Generic Project: Better filtering of supported files.

In the edit files dialog and project wizard, initial filtering of files
was done by checking the file suffix in mime database. This does not
work for all files (e.g. makefiles), and is not needed: filtering is
done afterwards using a user-editable filter string.

Change-Id: I0664aa5b3c52b663d6d94020df4e1986dd7c69a5
Reviewed-by: Thorbjørn Lindeijer
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
Francois Ferrand
2012-02-29 11:19:18 +01:00
committed by Daniel Teske
parent 46a6e9e9e8
commit ff652f0a59
4 changed files with 4 additions and 16 deletions

View File

@@ -84,9 +84,7 @@ void FilesSelectionWizardPage::initializePage()
{ {
m_view->setModel(0); m_view->setModel(0);
delete m_model; delete m_model;
Core::MimeDatabase *mimeDatabase = Core::ICore::mimeDatabase();
m_model = new SelectableFilesModel(m_genericProjectWizardDialog->path(), this); m_model = new SelectableFilesModel(m_genericProjectWizardDialog->path(), this);
m_model->setSuffixes(mimeDatabase->suffixes().toSet());
connect(m_model, SIGNAL(parsingProgress(QString)), connect(m_model, SIGNAL(parsingProgress(QString)),
this, SLOT(parsingProgress(QString))); this, SLOT(parsingProgress(QString)));
connect(m_model, SIGNAL(parsingFinished()), connect(m_model, SIGNAL(parsingFinished()),

View File

@@ -122,10 +122,8 @@ void GenericProjectPlugin::updateContextMenu(ProjectExplorer::Project *project,
void GenericProjectPlugin::editFiles() void GenericProjectPlugin::editFiles()
{ {
GenericProject *genericProject = static_cast<GenericProject *>(m_contextMenuProject); GenericProject *genericProject = static_cast<GenericProject *>(m_contextMenuProject);
Core::MimeDatabase *mimeDatabase = Core::ICore::mimeDatabase();
SelectableFilesDialog sfd(QFileInfo(genericProject->document()->fileName()).path(), genericProject->files(), SelectableFilesDialog sfd(QFileInfo(genericProject->document()->fileName()).path(), genericProject->files(),
mimeDatabase->suffixes().toSet(), Core::ICore::mainWindow()); Core::ICore::mainWindow());
if (sfd.exec() == QDialog::Accepted) { if (sfd.exec() == QDialog::Accepted) {
genericProject->setFiles(sfd.selectedFiles()); genericProject->setFiles(sfd.selectedFiles());
} }

View File

@@ -69,11 +69,6 @@ void SelectableFilesModel::setInitialMarkedFiles(const QStringList &files)
m_allFiles = false; m_allFiles = false;
} }
void SelectableFilesModel::setSuffixes(QSet<QString> suffixes)
{
m_suffixes = suffixes;
}
void SelectableFilesModel::init() void SelectableFilesModel::init()
{ {
} }
@@ -164,7 +159,7 @@ void SelectableFilesModel::buildTree(const QString &baseDir, Tree *tree, QFuture
allChecked &= t->checked == Qt::Checked; allChecked &= t->checked == Qt::Checked;
allUnchecked &= t->checked == Qt::Unchecked; allUnchecked &= t->checked == Qt::Unchecked;
tree->childDirectories.append(t); tree->childDirectories.append(t);
} else if (m_suffixes.contains(fileInfo.suffix())) { } else {
Tree *t = new Tree; Tree *t = new Tree;
t->parent = tree; t->parent = tree;
t->name = fileInfo.fileName(); t->name = fileInfo.fileName();
@@ -509,7 +504,7 @@ Qt::CheckState SelectableFilesModel::applyFilter(const QModelIndex &index)
// SelectableFilesDialog // SelectableFilesDialog
////////// //////////
SelectableFilesDialog::SelectableFilesDialog(const QString &path, const QStringList files, const QSet<QString> &suffixes, QWidget *parent) SelectableFilesDialog::SelectableFilesDialog(const QString &path, const QStringList files, QWidget *parent)
: QDialog(parent) : QDialog(parent)
{ {
QVBoxLayout *layout = new QVBoxLayout(); QVBoxLayout *layout = new QVBoxLayout();
@@ -537,7 +532,6 @@ SelectableFilesDialog::SelectableFilesDialog(const QString &path, const QStringL
m_selectableFilesModel = new SelectableFilesModel(path, this); m_selectableFilesModel = new SelectableFilesModel(path, this);
m_selectableFilesModel->setInitialMarkedFiles(files); m_selectableFilesModel->setInitialMarkedFiles(files);
m_selectableFilesModel->setSuffixes(suffixes);
m_view->setModel(m_selectableFilesModel); m_view->setModel(m_selectableFilesModel);
m_view->setMinimumSize(500, 400); m_view->setMinimumSize(500, 400);
m_view->setHeaderHidden(true); m_view->setHeaderHidden(true);

View File

@@ -74,7 +74,6 @@ public:
SelectableFilesModel(const QString &baseDir, QObject *parent); SelectableFilesModel(const QString &baseDir, QObject *parent);
~SelectableFilesModel(); ~SelectableFilesModel();
void setSuffixes(QSet<QString> suffixes);
void setInitialMarkedFiles(const QStringList &files); void setInitialMarkedFiles(const QStringList &files);
int columnCount(const QModelIndex &parent) const; int columnCount(const QModelIndex &parent) const;
@@ -117,7 +116,6 @@ private:
QString m_baseDir; QString m_baseDir;
QSet<QString> m_files; QSet<QString> m_files;
QStringList m_outOfBaseDirFiles; QStringList m_outOfBaseDirFiles;
QSet<QString> m_suffixes;
QFutureWatcher<void> m_watcher; QFutureWatcher<void> m_watcher;
Tree *m_rootForFuture; Tree *m_rootForFuture;
int m_futureCount; int m_futureCount;
@@ -129,7 +127,7 @@ class SelectableFilesDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
SelectableFilesDialog(const QString &path, const QStringList files, const QSet<QString> &suffixes, QWidget *parent); SelectableFilesDialog(const QString &path, const QStringList files, QWidget *parent);
~SelectableFilesDialog(); ~SelectableFilesDialog();
QStringList selectedFiles() const; QStringList selectedFiles() const;