From 2ccf92f543e12b5db2e7884a6973d5153b4d896d Mon Sep 17 00:00:00 2001 From: Samuel Findlay Date: Tue, 5 Jun 2012 19:20:07 +1000 Subject: [PATCH] Improved isComplete() validation for single file/folder. --- openlp/plugins/songs/forms/songimportform.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 9d9a1a65b..0b7e24c8d 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -496,8 +496,11 @@ class SongImportSourcePage(QtGui.QWizardPage): def isComplete(self): """ - Returns True if an available format is selected, and the - file/folder/files widget is not empty. + Returns True if: + * an available format is selected, and + * if MultipleFiles mode, at least one file is selected + * or if SingleFile mode, the specified file exists + * or if SingleFolder mode, the specified folder exists When this method returns True, the wizard's Next button is enabled. """ @@ -510,7 +513,12 @@ class SongImportSourcePage(QtGui.QWizardPage): if wizard.formatWidgets[format][u'fileListWidget'].count() > 0: return True else: - filepathEdit = wizard.formatWidgets[format][u'filepathEdit'] - if not filepathEdit.text().isEmpty(): - return True + filepath = wizard.formatWidgets[format][u'filepathEdit'].text() + if not filepath.isEmpty(): + if select_mode == SongFormatSelect.SingleFile\ + and os.path.isfile(filepath): + return True + elif select_mode == SongFormatSelect.SingleFolder\ + and os.path.isdir(filepath): + return True return False