forked from qt-creator/qt-creator
ProjectExplorer: Add history completion ability to SelectableFilesWidget
... and make use of it in project contexts. Fixes: QTCREATORBUG-19781 Change-Id: I4618b6e4a64b1aaa1352afcc98e4cc6e5fac1859 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#include "genericprojectconstants.h"
|
#include "genericprojectconstants.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/selectablefilesmodel.h>
|
#include <projectexplorer/selectablefilesmodel.h>
|
||||||
|
|
||||||
#include <utils/wizard.h>
|
#include <utils/wizard.h>
|
||||||
@@ -47,6 +48,8 @@ FilesSelectionWizardPage::FilesSelectionWizardPage(GenericProjectWizardDialog *g
|
|||||||
auto layout = new QVBoxLayout(this);
|
auto layout = new QVBoxLayout(this);
|
||||||
|
|
||||||
layout->addWidget(m_filesWidget);
|
layout->addWidget(m_filesWidget);
|
||||||
|
m_filesWidget->enableFilterHistoryCompletion
|
||||||
|
(ProjectExplorer::Constants::ADD_FILES_DIALOG_FILTER_HISTORY_KEY);
|
||||||
m_filesWidget->setBaseDirEditable(false);
|
m_filesWidget->setBaseDirEditable(false);
|
||||||
connect(m_filesWidget, &ProjectExplorer::SelectableFilesWidget::selectedFilesChanged,
|
connect(m_filesWidget, &ProjectExplorer::SelectableFilesWidget::selectedFilesChanged,
|
||||||
this, &FilesSelectionWizardPage::completeChanged);
|
this, &FilesSelectionWizardPage::completeChanged);
|
||||||
|
@@ -3317,7 +3317,9 @@ void ProjectExplorerPluginPrivate::addExistingDirectory()
|
|||||||
|
|
||||||
SelectableFilesDialogAddDirectory dialog(Utils::FileName::fromString(directoryFor(node)),
|
SelectableFilesDialogAddDirectory dialog(Utils::FileName::fromString(directoryFor(node)),
|
||||||
Utils::FileNameList(), ICore::mainWindow());
|
Utils::FileNameList(), ICore::mainWindow());
|
||||||
dialog.setAddFileFilter(folderNode->addFileFilter());
|
const QString addFileFilter = folderNode->addFileFilter();
|
||||||
|
if (!addFileFilter.isEmpty())
|
||||||
|
dialog.setAddFileFilter(addFileFilter);
|
||||||
|
|
||||||
if (dialog.exec() == QDialog::Accepted)
|
if (dialog.exec() == QDialog::Accepted)
|
||||||
ProjectExplorerPlugin::addExistingFiles(folderNode, Utils::transform(dialog.selectedFiles(), &Utils::FileName::toString));
|
ProjectExplorerPlugin::addExistingFiles(folderNode, Utils::transform(dialog.selectedFiles(), &Utils::FileName::toString));
|
||||||
|
@@ -211,5 +211,7 @@ const char FILEOVERLAY_H[]=":/projectexplorer/images/fileoverlay_h.png";
|
|||||||
const char FILEOVERLAY_SCXML[]=":/projectexplorer/images/fileoverlay_scxml.png";
|
const char FILEOVERLAY_SCXML[]=":/projectexplorer/images/fileoverlay_scxml.png";
|
||||||
const char FILEOVERLAY_UNKNOWN[]=":/projectexplorer/images/fileoverlay_unknown.png";
|
const char FILEOVERLAY_UNKNOWN[]=":/projectexplorer/images/fileoverlay_unknown.png";
|
||||||
|
|
||||||
|
const char ADD_FILES_DIALOG_FILTER_HISTORY_KEY[] = "ProjectExplorer.AddFilesFilterKey";
|
||||||
|
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -29,8 +29,10 @@
|
|||||||
#include <coreplugin/fileiconprovider.h>
|
#include <coreplugin/fileiconprovider.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <utils/runextensions.h>
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/fancylineedit.h>
|
||||||
|
#include <utils/pathchooser.h>
|
||||||
|
#include <utils/runextensions.h>
|
||||||
|
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
@@ -39,7 +41,6 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <utils/pathchooser.h>
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
@@ -533,9 +534,9 @@ SelectableFilesWidget::SelectableFilesWidget(QWidget *parent) :
|
|||||||
m_baseDirLabel(new QLabel),
|
m_baseDirLabel(new QLabel),
|
||||||
m_startParsingButton(new QPushButton),
|
m_startParsingButton(new QPushButton),
|
||||||
m_selectFilesFilterLabel(new QLabel),
|
m_selectFilesFilterLabel(new QLabel),
|
||||||
m_selectFilesFilterEdit(new QLineEdit),
|
m_selectFilesFilterEdit(new Utils::FancyLineEdit),
|
||||||
m_hideFilesFilterLabel(new QLabel),
|
m_hideFilesFilterLabel(new QLabel),
|
||||||
m_hideFilesFilterEdit(new QLineEdit),
|
m_hideFilesFilterEdit(new Utils::FancyLineEdit),
|
||||||
m_applyFiltersButton(new QPushButton),
|
m_applyFiltersButton(new QPushButton),
|
||||||
m_view(new QTreeView),
|
m_view(new QTreeView),
|
||||||
m_preservedFilesLabel(new QLabel),
|
m_preservedFilesLabel(new QLabel),
|
||||||
@@ -652,6 +653,12 @@ void SelectableFilesWidget::cancelParsing()
|
|||||||
m_model->cancel();
|
m_model->cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SelectableFilesWidget::enableFilterHistoryCompletion(const QString &keyPrefix)
|
||||||
|
{
|
||||||
|
m_selectFilesFilterEdit->setHistoryCompleter(keyPrefix + ".select", true);
|
||||||
|
m_hideFilesFilterEdit->setHistoryCompleter(keyPrefix + ".hide", true);
|
||||||
|
}
|
||||||
|
|
||||||
void SelectableFilesWidget::enableWidgets(bool enabled)
|
void SelectableFilesWidget::enableWidgets(bool enabled)
|
||||||
{
|
{
|
||||||
m_hideFilesFilterEdit->setEnabled(enabled);
|
m_hideFilesFilterEdit->setEnabled(enabled);
|
||||||
@@ -733,6 +740,7 @@ SelectableFilesDialogEditFiles::SelectableFilesDialogEditFiles(const Utils::File
|
|||||||
layout->addWidget(m_filesWidget);
|
layout->addWidget(m_filesWidget);
|
||||||
|
|
||||||
m_filesWidget->setBaseDirEditable(false);
|
m_filesWidget->setBaseDirEditable(false);
|
||||||
|
m_filesWidget->enableFilterHistoryCompletion(Constants::ADD_FILES_DIALOG_FILTER_HISTORY_KEY);
|
||||||
|
|
||||||
auto buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
|
auto buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
|
||||||
buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
@@ -749,6 +757,7 @@ Utils::FileNameList SelectableFilesDialogEditFiles::selectedFiles() const
|
|||||||
return m_filesWidget->selectedFiles();
|
return m_filesWidget->selectedFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
// SelectableFilesDialogAddDirectory
|
// SelectableFilesDialogAddDirectory
|
||||||
//////////
|
//////////
|
||||||
|
@@ -36,7 +36,10 @@
|
|||||||
|
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
namespace Utils { class PathChooser; }
|
namespace Utils {
|
||||||
|
class FancyLineEdit;
|
||||||
|
class PathChooser;
|
||||||
|
}
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
@@ -202,6 +205,8 @@ public:
|
|||||||
void resetModel(const Utils::FileName &path, const Utils::FileNameList &files);
|
void resetModel(const Utils::FileName &path, const Utils::FileNameList &files);
|
||||||
void cancelParsing();
|
void cancelParsing();
|
||||||
|
|
||||||
|
void enableFilterHistoryCompletion(const QString &keyPrefix);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void selectedFilesChanged();
|
void selectedFilesChanged();
|
||||||
|
|
||||||
@@ -223,10 +228,10 @@ private:
|
|||||||
QPushButton *m_startParsingButton;
|
QPushButton *m_startParsingButton;
|
||||||
|
|
||||||
QLabel *m_selectFilesFilterLabel;
|
QLabel *m_selectFilesFilterLabel;
|
||||||
QLineEdit *m_selectFilesFilterEdit;
|
Utils::FancyLineEdit *m_selectFilesFilterEdit;
|
||||||
|
|
||||||
QLabel *m_hideFilesFilterLabel;
|
QLabel *m_hideFilesFilterLabel;
|
||||||
QLineEdit *m_hideFilesFilterEdit;
|
Utils::FancyLineEdit *m_hideFilesFilterEdit;
|
||||||
|
|
||||||
QPushButton *m_applyFiltersButton;
|
QPushButton *m_applyFiltersButton;
|
||||||
|
|
||||||
@@ -259,8 +264,6 @@ class SelectableFilesDialogAddDirectory : public SelectableFilesDialogEditFiles
|
|||||||
public:
|
public:
|
||||||
SelectableFilesDialogAddDirectory(const Utils::FileName &path, const Utils::FileNameList &files,
|
SelectableFilesDialogAddDirectory(const Utils::FileName &path, const Utils::FileNameList &files,
|
||||||
QWidget *parent);
|
QWidget *parent);
|
||||||
|
|
||||||
void setAddFileFilter(const QString &filter) { m_filesWidget->setAddFileFilter(filter); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -86,6 +86,8 @@ FilesSelectionWizardPage::FilesSelectionWizardPage(SimpleProjectWizardDialog *si
|
|||||||
|
|
||||||
layout->addWidget(m_filesWidget);
|
layout->addWidget(m_filesWidget);
|
||||||
m_filesWidget->setBaseDirEditable(false);
|
m_filesWidget->setBaseDirEditable(false);
|
||||||
|
m_filesWidget->enableFilterHistoryCompletion
|
||||||
|
(ProjectExplorer::Constants::ADD_FILES_DIALOG_FILTER_HISTORY_KEY);
|
||||||
connect(m_filesWidget, &SelectableFilesWidget::selectedFilesChanged,
|
connect(m_filesWidget, &SelectableFilesWidget::selectedFilesChanged,
|
||||||
this, &FilesSelectionWizardPage::completeChanged);
|
this, &FilesSelectionWizardPage::completeChanged);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user