Commit ba15f8ec authored by Nicolas Arnaud-Cormos's avatar Nicolas Arnaud-Cormos Committed by Eike Ziller

Add an enabled property in locator, and used it instead of hidden.

Disabled locator won't be displayed in the filter list, but will be
visible in the option page.

Change-Id: I4d39bb8ed04ce49fc34aa84c229b51f26fc70733
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent 19b1a06e
......@@ -54,6 +54,9 @@ CMakeLocatorFilter::CMakeLocatorFilter()
this, SLOT(slotProjectListUpdated()));
connect(sm, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
this, SLOT(slotProjectListUpdated()));
// Initialize the filter
slotProjectListUpdated();
}
CMakeLocatorFilter::~CMakeLocatorFilter()
......@@ -140,6 +143,6 @@ void CMakeLocatorFilter::slotProjectListUpdated()
break;
}
// Hide the locator if there's no CMake project
setHidden(!cmakeProject);
// Enable the filter if there's at least one CMake project
setEnabled(cmakeProject);
}
......@@ -121,11 +121,6 @@ void CommandLocator::accept(Locator::FilterEntry entry) const
action->trigger();
}
void CommandLocator::setEnabled(bool e)
{
setHidden(!e);
}
void CommandLocator::refresh(QFutureInterface<void> &)
{
}
......
......@@ -71,9 +71,6 @@ public:
virtual void accept(FilterEntry selection) const;
virtual void refresh(QFutureInterface<void> &future);
public slots:
void setEnabled(bool e);
private:
CommandLocatorPrivate *d;
};
......
......@@ -44,7 +44,8 @@ using namespace Locator;
ILocatorFilter::ILocatorFilter(QObject *parent):
QObject(parent),
m_includedByDefault(false),
m_hidden(false)
m_hidden(false),
m_enabled(true)
{
}
......@@ -140,3 +141,13 @@ void ILocatorFilter::setHidden(bool hidden)
{
m_hidden = hidden;
}
bool ILocatorFilter::isEnabled() const
{
return m_enabled;
}
void ILocatorFilter::setEnabled(bool enabled)
{
m_enabled = enabled;
}
......@@ -133,6 +133,9 @@ public:
/* Returns whether the filter should be hidden from configuration and menus. */
bool isHidden() const;
/* Returns whether the filter should be enabled and used in menus. */
bool isEnabled() const;
static QString trimWildcards(const QString &str) {
if (str.isEmpty())
return str;
......@@ -146,6 +149,10 @@ public:
return str.mid(first, last-first+1);
}
public slots:
/* Enable or disable the filter. */
void setEnabled(bool enabled);
protected:
void setShortcutString(const QString &shortcut);
void setIncludedByDefault(bool includedByDefault);
......@@ -155,6 +162,7 @@ private:
QString m_shortcut;
bool m_includedByDefault;
bool m_hidden;
bool m_enabled;
};
} // namespace Locator
......
......@@ -81,7 +81,7 @@ QList<FilterEntry> LocatorFiltersFilter::matchesFor(QFutureInterface<Locator::Fi
foreach (ILocatorFilter *filter, uniqueFilters) {
if (future.isCanceled())
break;
if (!filter->shortcutString().isEmpty() && !filter->isHidden()) {
if (!filter->shortcutString().isEmpty() && !filter->isHidden() && filter->isEnabled()) {
FilterEntry filterEntry(this,
filter->shortcutString(),
QVariant::fromValue(filter),
......
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