Commit be1e4d85 authored by Daniel Teske's avatar Daniel Teske
Browse files

Generic Project: Preserve out of project files on "Edit Files"

Change-Id: Ia71ed20f8cd5563f1e7fce7a99cf12fc4e7e62c2
Reviewed-on: http://codereview.qt.nokia.com/1076


Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarOswald Buddenhagen <oswald.buddenhagen@nokia.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent b48ccacb
......@@ -58,6 +58,12 @@ SelectableFilesModel::SelectableFilesModel(const QString &baseDir, QObject *pare
void SelectableFilesModel::setInitialMarkedFiles(const QStringList &files)
{
m_files = files.toSet();
m_outOfBaseDirFiles.clear();
QString base = m_baseDir + '/';
foreach (const QString &file, m_files)
if (!file.startsWith(base))
m_outOfBaseDirFiles.append(file);
m_allFiles = false;
}
......@@ -333,11 +339,16 @@ void SelectableFilesModel::collectPaths(Tree *root, QStringList *result) const
QStringList SelectableFilesModel::selectedFiles() const
{
QStringList result;
QStringList result = m_outOfBaseDirFiles;
collectFiles(m_root, &result);
return result;
}
QStringList SelectableFilesModel::preservedFiles() const
{
return m_outOfBaseDirFiles;
}
void SelectableFilesModel::collectFiles(Tree *root, QStringList *result) const
{
if (root->checked == Qt::Unchecked)
......@@ -526,6 +537,10 @@ SelectableFilesDialog::SelectableFilesDialog(const QString &path, const QStringL
m_view->hide();
layout->addWidget(m_view);
m_preservedFiles = new QLabel;
m_preservedFiles->hide();
layout->addWidget(m_preservedFiles);
m_progressLabel = new QLabel(this);
m_progressLabel->setMaximumWidth(500);
layout->addWidget(m_progressLabel);
......@@ -569,6 +584,13 @@ void SelectableFilesDialog::parsingFinished()
m_view->expand(QModelIndex());
smartExpand(m_selectableFilesModel->index(0,0, QModelIndex()));
applyFilter();
const QStringList &preservedFiles = m_selectableFilesModel->preservedFiles();
if (preservedFiles.isEmpty()) {
m_preservedFiles->hide();
} else {
m_preservedFiles->show();
m_preservedFiles->setText(tr("Not showing %1 files that are outside of the base directory.\nThese files are preserved.").arg(preservedFiles.count()));
}
}
void SelectableFilesDialog::smartExpand(const QModelIndex &index)
......
......@@ -88,6 +88,7 @@ public:
QStringList selectedFiles() const;
QStringList selectedPaths() const;
QStringList preservedFiles() const;
// only call this once
void startParsing();
......@@ -115,6 +116,7 @@ private:
// Used in the future thread need to all not used after calling startParsing
QString m_baseDir;
QSet<QString> m_files;
QStringList m_outOfBaseDirFiles;
QSet<QString> m_suffixes;
QFutureWatcher<void> m_watcher;
Tree *m_rootForFuture;
......@@ -143,6 +145,7 @@ private:
QLineEdit *m_filterLineEdit;
QPushButton *m_applyFilterButton;
QTreeView *m_view;
QLabel *m_preservedFiles;
QLabel *m_progressLabel;
};
......
Supports Markdown
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