# HG changeset patch # User Andre Heinecke # Date 1430934344 -7200 # Node ID 213d9163dab0aecb4fe7bd00ccbd7b424d2df168 # Parent 73e6b6b12412eef6c8edf4a5c389db15532c2682 Add error handling to the folder selection dialog diff -r 73e6b6b12412 -r 213d9163dab0 src/folderselectdialog.cpp --- 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 #include #include +#include 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 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() {