2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "searchresultwindow.h"
|
|
|
|
|
#include "searchresulttreemodel.h"
|
2009-10-05 16:01:50 +02:00
|
|
|
#include "searchresulttreeitems.h"
|
2010-03-24 10:43:01 +01:00
|
|
|
#include "searchresulttreeview.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-21 18:09:37 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2009-10-05 16:01:50 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2009-01-21 18:09:37 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QFile>
|
|
|
|
|
#include <QtCore/QTextStream>
|
|
|
|
|
#include <QtCore/QSettings>
|
2009-04-30 12:50:52 +02:00
|
|
|
#include <QtCore/QDebug>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtGui/QListWidget>
|
|
|
|
|
#include <QtGui/QToolButton>
|
2009-09-29 16:40:52 +02:00
|
|
|
#include <QtGui/QLineEdit>
|
2009-10-01 16:38:08 +02:00
|
|
|
#include <QtGui/QStackedWidget>
|
|
|
|
|
#include <QtGui/QLabel>
|
2010-03-24 10:43:01 +01:00
|
|
|
#include <QtGui/QFont>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-24 10:43:01 +01:00
|
|
|
static const char SETTINGSKEYSECTIONNAME[] = "SearchResults";
|
|
|
|
|
static const char SETTINGSKEYEXPANDRESULTS[] = "ExpandResults";
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
|
2010-03-24 10:43:01 +01:00
|
|
|
namespace Find {
|
2009-09-29 16:59:19 +02:00
|
|
|
|
2010-05-21 13:47:02 +02:00
|
|
|
class WideEnoughLineEdit : public QLineEdit {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
WideEnoughLineEdit(QWidget *parent):QLineEdit(parent){
|
|
|
|
|
connect(this, SIGNAL(textChanged(QString)),
|
|
|
|
|
this, SLOT(updateGeometry()));
|
|
|
|
|
}
|
|
|
|
|
~WideEnoughLineEdit(){}
|
|
|
|
|
QSize sizeHint() const {
|
|
|
|
|
QSize sh = QLineEdit::minimumSizeHint();
|
|
|
|
|
sh.rwidth() += qMax(25 * fontMetrics().width(QLatin1Char('x')),
|
|
|
|
|
fontMetrics().width(text()));
|
|
|
|
|
return sh;
|
|
|
|
|
}
|
|
|
|
|
public slots:
|
|
|
|
|
void updateGeometry() { QLineEdit::updateGeometry(); }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2010-03-24 10:43:01 +01:00
|
|
|
struct SearchResultWindowPrivate {
|
|
|
|
|
SearchResultWindowPrivate();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-24 10:43:01 +01:00
|
|
|
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;
|
|
|
|
|
SearchResult *m_currentSearch;
|
|
|
|
|
QList<SearchResultItem> m_items;
|
|
|
|
|
bool m_isShowingReplaceUI;
|
|
|
|
|
bool m_focusReplaceEdit;
|
|
|
|
|
};
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-24 10:43:01 +01:00
|
|
|
SearchResultWindowPrivate::SearchResultWindowPrivate()
|
|
|
|
|
: m_currentSearch(0), m_isShowingReplaceUI(false), m_focusReplaceEdit(false)
|
|
|
|
|
{
|
|
|
|
|
}
|
2009-09-29 16:40:52 +02:00
|
|
|
|
2010-03-24 10:43:01 +01:00
|
|
|
SearchResultWindow::SearchResultWindow() : d(new SearchResultWindowPrivate)
|
|
|
|
|
{
|
|
|
|
|
d->m_widget = new QStackedWidget;
|
2010-06-16 11:56:30 +02:00
|
|
|
d->m_widget->setWindowTitle(displayName());
|
2010-03-24 10:43:01 +01:00
|
|
|
|
|
|
|
|
d->m_searchResultTreeView = new Internal::SearchResultTreeView(d->m_widget);
|
|
|
|
|
d->m_searchResultTreeView->setFrameStyle(QFrame::NoFrame);
|
|
|
|
|
d->m_searchResultTreeView->setAttribute(Qt::WA_MacShowFocusRect, false);
|
|
|
|
|
d->m_widget->addWidget(d->m_searchResultTreeView);
|
|
|
|
|
|
|
|
|
|
d->m_noMatchesFoundDisplay = new QListWidget(d->m_widget);
|
|
|
|
|
d->m_noMatchesFoundDisplay->addItem(tr("No matches found!"));
|
|
|
|
|
d->m_noMatchesFoundDisplay->setFrameStyle(QFrame::NoFrame);
|
|
|
|
|
d->m_widget->addWidget(d->m_noMatchesFoundDisplay);
|
|
|
|
|
|
|
|
|
|
d->m_expandCollapseToolButton = new QToolButton(d->m_widget);
|
|
|
|
|
d->m_expandCollapseToolButton->setAutoRaise(true);
|
|
|
|
|
d->m_expandCollapseToolButton->setCheckable(true);
|
|
|
|
|
d->m_expandCollapseToolButton->setIcon(QIcon(":/find/images/expand.png"));
|
|
|
|
|
d->m_expandCollapseToolButton->setToolTip(tr("Expand All"));
|
|
|
|
|
|
|
|
|
|
d->m_replaceLabel = new QLabel(tr("Replace with:"), d->m_widget);
|
|
|
|
|
d->m_replaceLabel->setContentsMargins(12, 0, 5, 0);
|
2010-05-21 13:47:02 +02:00
|
|
|
d->m_replaceTextEdit = new WideEnoughLineEdit(d->m_widget);
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_replaceButton = new QToolButton(d->m_widget);
|
|
|
|
|
d->m_replaceButton->setToolTip(tr("Replace all occurrences"));
|
|
|
|
|
d->m_replaceButton->setText(tr("Replace"));
|
|
|
|
|
d->m_replaceButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
|
|
|
|
|
d->m_replaceButton->setAutoRaise(true);
|
|
|
|
|
d->m_replaceTextEdit->setTabOrder(d->m_replaceTextEdit, d->m_searchResultTreeView);
|
|
|
|
|
|
|
|
|
|
connect(d->m_searchResultTreeView, SIGNAL(jumpToSearchResult(int,bool)),
|
2009-10-05 16:01:50 +02:00
|
|
|
this, SLOT(handleJumpToSearchResult(int,bool)));
|
2010-03-24 10:43:01 +01:00
|
|
|
connect(d->m_expandCollapseToolButton, SIGNAL(toggled(bool)), this, SLOT(handleExpandCollapseToolButton(bool)));
|
|
|
|
|
connect(d->m_replaceTextEdit, SIGNAL(returnPressed()), this, SLOT(handleReplaceButton()));
|
|
|
|
|
connect(d->m_replaceButton, SIGNAL(clicked()), this, SLOT(handleReplaceButton()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
readSettings();
|
2009-09-29 16:40:52 +02:00
|
|
|
setShowReplaceUI(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SearchResultWindow::~SearchResultWindow()
|
|
|
|
|
{
|
|
|
|
|
writeSettings();
|
2010-03-24 10:43:01 +01:00
|
|
|
delete d->m_currentSearch;
|
|
|
|
|
d->m_currentSearch = 0;
|
|
|
|
|
delete d->m_widget;
|
|
|
|
|
d->m_widget = 0;
|
|
|
|
|
d->m_items.clear();
|
|
|
|
|
delete d;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-06 16:00:32 +02:00
|
|
|
void SearchResultWindow::setTextToReplace(const QString &textToReplace)
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_replaceTextEdit->setText(textToReplace);
|
2009-10-06 16:00:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString SearchResultWindow::textToReplace() const
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
return d->m_replaceTextEdit->text();
|
2009-10-06 16:00:32 +02:00
|
|
|
}
|
|
|
|
|
|
2009-09-29 16:40:52 +02:00
|
|
|
void SearchResultWindow::setShowReplaceUI(bool show)
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_searchResultTreeView->model()->setShowReplaceUI(show);
|
|
|
|
|
d->m_replaceLabel->setVisible(show);
|
|
|
|
|
d->m_replaceTextEdit->setVisible(show);
|
|
|
|
|
d->m_replaceButton->setVisible(show);
|
|
|
|
|
d->m_isShowingReplaceUI = show;
|
2009-09-29 16:40:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SearchResultWindow::handleReplaceButton()
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
QTC_ASSERT(d->m_currentSearch, return);
|
2009-11-04 18:10:03 +01:00
|
|
|
// check if button is actually enabled, because this is also triggered
|
|
|
|
|
// by pressing return in replace line edit
|
2010-03-24 10:43:01 +01:00
|
|
|
if (d->m_replaceButton->isEnabled())
|
|
|
|
|
d->m_currentSearch->replaceButtonClicked(d->m_replaceTextEdit->text(), checkedItems());
|
2009-09-29 16:40:52 +02:00
|
|
|
}
|
|
|
|
|
|
2009-10-05 16:01:50 +02:00
|
|
|
QList<SearchResultItem> SearchResultWindow::checkedItems() const
|
2009-09-29 16:40:52 +02:00
|
|
|
{
|
2009-10-05 16:01:50 +02:00
|
|
|
QList<SearchResultItem> result;
|
2010-03-24 10:43:01 +01:00
|
|
|
Internal::SearchResultTreeModel *model = d->m_searchResultTreeView->model();
|
2009-10-05 16:01:50 +02:00
|
|
|
const int fileCount = model->rowCount(QModelIndex());
|
|
|
|
|
for (int i = 0; i < fileCount; ++i) {
|
|
|
|
|
QModelIndex fileIndex = model->index(i, 0, QModelIndex());
|
2010-03-24 10:43:01 +01:00
|
|
|
Internal::SearchResultFile *fileItem = static_cast<Internal::SearchResultFile *>(fileIndex.internalPointer());
|
2009-10-05 16:01:50 +02:00
|
|
|
Q_ASSERT(fileItem != 0);
|
|
|
|
|
for (int rowIndex = 0; rowIndex < fileItem->childrenCount(); ++rowIndex) {
|
|
|
|
|
QModelIndex textIndex = model->index(rowIndex, 0, fileIndex);
|
2010-03-24 10:43:01 +01:00
|
|
|
Internal::SearchResultTextRow *rowItem = static_cast<Internal::SearchResultTextRow *>(textIndex.internalPointer());
|
2009-10-05 16:01:50 +02:00
|
|
|
if (rowItem->checkState())
|
2010-03-24 10:43:01 +01:00
|
|
|
result << d->m_items.at(rowItem->index());
|
2009-10-05 16:01:50 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
2009-09-29 16:40:52 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void SearchResultWindow::visibilityChanged(bool /*visible*/)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *SearchResultWindow::outputWidget(QWidget *)
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
return d->m_widget;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-04-07 16:59:48 +02:00
|
|
|
QList<QWidget*> SearchResultWindow::toolBarWidgets() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
return QList<QWidget*>() << d->m_expandCollapseToolButton << d->m_replaceLabel << d->m_replaceTextEdit << d->m_replaceButton;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-05 16:01:50 +02:00
|
|
|
SearchResult *SearchResultWindow::startNewSearch(SearchMode searchOrSearchAndReplace)
|
|
|
|
|
{
|
|
|
|
|
clearContents();
|
|
|
|
|
setShowReplaceUI(searchOrSearchAndReplace != SearchOnly);
|
2010-03-24 10:43:01 +01:00
|
|
|
delete d->m_currentSearch;
|
|
|
|
|
d->m_currentSearch = new SearchResult;
|
|
|
|
|
return d->m_currentSearch;
|
2009-10-05 16:01:50 +02:00
|
|
|
}
|
|
|
|
|
|
2009-11-04 18:10:03 +01:00
|
|
|
void SearchResultWindow::finishSearch()
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
if (d->m_items.count()) {
|
|
|
|
|
d->m_replaceButton->setEnabled(true);
|
2009-11-04 18:10:03 +01:00
|
|
|
} else {
|
|
|
|
|
showNoMatchesFound();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void SearchResultWindow::clearContents()
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_replaceTextEdit->setEnabled(false);
|
|
|
|
|
d->m_replaceButton->setEnabled(false);
|
|
|
|
|
d->m_replaceTextEdit->clear();
|
|
|
|
|
d->m_searchResultTreeView->clear();
|
|
|
|
|
d->m_items.clear();
|
|
|
|
|
d->m_widget->setCurrentWidget(d->m_searchResultTreeView);
|
2009-04-30 12:50:52 +02:00
|
|
|
navigateStateChanged();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-04-07 16:59:48 +02:00
|
|
|
void SearchResultWindow::showNoMatchesFound()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_replaceTextEdit->setEnabled(false);
|
|
|
|
|
d->m_replaceButton->setEnabled(false);
|
|
|
|
|
d->m_widget->setCurrentWidget(d->m_noMatchesFoundDisplay);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SearchResultWindow::isEmpty() const
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
return (d->m_searchResultTreeView->model()->rowCount() < 1);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SearchResultWindow::numberOfResults() const
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
return d->m_items.count();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-04-08 14:32:31 +02:00
|
|
|
bool SearchResultWindow::hasFocus()
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
return d->m_searchResultTreeView->hasFocus() || (d->m_isShowingReplaceUI && d->m_replaceTextEdit->hasFocus());
|
2009-04-08 14:32:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SearchResultWindow::canFocus()
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
return !d->m_items.isEmpty();
|
2009-04-08 14:32:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SearchResultWindow::setFocus()
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
if (!d->m_items.isEmpty()) {
|
|
|
|
|
if (!d->m_isShowingReplaceUI) {
|
|
|
|
|
d->m_searchResultTreeView->setFocus();
|
2009-09-29 17:33:34 +02:00
|
|
|
} else {
|
2010-03-24 10:43:01 +01:00
|
|
|
if (!d->m_widget->focusWidget()
|
|
|
|
|
|| d->m_widget->focusWidget() == d->m_replaceTextEdit
|
|
|
|
|
|| d->m_focusReplaceEdit) {
|
|
|
|
|
d->m_replaceTextEdit->setFocus();
|
|
|
|
|
d->m_replaceTextEdit->selectAll();
|
2009-09-29 17:33:34 +02:00
|
|
|
} else {
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_searchResultTreeView->setFocus();
|
2009-09-29 17:33:34 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-04-08 14:32:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SearchResultWindow::setTextEditorFont(const QFont &font)
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_searchResultTreeView->setTextEditorFont(font);
|
2009-04-08 14:32:31 +02:00
|
|
|
}
|
|
|
|
|
|
2009-10-12 12:33:12 +02:00
|
|
|
void SearchResultWindow::handleJumpToSearchResult(int index, bool /* checked */)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
QTC_ASSERT(d->m_currentSearch, return);
|
|
|
|
|
d->m_currentSearch->activated(d->m_items.at(index));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-05 16:01:50 +02:00
|
|
|
void SearchResultWindow::addResult(const QString &fileName, int lineNumber, const QString &rowText,
|
|
|
|
|
int searchTermStart, int searchTermLength, const QVariant &userData)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-07-24 15:47:22 +02:00
|
|
|
//qDebug()<<"###"<<fileName;
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_widget->setCurrentWidget(d->m_searchResultTreeView);
|
|
|
|
|
int index = d->m_items.size();
|
2009-10-05 16:01:50 +02:00
|
|
|
SearchResultItem item;
|
|
|
|
|
item.fileName = fileName;
|
|
|
|
|
item.lineNumber = lineNumber;
|
|
|
|
|
item.lineText = rowText;
|
|
|
|
|
item.searchTermStart = searchTermStart;
|
|
|
|
|
item.searchTermLength = searchTermLength;
|
|
|
|
|
item.userData = userData;
|
|
|
|
|
item.index = index;
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_items.append(item);
|
|
|
|
|
d->m_searchResultTreeView->appendResultLine(index, fileName, lineNumber, rowText, searchTermStart, searchTermLength);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (index == 0) {
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_replaceTextEdit->setEnabled(true);
|
2009-11-04 18:10:03 +01:00
|
|
|
// We didn't have an item before, set the focus to the search widget
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_focusReplaceEdit = true;
|
2009-09-29 17:33:34 +02:00
|
|
|
setFocus();
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_focusReplaceEdit = false;
|
|
|
|
|
d->m_searchResultTreeView->selectionModel()->select(d->m_searchResultTreeView->model()->index(0, 0, QModelIndex()), QItemSelectionModel::Select);
|
2009-04-30 12:50:52 +02:00
|
|
|
emit navigateStateChanged();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-10-05 16:01:50 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void SearchResultWindow::handleExpandCollapseToolButton(bool checked)
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_searchResultTreeView->setAutoExpandResults(checked);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (checked)
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_searchResultTreeView->expandAll();
|
2008-12-02 12:01:29 +01:00
|
|
|
else
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_searchResultTreeView->collapseAll();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-04-07 16:59:48 +02:00
|
|
|
void SearchResultWindow::readSettings()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-21 18:09:37 +01:00
|
|
|
QSettings *s = Core::ICore::instance()->settings();
|
|
|
|
|
if (s) {
|
2010-03-24 10:43:01 +01:00
|
|
|
s->beginGroup(QLatin1String(SETTINGSKEYSECTIONNAME));
|
|
|
|
|
d->m_expandCollapseToolButton->setChecked(s->value(QLatin1String(SETTINGSKEYEXPANDRESULTS), d->m_initiallyExpand).toBool());
|
2008-12-02 12:01:29 +01:00
|
|
|
s->endGroup();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-07 16:59:48 +02:00
|
|
|
void SearchResultWindow::writeSettings()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-21 18:09:37 +01:00
|
|
|
QSettings *s = Core::ICore::instance()->settings();
|
|
|
|
|
if (s) {
|
2010-03-24 10:43:01 +01:00
|
|
|
s->beginGroup(QLatin1String(SETTINGSKEYSECTIONNAME));
|
|
|
|
|
s->setValue(QLatin1String(SETTINGSKEYEXPANDRESULTS), d->m_expandCollapseToolButton->isChecked());
|
2008-12-02 12:01:29 +01:00
|
|
|
s->endGroup();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SearchResultWindow::priorityInStatusBar() const
|
|
|
|
|
{
|
|
|
|
|
return 80;
|
|
|
|
|
}
|
2009-04-30 12:50:52 +02:00
|
|
|
|
|
|
|
|
bool SearchResultWindow::canNext()
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
return d->m_items.count() > 0;
|
2009-04-30 12:50:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SearchResultWindow::canPrevious()
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
return d->m_items.count() > 0;
|
2009-04-30 12:50:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SearchResultWindow::goToNext()
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
if (d->m_items.count() == 0)
|
2009-04-30 12:50:52 +02:00
|
|
|
return;
|
2010-03-24 10:43:01 +01:00
|
|
|
QModelIndex idx = d->m_searchResultTreeView->model()->next(d->m_searchResultTreeView->currentIndex());
|
2009-04-30 12:50:52 +02:00
|
|
|
if (idx.isValid()) {
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_searchResultTreeView->setCurrentIndex(idx);
|
|
|
|
|
d->m_searchResultTreeView->emitJumpToSearchResult(idx);
|
2009-04-30 12:50:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void SearchResultWindow::goToPrev()
|
|
|
|
|
{
|
2010-03-24 10:43:01 +01:00
|
|
|
if (!d->m_searchResultTreeView->model()->rowCount())
|
2009-04-30 12:50:52 +02:00
|
|
|
return;
|
2010-03-24 10:43:01 +01:00
|
|
|
QModelIndex idx = d->m_searchResultTreeView->model()->prev(d->m_searchResultTreeView->currentIndex());
|
2009-04-30 12:50:52 +02:00
|
|
|
if (idx.isValid()) {
|
2010-03-24 10:43:01 +01:00
|
|
|
d->m_searchResultTreeView->setCurrentIndex(idx);
|
|
|
|
|
d->m_searchResultTreeView->emitJumpToSearchResult(idx);
|
2009-04-30 12:50:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SearchResultWindow::canNavigate()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2010-03-24 10:43:01 +01:00
|
|
|
|
|
|
|
|
} // namespace Find
|
|
|
|
|
|
2010-05-21 13:47:02 +02:00
|
|
|
|
|
|
|
|
#include "searchresultwindow.moc"
|