forked from qt-creator/qt-creator
Current Project FindFilter: Show the project displayname
Change-Id: I91b083a91ff782fed1e8514a3690965708eff4dd Task-number: QTCREATORBUG-14932 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -176,6 +176,16 @@ void FindPlugin::filterChanged()
|
||||
d->m_openFindDialog->setEnabled(haveEnabledFilters);
|
||||
}
|
||||
|
||||
void FindPlugin::displayNameChanged()
|
||||
{
|
||||
IFindFilter *changedFilter = qobject_cast<IFindFilter *>(sender());
|
||||
QAction *action = d->m_filterActions.value(changedFilter);
|
||||
QTC_ASSERT(changedFilter, return);
|
||||
QTC_ASSERT(action, return);
|
||||
action->setText(QLatin1String(" ") + changedFilter->displayName());
|
||||
d->m_findDialog->updateFindFilterNames();
|
||||
}
|
||||
|
||||
void FindPlugin::openFindFilter()
|
||||
{
|
||||
QAction *action = qobject_cast<QAction*>(sender());
|
||||
@@ -241,10 +251,12 @@ void FindPlugin::setupFilterMenuItems()
|
||||
action->setData(qVariantFromValue(filter));
|
||||
cmd = ActionManager::registerAction(action, base.withSuffix(filter->id()));
|
||||
cmd->setDefaultKeySequence(filter->defaultShortcut());
|
||||
cmd->setAttribute(Command::CA_UpdateText);
|
||||
mfindadvanced->addAction(cmd);
|
||||
d->m_filterActions.insert(filter, action);
|
||||
connect(action, &QAction::triggered, this, &FindPlugin::openFindFilter);
|
||||
connect(filter, &IFindFilter::enabledChanged, this, &FindPlugin::filterChanged);
|
||||
connect(filter, &IFindFilter::displayNameChanged, this, &FindPlugin::displayNameChanged);
|
||||
}
|
||||
d->m_findDialog->setFindFilters(findInterfaces);
|
||||
d->m_openFindDialog->setEnabled(haveEnabledFilters);
|
||||
|
||||
@@ -90,6 +90,7 @@ signals:
|
||||
|
||||
private slots:
|
||||
void filterChanged();
|
||||
void displayNameChanged();
|
||||
void openFindFilter();
|
||||
void writeSettings();
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QSettings>
|
||||
#include <QStringListModel>
|
||||
@@ -158,6 +159,15 @@ void FindToolWindow::setFindFilters(const QList<IFindFilter *> &filters)
|
||||
setCurrentFilter(0);
|
||||
}
|
||||
|
||||
void FindToolWindow::updateFindFilterNames()
|
||||
{
|
||||
int currentIndex = m_ui.filterList->currentIndex();
|
||||
m_ui.filterList->clear();
|
||||
QStringList names = Utils::transform(m_filters, &IFindFilter::displayName);
|
||||
m_ui.filterList->addItems(names);
|
||||
m_ui.filterList->setCurrentIndex(currentIndex);
|
||||
}
|
||||
|
||||
void FindToolWindow::setFindText(const QString &text)
|
||||
{
|
||||
m_ui.searchTerm->setText(text);
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
void setCurrentFilter(IFindFilter *filter);
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
void updateFindFilterNames();
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event);
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
static QString descriptionForFindFlags(FindFlags flags);
|
||||
signals:
|
||||
void enabledChanged(bool enabled);
|
||||
void displayNameChanged();
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
@@ -57,7 +57,11 @@ QString CurrentProjectFind::id() const
|
||||
|
||||
QString CurrentProjectFind::displayName() const
|
||||
{
|
||||
return tr("Current Project");
|
||||
Project *p = ProjectTree::currentProject();
|
||||
if (p)
|
||||
return tr("Project \"%1\"").arg(p->displayName());
|
||||
else
|
||||
return tr("Current Project");
|
||||
}
|
||||
|
||||
bool CurrentProjectFind::isEnabled() const
|
||||
@@ -96,6 +100,7 @@ QString CurrentProjectFind::label() const
|
||||
void CurrentProjectFind::handleProjectChanged()
|
||||
{
|
||||
emit enabledChanged(isEnabled());
|
||||
emit displayNameChanged();
|
||||
}
|
||||
|
||||
void CurrentProjectFind::recheckEnabled()
|
||||
|
||||
Reference in New Issue
Block a user