changeset 45:213d9163dab0

Add error handling to the folder selection dialog
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 06 May 2015 19:45:44 +0200
parents 73e6b6b12412
children 97c14310cc1a
files src/folderselectdialog.cpp
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/folderselectdialog.cpp	Wed May 06 19:45:26 2015 +0200
+++ b/src/folderselectdialog.cpp	Wed May 06 19:45:44 2015 +0200
@@ -24,6 +24,7 @@
 #include <QSettings>
 #include <QStringList>
 #include <QStandardItem>
+#include <QMessageBox>
 
 FolderSelectDialog::FolderSelectDialog(const QString& startFolder,
                                        const QString& folderPattern,
@@ -145,13 +146,14 @@
     mModel->setHorizontalHeaderLabels(columns);
     QDir dir(folder);
     qDebug() << "Folder set to: " << folder;
+    QStringList errors;
     foreach (const QString & subfolder, dir.entryList(QDir::Dirs |
                                                       QDir::Readable |
                                                       QDir::NoDotAndDotDot)) {
         qDebug() << "Looking at: " << subfolder;
         QStringList itemData = subfolder.split(PATTERN_SEPERATOR);
         if (itemData.size() != columns.size()) {
-            qDebug() << "Failed to parse: " << subfolder;
+            errors << subfolder;
             continue;
         }
         QList<QStandardItem*> items;
@@ -163,6 +165,11 @@
         mModel->appendRow(items);
     }
     mSortModel->setSourceModel(mModel);
+    if (!errors.isEmpty()) {
+        QString errMsg = tr("The following folders did not match the pattern: %1").arg(mFolderPattern);
+        errMsg += "\n" + errors.join("\n");
+        QMessageBox::warning(this, tr("Failed to parse some folders."), errMsg);
+    }
 }
 
 void FolderSelectDialog::wantToAccept() {
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)