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);
|
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()
|
void FindPlugin::openFindFilter()
|
||||||
{
|
{
|
||||||
QAction *action = qobject_cast<QAction*>(sender());
|
QAction *action = qobject_cast<QAction*>(sender());
|
||||||
@@ -241,10 +251,12 @@ void FindPlugin::setupFilterMenuItems()
|
|||||||
action->setData(qVariantFromValue(filter));
|
action->setData(qVariantFromValue(filter));
|
||||||
cmd = ActionManager::registerAction(action, base.withSuffix(filter->id()));
|
cmd = ActionManager::registerAction(action, base.withSuffix(filter->id()));
|
||||||
cmd->setDefaultKeySequence(filter->defaultShortcut());
|
cmd->setDefaultKeySequence(filter->defaultShortcut());
|
||||||
|
cmd->setAttribute(Command::CA_UpdateText);
|
||||||
mfindadvanced->addAction(cmd);
|
mfindadvanced->addAction(cmd);
|
||||||
d->m_filterActions.insert(filter, action);
|
d->m_filterActions.insert(filter, action);
|
||||||
connect(action, &QAction::triggered, this, &FindPlugin::openFindFilter);
|
connect(action, &QAction::triggered, this, &FindPlugin::openFindFilter);
|
||||||
connect(filter, &IFindFilter::enabledChanged, this, &FindPlugin::filterChanged);
|
connect(filter, &IFindFilter::enabledChanged, this, &FindPlugin::filterChanged);
|
||||||
|
connect(filter, &IFindFilter::displayNameChanged, this, &FindPlugin::displayNameChanged);
|
||||||
}
|
}
|
||||||
d->m_findDialog->setFindFilters(findInterfaces);
|
d->m_findDialog->setFindFilters(findInterfaces);
|
||||||
d->m_openFindDialog->setEnabled(haveEnabledFilters);
|
d->m_openFindDialog->setEnabled(haveEnabledFilters);
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void filterChanged();
|
void filterChanged();
|
||||||
|
void displayNameChanged();
|
||||||
void openFindFilter();
|
void openFindFilter();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
@@ -158,6 +159,15 @@ void FindToolWindow::setFindFilters(const QList<IFindFilter *> &filters)
|
|||||||
setCurrentFilter(0);
|
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)
|
void FindToolWindow::setFindText(const QString &text)
|
||||||
{
|
{
|
||||||
m_ui.searchTerm->setText(text);
|
m_ui.searchTerm->setText(text);
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ public:
|
|||||||
void setCurrentFilter(IFindFilter *filter);
|
void setCurrentFilter(IFindFilter *filter);
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
void updateFindFilterNames();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *event);
|
bool event(QEvent *event);
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public:
|
|||||||
static QString descriptionForFindFlags(FindFlags flags);
|
static QString descriptionForFindFlags(FindFlags flags);
|
||||||
signals:
|
signals:
|
||||||
void enabledChanged(bool enabled);
|
void enabledChanged(bool enabled);
|
||||||
|
void displayNameChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|||||||
@@ -57,6 +57,10 @@ QString CurrentProjectFind::id() const
|
|||||||
|
|
||||||
QString CurrentProjectFind::displayName() const
|
QString CurrentProjectFind::displayName() const
|
||||||
{
|
{
|
||||||
|
Project *p = ProjectTree::currentProject();
|
||||||
|
if (p)
|
||||||
|
return tr("Project \"%1\"").arg(p->displayName());
|
||||||
|
else
|
||||||
return tr("Current Project");
|
return tr("Current Project");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,6 +100,7 @@ QString CurrentProjectFind::label() const
|
|||||||
void CurrentProjectFind::handleProjectChanged()
|
void CurrentProjectFind::handleProjectChanged()
|
||||||
{
|
{
|
||||||
emit enabledChanged(isEnabled());
|
emit enabledChanged(isEnabled());
|
||||||
|
emit displayNameChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurrentProjectFind::recheckEnabled()
|
void CurrentProjectFind::recheckEnabled()
|
||||||
|
|||||||
Reference in New Issue
Block a user