Commit cded30f0 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer

Hide the "Available Filters" locator

Done based on new IQuickOpenFilter property, isHidden.
parent 0145a3de
......@@ -62,7 +62,7 @@ QByteArray DirectoryFilter::saveState() const
out << m_directories;
out << m_filters;
out << shortcutString();
out << defaultActiveState();
out << isIncludedByDefault();
out << m_files;
return value;
}
......@@ -120,7 +120,7 @@ bool DirectoryFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
m_ui.directoryList->addItems(m_directories);
m_ui.fileTypeEdit->setText(m_filters.join(tr(",")));
m_ui.shortcutEdit->setText(shortcutString());
m_ui.defaultFlag->setChecked(!defaultActiveState());
m_ui.defaultFlag->setChecked(!isIncludedByDefault());
updateOptionButtons();
if (dialog.exec() == QDialog::Accepted) {
QMutexLocker locker(&m_lock);
......
......@@ -114,7 +114,7 @@ bool FileSystemFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
ui.setupUi(&dialog);
ui.hiddenFilesFlag->setChecked(m_includeHidden);
ui.limitCheck->setChecked(!defaultActiveState());
ui.limitCheck->setChecked(!isIncludedByDefault());
ui.shortcutEdit->setText(shortcutString());
if (dialog.exec() == QDialog::Accepted) {
......@@ -132,7 +132,7 @@ QByteArray FileSystemFilter::saveState() const
QDataStream out(&value, QIODevice::WriteOnly);
out << m_includeHidden;
out << shortcutString();
out << defaultActiveState();
out << isIncludedByDefault();
return value;
}
......
......@@ -43,7 +43,9 @@
using namespace QuickOpen;
IQuickOpenFilter::IQuickOpenFilter(QObject *parent):
QObject(parent)
QObject(parent),
m_includedByDefault(false),
m_hidden(false)
{
}
......@@ -62,7 +64,7 @@ QByteArray IQuickOpenFilter::saveState() const
QByteArray value;
QDataStream out(&value, QIODevice::WriteOnly);
out << shortcutString();
out << defaultActiveState();
out << isIncludedByDefault();
return value;
}
......@@ -91,7 +93,7 @@ bool IQuickOpenFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
QHBoxLayout *hlayout = new QHBoxLayout;
QLineEdit *shortcutEdit = new QLineEdit(shortcutString());
QCheckBox *limitCheck = new QCheckBox(tr("Limit to prefix"));
limitCheck->setChecked(!defaultActiveState());
limitCheck->setChecked(!isIncludedByDefault());
hlayout->addWidget(new QLabel(tr("Prefix:")));
hlayout->addWidget(shortcutEdit);
......@@ -120,12 +122,22 @@ bool IQuickOpenFilter::isConfigurable() const
return true;
}
bool IQuickOpenFilter::defaultActiveState() const
bool IQuickOpenFilter::isIncludedByDefault() const
{
return m_default;
return m_includedByDefault;
}
void IQuickOpenFilter::setIncludedByDefault(bool includedByDefault)
{
m_default = includedByDefault;
m_includedByDefault = includedByDefault;
}
bool IQuickOpenFilter::isHidden() const
{
return m_hidden;
}
void IQuickOpenFilter::setHidden(bool hidden)
{
m_hidden = hidden;
}
......@@ -87,26 +87,25 @@ public:
IQuickOpenFilter(QObject *parent = 0);
virtual ~IQuickOpenFilter() {}
/* visible name */
/* Visible name. */
virtual QString trName() const = 0;
/* internal name */
/* Internal name. */
virtual QString name() const = 0;
/* selection list order in case of multiple active filters (high goes on top) */
/* Selection list order in case of multiple active filters (high goes on top). */
virtual Priority priority() const = 0;
/* string to type to use this filter exclusively */
virtual QString shortcutString() const;
void setShortcutString(const QString &shortcut);
/* String to type to use this filter exclusively. */
QString shortcutString() const;
/* list of matches for the given user entry */
/* List of matches for the given user entry. */
virtual QList<FilterEntry> matchesFor(const QString &entry) = 0;
/* user has selected the given entry that belongs to this filter */
/* User has selected the given entry that belongs to this filter. */
virtual void accept(FilterEntry selection) const = 0;
/* implement to update caches on user request, if that's a long operation */
/* Implement to update caches on user request, if that's a long operation. */
virtual void refresh(QFutureInterface<void> &future) = 0;
/* Saved state is used to restore the filter at start up. */
......@@ -126,9 +125,11 @@ public:
* implementation returns true. */
virtual bool isConfigurable() const;
/* is this filter used also when the shortcutString is not used? */
virtual bool defaultActiveState() const;
void setIncludedByDefault(bool includedByDefault);
/* Is this filter used also when the shortcutString is not used? */
bool isIncludedByDefault() const;
/* Returns whether the filter should be hidden from configuration and menus. */
bool isHidden() const;
static QString trimWildcards(const QString &str) {
if (str.isEmpty())
......@@ -143,9 +144,15 @@ public:
return str.mid(first, last-first+1);
}
protected:
void setShortcutString(const QString &shortcut);
void setIncludedByDefault(bool includedByDefault);
void setHidden(bool hidden);
private:
QString m_shortcut;
bool m_default;
bool m_includedByDefault;
bool m_hidden;
};
} // namespace QuickOpen
......
......@@ -49,7 +49,7 @@ QuickOpenFiltersFilter::QuickOpenFiltersFilter(QuickOpenPlugin *plugin,
m_icon(QIcon(Core::Constants::ICON_NEXT))
{
setIncludedByDefault(true);
setShortcutString(QString());
setHidden(true);
}
QString QuickOpenFiltersFilter::trName() const
......@@ -71,8 +71,8 @@ QList<FilterEntry> QuickOpenFiltersFilter::matchesFor(const QString &entry)
{
QList<FilterEntry> entries;
if (entry.isEmpty()) {
foreach (IQuickOpenFilter* filter, m_plugin->filter()) {
if (!filter->shortcutString().isEmpty()) {
foreach (IQuickOpenFilter *filter, m_plugin->filter()) {
if (!filter->shortcutString().isEmpty() && !filter->isHidden()) {
FilterEntry entry(this,
filter->shortcutString(),
QVariant::fromValue(filter),
......
......@@ -314,7 +314,7 @@ void QuickOpenToolWindow::updateFilterList()
{
m_filterMenu->clear();
foreach (IQuickOpenFilter *filter, m_quickOpenPlugin->filter()) {
if (!filter->shortcutString().isEmpty()) {
if (!filter->shortcutString().isEmpty() && !filter->isHidden()) {
QAction *action = m_filterMenu->addAction(filter->trName(), this, SLOT(filterSelected()));
action->setData(qVariantFromValue(filter));
}
......@@ -396,7 +396,7 @@ QList<IQuickOpenFilter*> QuickOpenToolWindow::filtersFor(const QString &text, QS
searchText = text;
QList<IQuickOpenFilter*> activeFilters;
foreach (IQuickOpenFilter *filter, filters)
if (filter->defaultActiveState())
if (filter->isIncludedByDefault())
activeFilters << filter;
return activeFilters;
}
......
......@@ -121,8 +121,11 @@ void SettingsPage::updateFilterList()
{
m_ui.filterList->clear();
foreach (IQuickOpenFilter *filter, m_filters) {
if (filter->isHidden())
continue;
QString title;
if (filter->defaultActiveState())
if (filter->isIncludedByDefault())
title = filter->trName();
else
title = tr("%1 (Prefix: %2)").arg(filter->trName()).arg(filter->shortcutString());
......
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