diff --git a/src/plugins/find/searchresultwindow.cpp b/src/plugins/find/searchresultwindow.cpp index 6e44c7c8a944dee86f4b3da5f631e23491a1785b..6fcb8aefa9893d466a1c214046fe3d753eae90f6 100644 --- a/src/plugins/find/searchresultwindow.cpp +++ b/src/plugins/find/searchresultwindow.cpp @@ -38,6 +38,7 @@ #include <QtCore/QDebug> #include <QtGui/QListWidget> #include <QtGui/QToolButton> +#include <QtGui/QLineEdit> using namespace Find; using namespace Find::Internal; @@ -46,6 +47,7 @@ static const QString SETTINGSKEYSECTIONNAME("SearchResults"); static const QString SETTINGSKEYEXPANDRESULTS("ExpandResults"); SearchResultWindow::SearchResultWindow() + : m_isShowingReplaceUI(false) { m_widget = new QStackedWidget; m_widget->setWindowTitle(name()); @@ -66,11 +68,22 @@ SearchResultWindow::SearchResultWindow() m_expandCollapseToolButton->setIcon(QIcon(":/find/images/expand.png")); m_expandCollapseToolButton->setToolTip(tr("Expand All")); + m_replaceLabel = new QLabel(tr("Replace with:"), m_widget); + m_replaceLabel->setContentsMargins(12, 0, 5, 0); + m_replaceTextEdit = new QLineEdit(m_widget); + m_replaceButton = new QToolButton(m_widget); + m_replaceButton->setToolTip(tr("Replace all occurances")); + m_replaceButton->setText(tr("Replace")); + m_replaceButton->setToolButtonStyle(Qt::ToolButtonTextOnly); + m_replaceButton->setAutoRaise(true); + connect(m_searchResultTreeView, SIGNAL(jumpToSearchResult(int,const QString&,int,int,int)), this, SLOT(handleJumpToSearchResult(int,const QString&,int,int,int))); connect(m_expandCollapseToolButton, SIGNAL(toggled(bool)), this, SLOT(handleExpandCollapseToolButton(bool))); + connect(m_replaceButton, SIGNAL(clicked()), this, SLOT(handleReplaceButton())); readSettings(); + setShowReplaceUI(false); } SearchResultWindow::~SearchResultWindow() @@ -82,6 +95,36 @@ SearchResultWindow::~SearchResultWindow() m_items.clear(); } +void SearchResultWindow::setShowReplaceUI(bool show) +{ + m_replaceLabel->setVisible(show); + m_replaceTextEdit->setVisible(show); + m_replaceButton->setVisible(show); +// TODO m_searchResultTreeView->setShowCheckboxes(show); + m_isShowingReplaceUI = show; +} + +bool SearchResultWindow::isShowingReplaceUI() const +{ + return m_isShowingReplaceUI; +} + +void SearchResultWindow::handleReplaceButton() +{ + emit replaceButtonClicked(m_replaceTextEdit->text()); +} + +QList<ResultWindowItem *> SearchResultWindow::selectedItems() const +{ + QList<ResultWindowItem *> items; + // TODO +// foreach (ResultWindowItem *item, m_items) { +// if (item->isSelected) +// items << item; +// } + return items; +} + void SearchResultWindow::visibilityChanged(bool /*visible*/) { } @@ -93,7 +136,7 @@ QWidget *SearchResultWindow::outputWidget(QWidget *) QList<QWidget*> SearchResultWindow::toolBarWidgets() const { - return QList<QWidget*>() << m_expandCollapseToolButton; + return QList<QWidget*>() << m_expandCollapseToolButton << m_replaceLabel << m_replaceTextEdit << m_replaceButton; } void SearchResultWindow::clearContents() diff --git a/src/plugins/find/searchresultwindow.h b/src/plugins/find/searchresultwindow.h index 93df89f376436860abecbfd8108ba6fd073e76f3..1cc6912ef715f434631c5c4d179919aeaf8c7e13 100644 --- a/src/plugins/find/searchresultwindow.h +++ b/src/plugins/find/searchresultwindow.h @@ -40,6 +40,7 @@ #include <QtGui/QStackedWidget> #include <QtGui/QListWidget> #include <QtGui/QToolButton> +#include <QtGui/QLabel> namespace Find { @@ -81,8 +82,15 @@ public: void goToPrev(); bool canNavigate(); + void setShowReplaceUI(bool show); + bool isShowingReplaceUI() const; + QList<ResultWindowItem *> selectedItems() const; + void setTextEditorFont(const QFont &font); +signals: + void replaceButtonClicked(const QString &replaceText); + public slots: void clearContents(); void showNoMatchesFound(); @@ -93,6 +101,7 @@ private slots: void handleExpandCollapseToolButton(bool checked); void handleJumpToSearchResult(int index, const QString &fileName, int lineNumber, int searchTermStart, int searchTermLength); + void handleReplaceButton(); private: void readSettings(); @@ -101,9 +110,13 @@ private: Internal::SearchResultTreeView *m_searchResultTreeView; QListWidget *m_noMatchesFoundDisplay; QToolButton *m_expandCollapseToolButton; + QLabel *m_replaceLabel; + QLineEdit *m_replaceTextEdit; + QToolButton *m_replaceButton; static const bool m_initiallyExpand = false; QStackedWidget *m_widget; QList<ResultWindowItem *> m_items; + bool m_isShowingReplaceUI; }; } // namespace Find