diff --git a/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp b/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp index a8cdf8a660e..084774a9f81 100644 --- a/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp +++ b/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp @@ -55,6 +55,8 @@ FilesSelectionWizardPage::FilesSelectionWizardPage(GenericProjectWizardDialog *g layout->addWidget(m_filesWidget); m_filesWidget->setBaseDirEditable(false); + connect(m_filesWidget, &ProjectExplorer::SelectableFilesWidget::selectedFilesChanged, + this, &FilesSelectionWizardPage::completeChanged); setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Files")); } @@ -72,7 +74,7 @@ void FilesSelectionWizardPage::cleanupPage() bool FilesSelectionWizardPage::isComplete() const { - return m_finished; + return m_filesWidget->hasFilesSelected(); } Utils::FileNameList FilesSelectionWizardPage::selectedPaths() const diff --git a/src/plugins/genericprojectmanager/filesselectionwizardpage.h b/src/plugins/genericprojectmanager/filesselectionwizardpage.h index 50f862423c6..fe493f68e0c 100644 --- a/src/plugins/genericprojectmanager/filesselectionwizardpage.h +++ b/src/plugins/genericprojectmanager/filesselectionwizardpage.h @@ -64,7 +64,6 @@ public: private: GenericProjectWizardDialog *m_genericProjectWizardDialog; ProjectExplorer::SelectableFilesWidget *m_filesWidget; - bool m_finished = false; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/selectablefilesmodel.cpp b/src/plugins/projectexplorer/selectablefilesmodel.cpp index 53be72671bc..03419c749f2 100644 --- a/src/plugins/projectexplorer/selectablefilesmodel.cpp +++ b/src/plugins/projectexplorer/selectablefilesmodel.cpp @@ -59,6 +59,9 @@ SelectableFilesModel::SelectableFilesModel(QObject *parent) : QAbstractItemModel connect(&m_watcher, &QFutureWatcherBase::finished, this, &SelectableFilesModel::buildTreeFinished); + connect(this, &SelectableFilesModel::dataChanged, this, [this] { emit checkedFilesChanged(); }); + connect(this, &SelectableFilesModel::modelReset, this, [this] { emit checkedFilesChanged(); }); + m_root = new Tree; m_root->parent = 0; } @@ -340,6 +343,11 @@ Utils::FileNameList SelectableFilesModel::preservedFiles() const return m_outOfBaseDirFiles.toList(); } +bool SelectableFilesModel::hasCheckedFiles() const +{ + return m_root->checked != Qt::Unchecked; +} + void SelectableFilesModel::collectFiles(Tree *root, Utils::FileNameList *result) const { if (root->checked == Qt::Unchecked) @@ -395,6 +403,8 @@ void SelectableFilesModel::selectAllFiles(Tree *root) foreach (Tree *t, root->visibleFiles) t->checked = Qt::Checked; + + emit checkedFilesChanged(); } Qt::CheckState SelectableFilesModel::applyFilter(const QModelIndex &index) @@ -614,6 +624,11 @@ Utils::FileNameList SelectableFilesWidget::selectedPaths() const return m_model ? m_model->selectedPaths() : Utils::FileNameList(); } +bool SelectableFilesWidget::hasFilesSelected() const +{ + return m_model ? m_model->hasCheckedFiles() : false; +} + void SelectableFilesWidget::resetModel(const Utils::FileName &path, const Utils::FileNameList &files) { m_view->setModel(0); @@ -626,6 +641,8 @@ void SelectableFilesWidget::resetModel(const Utils::FileName &path, const Utils: this, &SelectableFilesWidget::parsingProgress); connect(m_model, &SelectableFilesModel::parsingFinished, this, &SelectableFilesWidget::parsingFinished); + connect(m_model, &SelectableFilesModel::checkedFilesChanged, + this, &SelectableFilesWidget::selectedFilesChanged); m_baseDirChooser->setFileName(path); m_view->setModel(m_model); diff --git a/src/plugins/projectexplorer/selectablefilesmodel.h b/src/plugins/projectexplorer/selectablefilesmodel.h index e637a53d16d..ab9218efa8f 100644 --- a/src/plugins/projectexplorer/selectablefilesmodel.h +++ b/src/plugins/projectexplorer/selectablefilesmodel.h @@ -112,6 +112,8 @@ public: Utils::FileNameList selectedPaths() const; Utils::FileNameList preservedFiles() const; + bool hasCheckedFiles() const; + void startParsing(const Utils::FileName &baseDir); void cancel(); void applyFilter(const QString &selectFilesfilter, const QString &hideFilesfilter); @@ -119,6 +121,7 @@ public: void selectAllFiles(); signals: + void checkedFilesChanged(); void parsingFinished(); void parsingProgress(const Utils::FileName &fileName); @@ -165,9 +168,14 @@ public: Utils::FileNameList selectedFiles() const; Utils::FileNameList selectedPaths() const; + bool hasFilesSelected() const; + void resetModel(const Utils::FileName &path, const Utils::FileNameList &files); void cancelParsing(); +signals: + void selectedFilesChanged(); + private: void enableWidgets(bool enabled); void applyFilter();