diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index a6a1d4c29..bd0a60424 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -351,7 +351,9 @@ QStringList MainWindow::SelectFilesToCheck(QFileDialog::FileMode mode) // selection dialog which is a lot more usable than QT:s own dialog. if (mode == QFileDialog::ExistingFiles) { SelectFilesDialog dialog(this); - dialog.exec(); + if (dialog.exec() == QDialog::Accepted) { + selected = dialog.getFiles(); + } /* selected = QFileDialog::getOpenFileNames(this, tr("Select files to check"), diff --git a/gui/selectfilesdialog.cpp b/gui/selectfilesdialog.cpp index 7bdee28fb..1c1de68fa 100644 --- a/gui/selectfilesdialog.cpp +++ b/gui/selectfilesdialog.cpp @@ -1,6 +1,7 @@ #include "selectfilesdialog.h" #include "ui_selectfilesdialog.h" +#include "filelist.h" #include #include @@ -34,9 +35,13 @@ private: public: SelectFilesModel() : QFileSystemModel() { - QStringList f; - f << "*.cpp"; - setNameFilters(f); + class FileLister : private FileList { + public: + static QStringList filters() { + return GetDefaultFilters(); + } + }; + setNameFilters(FileLister::filters()); setNameFilterDisables(false); setRootPath("/"); } @@ -99,11 +104,31 @@ public: } return QFileSystemModel::setData(index, value, role); } + + QStringList getFiles() const { + QStringList ret; + + // List all files in "selected" folders.. + FileList fileLister; + fileLister.AddPathList(selected); + ret = fileLister.GetFileList(); + + // Remove all items from ret that are unselected but not selected.. + for (int i = ret.size() - 1; i >= 0; i--) { + int unselindex = getindex(unselected, ret[i]); + if (unselindex == -1) + continue; + + // both selected and unselected, check which to rely on + int selindex = getindex(selected, ret[i]); + if (selected[selindex].size() < unselected[unselindex].size()) + ret.removeAt(i); + } + + return ret; + } }; -SelectFilesDialog::~SelectFilesDialog() { - delete ui; -} SelectFilesDialog::SelectFilesDialog(QWidget *w) : @@ -112,9 +137,19 @@ SelectFilesDialog::SelectFilesDialog(QWidget *w) : { ui->setupUi(this); - ui->treeView->setModel(new SelectFilesModel); + selectfilesmodel = new SelectFilesModel; + + ui->treeView->setModel(selectfilesmodel); for (int i = 1; i < 4; ++i) ui->treeView->setColumnHidden(i, true); } +SelectFilesDialog::~SelectFilesDialog() +{ + delete ui; +} +QStringList SelectFilesDialog::getFiles() const +{ + return selectfilesmodel->getFiles(); +} diff --git a/gui/selectfilesdialog.h b/gui/selectfilesdialog.h index 126e7527b..2052e0815 100644 --- a/gui/selectfilesdialog.h +++ b/gui/selectfilesdialog.h @@ -3,18 +3,24 @@ #define selectfilesdialogH #include +#include namespace Ui { class SelectFilesDialog; } +class SelectFilesModel; + class SelectFilesDialog : public QDialog { public: explicit SelectFilesDialog(QWidget *w); ~SelectFilesDialog(); + QStringList getFiles() const; + private: Ui::SelectFilesDialog *ui; + SelectFilesModel *selectfilesmodel; }; #endif diff --git a/gui/selectfilesdialog.ui b/gui/selectfilesdialog.ui index 3931c6e74..3100f6c8e 100644 --- a/gui/selectfilesdialog.ui +++ b/gui/selectfilesdialog.ui @@ -11,7 +11,7 @@ - Dialog + Select files to check