Commit 5990b039 authored by Eike Ziller's avatar Eike Ziller

Show more info about a search and move UI for replacing

Change-Id: I6e024583c0d778a65007eb4590118c4329b2118a
Reviewed-on: http://codereview.qt-project.org/4554Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarLeandro T. C. Melo <leandro.melo@nokia.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent d298cffe
...@@ -228,7 +228,8 @@ static void find_helper(QFutureInterface<Usage> &future, ...@@ -228,7 +228,8 @@ static void find_helper(QFutureInterface<Usage> &future,
void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context) void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context)
{ {
m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(Find::SearchResultWindow::SearchOnly); m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(Find::SearchResultWindow::SearchOnly);
Overview overview;
m_currentSearch->setInfo(tr("C++ Usages:"), QString(), overview(context.fullyQualifiedName(symbol)));
connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)), connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)),
this, SLOT(openEditor(Find::SearchResultItem))); this, SLOT(openEditor(Find::SearchResultItem)));
...@@ -244,6 +245,8 @@ void CppFindReferences::renameUsages(CPlusPlus::Symbol *symbol, const CPlusPlus: ...@@ -244,6 +245,8 @@ void CppFindReferences::renameUsages(CPlusPlus::Symbol *symbol, const CPlusPlus:
m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch( m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(
Find::SearchResultWindow::SearchAndReplace, QLatin1String("CppEditor")); Find::SearchResultWindow::SearchAndReplace, QLatin1String("CppEditor"));
Overview overview;
m_currentSearch->setInfo(tr("C++ Usages:"), QString(), overview(context.fullyQualifiedName(symbol)));
m_currentSearch->setTextToReplace(textToReplace); m_currentSearch->setTextToReplace(textToReplace);
connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)), connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)),
...@@ -415,6 +418,7 @@ static void findMacroUses_helper(QFutureInterface<Usage> &future, ...@@ -415,6 +418,7 @@ static void findMacroUses_helper(QFutureInterface<Usage> &future,
void CppFindReferences::findMacroUses(const Macro &macro) void CppFindReferences::findMacroUses(const Macro &macro)
{ {
m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(Find::SearchResultWindow::SearchOnly); m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(Find::SearchResultWindow::SearchOnly);
m_currentSearch->setInfo(tr("C++ Macro Usages:"), QString(), QString::fromLocal8Bit(macro.name()));
Find::SearchResultWindow::instance()->popup(true); Find::SearchResultWindow::instance()->popup(true);
......
...@@ -33,15 +33,16 @@ ...@@ -33,15 +33,16 @@
#ifndef CPPFINDREFERENCES_H #ifndef CPPFINDREFERENCES_H
#define CPPFINDREFERENCES_H #define CPPFINDREFERENCES_H
#include <utils/filesearch.h>
#include <cplusplus/CppDocument.h>
#include <cplusplus/DependencyTable.h>
#include <cplusplus/FindUsages.h>
#include <QtCore/QMutex> #include <QtCore/QMutex>
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QPointer> #include <QtCore/QPointer>
#include <QtCore/QFuture> #include <QtCore/QFuture>
#include <QtCore/QFutureWatcher> #include <QtCore/QFutureWatcher>
#include <utils/filesearch.h>
#include <cplusplus/CppDocument.h>
#include <cplusplus/DependencyTable.h>
#include <cplusplus/FindUsages.h>
QT_FORWARD_DECLARE_CLASS(QTimer) QT_FORWARD_DECLARE_CLASS(QTimer)
......
...@@ -156,6 +156,7 @@ void SymbolsFindFilter::findAll(const QString &txt, Find::FindFlags findFlags) ...@@ -156,6 +156,7 @@ void SymbolsFindFilter::findAll(const QString &txt, Find::FindFlags findFlags)
emit changed(); emit changed();
Find::SearchResultWindow *window = Find::SearchResultWindow::instance(); Find::SearchResultWindow *window = Find::SearchResultWindow::instance();
m_currentSearch = window->startNewSearch(); m_currentSearch = window->startNewSearch();
m_currentSearch->setInfo(label(), toolTip(findFlags), txt);
connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem))); connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem)));
window->popup(true); window->popup(true);
...@@ -244,6 +245,28 @@ void SymbolsFindFilter::onAllTasksFinished(const QString &type) ...@@ -244,6 +245,28 @@ void SymbolsFindFilter::onAllTasksFinished(const QString &type)
} }
} }
QString SymbolsFindFilter::label() const
{
return tr("C++ Symbols:");
}
QString SymbolsFindFilter::toolTip(Find::FindFlags findFlags) const
{
QStringList types;
if (m_symbolsToSearch & SearchSymbols::Classes)
types.append(tr("Classes"));
if (m_symbolsToSearch & SearchSymbols::Functions)
types.append(tr("Methods"));
if (m_symbolsToSearch & SearchSymbols::Enums)
types.append(tr("Enums"));
if (m_symbolsToSearch & SearchSymbols::Declarations)
types.append(tr("Declarations"));
return tr("Scope: %1\nTypes: %2\nFlags: %3")
.arg(searchScope() == SearchGlobal ? tr("All") : tr("Projects"))
.arg(types.join(tr(", ")))
.arg(Find::IFindFilter::descriptionForFindFlags(findFlags));
}
// #pragma mark -- SymbolsFindFilterConfigWidget // #pragma mark -- SymbolsFindFilterConfigWidget
SymbolsFindFilterConfigWidget::SymbolsFindFilterConfigWidget(SymbolsFindFilter *filter) SymbolsFindFilterConfigWidget::SymbolsFindFilterConfigWidget(SymbolsFindFilter *filter)
......
...@@ -91,6 +91,9 @@ private slots: ...@@ -91,6 +91,9 @@ private slots:
void onAllTasksFinished(const QString &type); void onAllTasksFinished(const QString &type);
private: private:
QString label() const;
QString toolTip(Find::FindFlags findFlags) const;
CppModelManager *m_manager; CppModelManager *m_manager;
bool m_isRunning; bool m_isRunning;
bool m_enabled; bool m_enabled;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "findtoolbar.h" #include "findtoolbar.h"
#include "findplugin.h" #include "findplugin.h"
#include "textfindconstants.h" #include "textfindconstants.h"
#include "ifindfilter.h"
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/icontext.h> #include <coreplugin/icontext.h>
...@@ -79,9 +80,6 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen ...@@ -79,9 +80,6 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_replaceAction(0), m_replaceAction(0),
m_replaceNextAction(0), m_replaceNextAction(0),
m_replacePreviousAction(0), m_replacePreviousAction(0),
m_casesensitiveIcon(":/find/images/casesensitively.png"),
m_regexpIcon(":/find/images/regexp.png"),
m_wholewordsIcon(":/find/images/wholewords.png"),
m_findIncrementalTimer(this), m_findStepTimer(this), m_findIncrementalTimer(this), m_findStepTimer(this),
m_useFakeVim(false), m_useFakeVim(false),
m_eventFiltersInstalled(false) m_eventFiltersInstalled(false)
...@@ -539,33 +537,17 @@ void FindToolBar::updateIcons() ...@@ -539,33 +537,17 @@ void FindToolBar::updateIcons()
bool casesensitive = effectiveFlags & Find::FindCaseSensitively; bool casesensitive = effectiveFlags & Find::FindCaseSensitively;
bool wholewords = effectiveFlags & Find::FindWholeWords; bool wholewords = effectiveFlags & Find::FindWholeWords;
bool regexp = effectiveFlags & Find::FindRegularExpression; bool regexp = effectiveFlags & Find::FindRegularExpression;
int width = 0;
if (casesensitive) width += 6;
if (wholewords) width += 6;
if (regexp) width += 6;
if (width == 0) width = 18;
--width;
QPixmap pixmap(width, 17);
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
int x = 0;
if (casesensitive) {
painter.drawPixmap(x - 6, 0, m_casesensitiveIcon);
x += 6;
}
if (wholewords) {
painter.drawPixmap(x - 6, 0, m_wholewordsIcon);
x += 6;
}
if (regexp) {
painter.drawPixmap(x - 6, 0, m_regexpIcon);
}
if (!casesensitive && !wholewords && !regexp) { if (!casesensitive && !wholewords && !regexp) {
QPixmap pixmap(17, 17);
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
QPixmap mag(Core::Constants::ICON_MAGNIFIER); QPixmap mag(Core::Constants::ICON_MAGNIFIER);
painter.drawPixmap(0, (pixmap.height() - mag.height()) / 2, mag); painter.drawPixmap(0, (pixmap.height() - mag.height()) / 2, mag);
m_ui.findEdit->setButtonPixmap(Utils::FancyLineEdit::Left, pixmap);
} else {
m_ui.findEdit->setButtonPixmap(Utils::FancyLineEdit::Left,
IFindFilter::pixmapForFindFlags(effectiveFlags));
} }
m_ui.findEdit->setButtonPixmap(Utils::FancyLineEdit::Left, pixmap);
} }
Find::FindFlags FindToolBar::effectiveFindFlags() Find::FindFlags FindToolBar::effectiveFindFlags()
......
...@@ -133,10 +133,6 @@ private: ...@@ -133,10 +133,6 @@ private:
QAction *m_regularExpressionAction; QAction *m_regularExpressionAction;
Find::FindFlags m_findFlags; Find::FindFlags m_findFlags;
QPixmap m_casesensitiveIcon;
QPixmap m_regexpIcon;
QPixmap m_wholewordsIcon;
QTimer m_findIncrementalTimer; QTimer m_findIncrementalTimer;
QTimer m_findStepTimer; QTimer m_findStepTimer;
bool m_useFakeVim; bool m_useFakeVim;
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#include "ifindfilter.h" #include "ifindfilter.h"
#include <QtGui/QPainter>
/*! /*!
\class Find::IFindFilter \class Find::IFindFilter
\brief The IFindFilter class is the base class for find implementations \brief The IFindFilter class is the base class for find implementations
...@@ -220,3 +222,52 @@ Find::FindFlags Find::IFindFilter::supportedFindFlags() const ...@@ -220,3 +222,52 @@ Find::FindFlags Find::IFindFilter::supportedFindFlags() const
return Find::FindCaseSensitively return Find::FindCaseSensitively
| Find::FindRegularExpression | Find::FindWholeWords; | Find::FindRegularExpression | Find::FindWholeWords;
} }
QPixmap Find::IFindFilter::pixmapForFindFlags(Find::FindFlags flags)
{
static const QPixmap casesensitiveIcon(":/find/images/casesensitively.png");
static const QPixmap regexpIcon(":/find/images/regexp.png");
static const QPixmap wholewordsIcon(":/find/images/wholewords.png");
bool casesensitive = flags & Find::FindCaseSensitively;
bool wholewords = flags & Find::FindWholeWords;
bool regexp = flags & Find::FindRegularExpression;
int width = 0;
if (casesensitive) width += 6;
if (wholewords) width += 6;
if (regexp) width += 6;
if (width > 0) --width;
QPixmap pixmap(width, 17);
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
int x = 0;
if (casesensitive) {
painter.drawPixmap(x - 6, 0, casesensitiveIcon);
x += 6;
}
if (wholewords) {
painter.drawPixmap(x - 6, 0, wholewordsIcon);
x += 6;
}
if (regexp) {
painter.drawPixmap(x - 6, 0, regexpIcon);
}
return pixmap;
}
QString Find::IFindFilter::descriptionForFindFlags(Find::FindFlags flags)
{
QStringList flagStrings;
if (flags & Find::FindCaseSensitively)
flagStrings.append(tr("Case sensitive"));
if (flags & Find::FindWholeWords)
flagStrings.append(tr("Whole words"));
if (flags & Find::FindRegularExpression)
flagStrings.append(tr("Regular expressions"));
QString description = tr("Flags: %1");
if (flagStrings.isEmpty())
description = description.arg(tr("None"));
else
description = description.arg(flagStrings.join(tr(", ")));
return description;
}
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include "find_global.h" #include "find_global.h"
#include "textfindconstants.h" #include "textfindconstants.h"
#include <QtGui/QPixmap>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QWidget; class QWidget;
class QSettings; class QSettings;
...@@ -69,6 +71,8 @@ public: ...@@ -69,6 +71,8 @@ public:
virtual void writeSettings(QSettings *settings) { Q_UNUSED(settings) } virtual void writeSettings(QSettings *settings) { Q_UNUSED(settings) }
virtual void readSettings(QSettings *settings) { Q_UNUSED(settings) } virtual void readSettings(QSettings *settings) { Q_UNUSED(settings) }
static QPixmap pixmapForFindFlags(FindFlags flags);
static QString descriptionForFindFlags(FindFlags flags);
signals: signals:
void changed(); void changed();
}; };
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <QtGui/QVBoxLayout> #include <QtGui/QVBoxLayout>
#include <QtGui/QHBoxLayout>
namespace Find { namespace Find {
namespace Internal { namespace Internal {
...@@ -214,10 +215,17 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) : ...@@ -214,10 +215,17 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
layout->setSpacing(0); layout->setSpacing(0);
setLayout(layout); setLayout(layout);
m_noMatchesFoundDisplay = new QListWidget(this); QFrame *topWidget = new QFrame;
m_noMatchesFoundDisplay->addItem(tr("No matches found!")); QPalette pal = topWidget->palette();
m_noMatchesFoundDisplay->setFrameStyle(QFrame::NoFrame); pal.setColor(QPalette::Window, QColor(255, 255, 225));
m_noMatchesFoundDisplay->hide(); pal.setColor(QPalette::WindowText, Qt::black);
topWidget->setPalette(pal);
topWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);
topWidget->setLineWidth(1);
topWidget->setAutoFillBackground(true);
QHBoxLayout *topLayout = new QHBoxLayout(topWidget);
topLayout->setMargin(2);
topWidget->setLayout(topLayout);
m_searchResultTreeView = new Internal::SearchResultTreeView(this); m_searchResultTreeView = new Internal::SearchResultTreeView(this);
m_searchResultTreeView->setFrameStyle(QFrame::NoFrame); m_searchResultTreeView->setFrameStyle(QFrame::NoFrame);
...@@ -226,21 +234,41 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) : ...@@ -226,21 +234,41 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
agg->add(m_searchResultTreeView); agg->add(m_searchResultTreeView);
agg->add(new SearchResultFindSupport(m_searchResultTreeView)); agg->add(new SearchResultFindSupport(m_searchResultTreeView));
layout->addWidget(m_noMatchesFoundDisplay); layout->addWidget(topWidget);
layout->addWidget(m_searchResultTreeView); layout->addWidget(m_searchResultTreeView);
m_infoBarDisplay.setTarget(layout, 0); m_infoBarDisplay.setTarget(layout, 1);
m_infoBarDisplay.setInfoBar(&m_infoBar); m_infoBarDisplay.setInfoBar(&m_infoBar);
m_replaceLabel = new QLabel(tr("Replace with:"), parent); m_descriptionContainer = new QWidget(topWidget);
m_replaceLabel->setContentsMargins(12, 0, 5, 0); QHBoxLayout *descriptionLayout = new QHBoxLayout(m_descriptionContainer);
m_replaceTextEdit = new WideEnoughLineEdit(parent); m_descriptionContainer->setLayout(descriptionLayout);
m_replaceButton = new QToolButton(parent); descriptionLayout->setMargin(0);
m_label = new QLabel(m_descriptionContainer);
m_label->setVisible(false);
m_searchTerm = new QLabel(m_descriptionContainer);
m_searchTerm->setVisible(false);
descriptionLayout->addWidget(m_label);
descriptionLayout->addWidget(m_searchTerm);
m_replaceLabel = new QLabel(tr("Replace with:"), topWidget);
m_replaceTextEdit = new WideEnoughLineEdit(topWidget);
m_replaceButton = new QToolButton(topWidget);
m_replaceButton->setToolTip(tr("Replace all occurrences")); m_replaceButton->setToolTip(tr("Replace all occurrences"));
m_replaceButton->setText(tr("Replace")); m_replaceButton->setText(tr("Replace"));
m_replaceButton->setToolButtonStyle(Qt::ToolButtonTextOnly); m_replaceButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
m_replaceButton->setAutoRaise(true); m_replaceButton->setAutoRaise(true);
m_replaceTextEdit->setTabOrder(m_replaceTextEdit, m_searchResultTreeView); m_replaceTextEdit->setTabOrder(m_replaceTextEdit, m_searchResultTreeView);
m_matchesFoundLabel = new QLabel(topWidget);
updateMatchesFoundLabel();
topLayout->addWidget(m_descriptionContainer);
topLayout->addWidget(m_replaceLabel);
topLayout->addWidget(m_replaceTextEdit);
topLayout->addWidget(m_replaceButton);
topLayout->addStretch(2);
topLayout->addWidget(m_matchesFoundLabel);
setShowReplaceUI(false); setShowReplaceUI(false);
connect(m_searchResultTreeView, SIGNAL(jumpToSearchResult(SearchResultItem)), connect(m_searchResultTreeView, SIGNAL(jumpToSearchResult(SearchResultItem)),
...@@ -249,6 +277,15 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) : ...@@ -249,6 +277,15 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
connect(m_replaceButton, SIGNAL(clicked()), this, SLOT(handleReplaceButton())); connect(m_replaceButton, SIGNAL(clicked()), this, SLOT(handleReplaceButton()));
} }
void SearchResultWidget::setInfo(const QString &label, const QString &toolTip, const QString &term)
{
m_label->setText(label);
m_label->setVisible(!label.isEmpty());
m_descriptionContainer->setToolTip(toolTip);
m_searchTerm->setText(term);
m_searchTerm->setVisible(!term.isEmpty());
}
void SearchResultWidget::addResult(const QString &fileName, int lineNumber, const QString &rowText, void SearchResultWidget::addResult(const QString &fileName, int lineNumber, const QString &rowText,
int searchTermStart, int searchTermLength, const QVariant &userData) int searchTermStart, int searchTermLength, const QVariant &userData)
{ {
...@@ -286,6 +323,7 @@ void SearchResultWidget::addResults(const QList<SearchResultItem> &items, Search ...@@ -286,6 +323,7 @@ void SearchResultWidget::addResults(const QList<SearchResultItem> &items, Search
m_searchResultTreeView->selectionModel()->select(m_searchResultTreeView->model()->index(0, 0, QModelIndex()), QItemSelectionModel::Select); m_searchResultTreeView->selectionModel()->select(m_searchResultTreeView->model()->index(0, 0, QModelIndex()), QItemSelectionModel::Select);
emit navigateStateChanged(); emit navigateStateChanged();
} }
updateMatchesFoundLabel();
} }
int SearchResultWidget::count() const int SearchResultWidget::count() const
...@@ -398,11 +436,8 @@ void SearchResultWidget::goToPrevious() ...@@ -398,11 +436,8 @@ void SearchResultWidget::goToPrevious()
void SearchResultWidget::finishSearch() void SearchResultWidget::finishSearch()
{ {
if (m_count > 0) { m_replaceTextEdit->setEnabled(m_count > 0);
m_replaceButton->setEnabled(true); m_replaceButton->setEnabled(m_count > 0);
} else {
showNoMatchesFound();
}
} }
void SearchResultWidget::clear() void SearchResultWidget::clear()
...@@ -412,17 +447,12 @@ void SearchResultWidget::clear() ...@@ -412,17 +447,12 @@ void SearchResultWidget::clear()
m_replaceTextEdit->clear(); m_replaceTextEdit->clear();
m_searchResultTreeView->clear(); m_searchResultTreeView->clear();
m_count = 0; m_count = 0;
m_noMatchesFoundDisplay->hide(); m_label->setVisible(false);
m_searchTerm->setVisible(false);
updateMatchesFoundLabel();
m_infoBar.clear(); m_infoBar.clear();
} }
void SearchResultWidget::showNoMatchesFound()
{
m_replaceTextEdit->setEnabled(false);
m_replaceButton->setEnabled(false);
m_noMatchesFoundDisplay->show();
}
void SearchResultWidget::hideNoUndoWarning() void SearchResultWidget::hideNoUndoWarning()
{ {
setShowWarningMessage(false); setShowWarningMessage(false);
...@@ -486,4 +516,12 @@ QList<SearchResultItem> SearchResultWidget::checkedItems() const ...@@ -486,4 +516,12 @@ QList<SearchResultItem> SearchResultWidget::checkedItems() const
return result; return result;
} }
void SearchResultWidget::updateMatchesFoundLabel()
{
if (m_count == 0)
m_matchesFoundLabel->setText(tr("No matches found."));
else
m_matchesFoundLabel->setText(tr("%n matches found.", 0, m_count));
}
#include "searchresultwidget.moc" #include "searchresultwidget.moc"
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#include <QtGui/QLabel> #include <QtGui/QLabel>
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
#include <QtGui/QListWidget>
#include <QtGui/QToolButton> #include <QtGui/QToolButton>
#include <QtGui/QWidget> #include <QtGui/QWidget>
...@@ -54,6 +53,8 @@ class SearchResultWidget : public QWidget ...@@ -54,6 +53,8 @@ class SearchResultWidget : public QWidget
public: public:
explicit SearchResultWidget(QWidget *parent = 0); explicit SearchResultWidget(QWidget *parent = 0);
void setInfo(const QString &label, const QString &toolTip, const QString &term);
void addResult(const QString &fileName, int lineNumber, const QString &lineText, void addResult(const QString &fileName, int lineNumber, const QString &lineText,
int searchTermStart, int searchTermLength, const QVariant &userData = QVariant()); int searchTermStart, int searchTermLength, const QVariant &userData = QVariant());
void addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode); void addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode);
...@@ -82,13 +83,9 @@ public: ...@@ -82,13 +83,9 @@ public:
void goToNext(); void goToNext();
void goToPrevious(); void goToPrevious();
// TODO: temporary
QList<QWidget*> toolBarWidgets() const { return QList<QWidget*>() << m_replaceLabel << m_replaceTextEdit << m_replaceButton; }
public slots: public slots:
void finishSearch(); void finishSearch();
void clear(); void clear();
void showNoMatchesFound();
signals: signals:
void activated(const Find::SearchResultItem &item); void activated(const Find::SearchResultItem &item);
...@@ -106,17 +103,21 @@ private: ...@@ -106,17 +103,21 @@ private:
bool showWarningMessage() const; bool showWarningMessage() const;
void setShowWarningMessage(bool showWarningMessage); void setShowWarningMessage(bool showWarningMessage);
QList<SearchResultItem> checkedItems() const; QList<SearchResultItem> checkedItems() const;
void updateMatchesFoundLabel();
SearchResultTreeView *m_searchResultTreeView; SearchResultTreeView *m_searchResultTreeView;
int m_count; int m_count;
QString m_dontAskAgainGroup; QString m_dontAskAgainGroup;
Core::InfoBar m_infoBar; Core::InfoBar m_infoBar;
Core::InfoBarDisplay m_infoBarDisplay; Core::InfoBarDisplay m_infoBarDisplay;
QListWidget *m_noMatchesFoundDisplay;
bool m_isShowingReplaceUI; bool m_isShowingReplaceUI;
QLabel *m_replaceLabel; QLabel *m_replaceLabel;
QLineEdit *m_replaceTextEdit; QLineEdit *m_replaceTextEdit;
QToolButton *m_replaceButton; QToolButton *m_replaceButton;
QWidget *m_descriptionContainer;
QLabel *m_label;
QLabel *m_searchTerm;
QLabel *m_matchesFoundLabel;
}; };
} // Internal } // Internal
......
...@@ -230,7 +230,7 @@ QWidget *SearchResultWindow::outputWidget(QWidget *) ...@@ -230,7 +230,7 @@ QWidget *SearchResultWindow::outputWidget(QWidget *)
*/ */
QList<QWidget*> SearchResultWindow::toolBarWidgets() const QList<QWidget*> SearchResultWindow::toolBarWidgets() const
{ {
return QList<QWidget*>() << d->m_expandCollapseButton << d->m_searchResultWidget->toolBarWidgets(); return QList<QWidget*>() << d->m_expandCollapseButton;
} }
/*! /*!
...@@ -445,6 +445,23 @@ QString SearchResult::textToReplace() const ...@@ -445,6 +445,23 @@ QString SearchResult::textToReplace() const
return m_widget->textToReplace(); return m_widget->textToReplace();
} }
/*!
\fn void SearchResult::setInfo(const QString &label, const QString &toolTip, const QString &term)
\brief Set the information about the search that is show in the top-left corner of
the search result window.
The \a label should be a string that shortly describes the
search, i.e. search filter and a most relevant search options, followed by a colon ':'.
E.g. \code{Project 'myproject':}
The search \a term will be shown behind the colon.
The \a toolTip should elaborate on the search parameters, like file patterns that are searched and
find flags.
*/
void SearchResult::setInfo(const QString &label, const QString &toolTip, const QString &term)
{
m_widget->setInfo(label, toolTip, term);
}
/*! /*!
\fn void SearchResult::addResult(const QString &fileName, int lineNumber, const QString &rowText, int searchTermStart, int searchTermLength, const QVariant &userData) \fn void SearchResult::addResult(const QString &fileName, int lineNumber, const QString &rowText, int searchTermStart, int searchTermLength, const QVariant &userData)
\brief Adds a single result line to the search results. \brief Adds a single result line to the search results.
......
...@@ -98,6 +98,7 @@ public: ...@@ -98,6 +98,7 @@ public:
void setUserData(const QVariant &data); void setUserData(const QVariant &data);
QVariant userData() const; QVariant userData() const;
QString textToReplace() const; QString textToReplace() const;
void setInfo(const QString &label, const QString &toolTip, const QString &term);
public slots: public slots:
void addResult(const QString &fileName, int lineNumber, const QString &lineText, void addResult(const QString &fileName, int lineNumber, const QString &lineText,
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <QtGui/QGridLayout> #include <QtGui/QGridLayout>
#include <QtGui/QLabel> #include <QtGui/QLabel>
#include <QtGui/QHBoxLayout>