forked from qt-creator/qt-creator
SelectableFilesWidget: Wire up logic to notify about selection changes
Change-Id: Iba9b31c9ba374855c024d4fb0739d3ba9ab43bc9 Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
This commit is contained in:
@@ -55,6 +55,8 @@ FilesSelectionWizardPage::FilesSelectionWizardPage(GenericProjectWizardDialog *g
|
|||||||
|
|
||||||
layout->addWidget(m_filesWidget);
|
layout->addWidget(m_filesWidget);
|
||||||
m_filesWidget->setBaseDirEditable(false);
|
m_filesWidget->setBaseDirEditable(false);
|
||||||
|
connect(m_filesWidget, &ProjectExplorer::SelectableFilesWidget::selectedFilesChanged,
|
||||||
|
this, &FilesSelectionWizardPage::completeChanged);
|
||||||
|
|
||||||
setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Files"));
|
setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Files"));
|
||||||
}
|
}
|
||||||
@@ -72,7 +74,7 @@ void FilesSelectionWizardPage::cleanupPage()
|
|||||||
|
|
||||||
bool FilesSelectionWizardPage::isComplete() const
|
bool FilesSelectionWizardPage::isComplete() const
|
||||||
{
|
{
|
||||||
return m_finished;
|
return m_filesWidget->hasFilesSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::FileNameList FilesSelectionWizardPage::selectedPaths() const
|
Utils::FileNameList FilesSelectionWizardPage::selectedPaths() const
|
||||||
|
@@ -64,7 +64,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
GenericProjectWizardDialog *m_genericProjectWizardDialog;
|
GenericProjectWizardDialog *m_genericProjectWizardDialog;
|
||||||
ProjectExplorer::SelectableFilesWidget *m_filesWidget;
|
ProjectExplorer::SelectableFilesWidget *m_filesWidget;
|
||||||
bool m_finished = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -59,6 +59,9 @@ SelectableFilesModel::SelectableFilesModel(QObject *parent) : QAbstractItemModel
|
|||||||
connect(&m_watcher, &QFutureWatcherBase::finished,
|
connect(&m_watcher, &QFutureWatcherBase::finished,
|
||||||
this, &SelectableFilesModel::buildTreeFinished);
|
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 = new Tree;
|
||||||
m_root->parent = 0;
|
m_root->parent = 0;
|
||||||
}
|
}
|
||||||
@@ -340,6 +343,11 @@ Utils::FileNameList SelectableFilesModel::preservedFiles() const
|
|||||||
return m_outOfBaseDirFiles.toList();
|
return m_outOfBaseDirFiles.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SelectableFilesModel::hasCheckedFiles() const
|
||||||
|
{
|
||||||
|
return m_root->checked != Qt::Unchecked;
|
||||||
|
}
|
||||||
|
|
||||||
void SelectableFilesModel::collectFiles(Tree *root, Utils::FileNameList *result) const
|
void SelectableFilesModel::collectFiles(Tree *root, Utils::FileNameList *result) const
|
||||||
{
|
{
|
||||||
if (root->checked == Qt::Unchecked)
|
if (root->checked == Qt::Unchecked)
|
||||||
@@ -395,6 +403,8 @@ void SelectableFilesModel::selectAllFiles(Tree *root)
|
|||||||
|
|
||||||
foreach (Tree *t, root->visibleFiles)
|
foreach (Tree *t, root->visibleFiles)
|
||||||
t->checked = Qt::Checked;
|
t->checked = Qt::Checked;
|
||||||
|
|
||||||
|
emit checkedFilesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::CheckState SelectableFilesModel::applyFilter(const QModelIndex &index)
|
Qt::CheckState SelectableFilesModel::applyFilter(const QModelIndex &index)
|
||||||
@@ -614,6 +624,11 @@ Utils::FileNameList SelectableFilesWidget::selectedPaths() const
|
|||||||
return m_model ? m_model->selectedPaths() : Utils::FileNameList();
|
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)
|
void SelectableFilesWidget::resetModel(const Utils::FileName &path, const Utils::FileNameList &files)
|
||||||
{
|
{
|
||||||
m_view->setModel(0);
|
m_view->setModel(0);
|
||||||
@@ -626,6 +641,8 @@ void SelectableFilesWidget::resetModel(const Utils::FileName &path, const Utils:
|
|||||||
this, &SelectableFilesWidget::parsingProgress);
|
this, &SelectableFilesWidget::parsingProgress);
|
||||||
connect(m_model, &SelectableFilesModel::parsingFinished,
|
connect(m_model, &SelectableFilesModel::parsingFinished,
|
||||||
this, &SelectableFilesWidget::parsingFinished);
|
this, &SelectableFilesWidget::parsingFinished);
|
||||||
|
connect(m_model, &SelectableFilesModel::checkedFilesChanged,
|
||||||
|
this, &SelectableFilesWidget::selectedFilesChanged);
|
||||||
|
|
||||||
m_baseDirChooser->setFileName(path);
|
m_baseDirChooser->setFileName(path);
|
||||||
m_view->setModel(m_model);
|
m_view->setModel(m_model);
|
||||||
|
@@ -112,6 +112,8 @@ public:
|
|||||||
Utils::FileNameList selectedPaths() const;
|
Utils::FileNameList selectedPaths() const;
|
||||||
Utils::FileNameList preservedFiles() const;
|
Utils::FileNameList preservedFiles() const;
|
||||||
|
|
||||||
|
bool hasCheckedFiles() const;
|
||||||
|
|
||||||
void startParsing(const Utils::FileName &baseDir);
|
void startParsing(const Utils::FileName &baseDir);
|
||||||
void cancel();
|
void cancel();
|
||||||
void applyFilter(const QString &selectFilesfilter, const QString &hideFilesfilter);
|
void applyFilter(const QString &selectFilesfilter, const QString &hideFilesfilter);
|
||||||
@@ -119,6 +121,7 @@ public:
|
|||||||
void selectAllFiles();
|
void selectAllFiles();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void checkedFilesChanged();
|
||||||
void parsingFinished();
|
void parsingFinished();
|
||||||
void parsingProgress(const Utils::FileName &fileName);
|
void parsingProgress(const Utils::FileName &fileName);
|
||||||
|
|
||||||
@@ -165,9 +168,14 @@ public:
|
|||||||
Utils::FileNameList selectedFiles() const;
|
Utils::FileNameList selectedFiles() const;
|
||||||
Utils::FileNameList selectedPaths() const;
|
Utils::FileNameList selectedPaths() const;
|
||||||
|
|
||||||
|
bool hasFilesSelected() const;
|
||||||
|
|
||||||
void resetModel(const Utils::FileName &path, const Utils::FileNameList &files);
|
void resetModel(const Utils::FileName &path, const Utils::FileNameList &files);
|
||||||
void cancelParsing();
|
void cancelParsing();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void selectedFilesChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void enableWidgets(bool enabled);
|
void enableWidgets(bool enabled);
|
||||||
void applyFilter();
|
void applyFilter();
|
||||||
|
Reference in New Issue
Block a user