Commit 3a2d5954 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

SelectableFilesWidget: Wire up logic to notify about selection changes



Change-Id: Iba9b31c9ba374855c024d4fb0739d3ba9ab43bc9
Reviewed-by: default avatarNiels Weber <niels.weber@theqtcompany.com>
parent 03a7b7d7
......@@ -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
......
......@@ -64,7 +64,6 @@ public:
private:
GenericProjectWizardDialog *m_genericProjectWizardDialog;
ProjectExplorer::SelectableFilesWidget *m_filesWidget;
bool m_finished = false;
};
} // namespace Internal
......
......@@ -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);
......
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment