2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-11-17 17:33:22 +01:00
|
|
|
#include "searchresultitem.h"
|
|
|
|
|
|
2010-03-24 10:43:01 +01:00
|
|
|
#include <coreplugin/ioutputpane.h>
|
2009-10-01 16:38:08 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QVariant>
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
#include <QIcon>
|
2010-07-19 14:46:53 +02:00
|
|
|
|
2009-10-01 16:38:08 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
2010-03-24 10:43:01 +01:00
|
|
|
class QFont;
|
2009-10-01 16:38:08 +02:00
|
|
|
QT_END_NAMESPACE
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-01-13 16:17:34 +01:00
|
|
|
namespace Core {
|
2010-03-24 10:43:01 +01:00
|
|
|
namespace Internal {
|
2011-09-09 16:10:57 +02:00
|
|
|
class SearchResultWindowPrivate;
|
2011-09-06 13:03:15 +02:00
|
|
|
class SearchResultWidget;
|
2010-03-24 10:43:01 +01:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
class SearchResultWindow;
|
|
|
|
|
|
2014-01-13 16:17:34 +01:00
|
|
|
class CORE_EXPORT SearchResult : public QObject
|
2009-10-05 16:01:50 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2009-09-29 16:59:19 +02:00
|
|
|
|
2011-08-09 11:08:01 +02:00
|
|
|
public:
|
2011-09-02 11:51:31 +02:00
|
|
|
enum AddMode {
|
|
|
|
|
AddSorted,
|
|
|
|
|
AddOrdered
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void setUserData(const QVariant &data);
|
|
|
|
|
QVariant userData() const;
|
|
|
|
|
QString textToReplace() const;
|
2011-12-12 15:16:49 +01:00
|
|
|
int count() const;
|
2011-12-13 10:50:57 +01:00
|
|
|
void setSearchAgainSupported(bool supported);
|
2015-09-30 18:04:17 +02:00
|
|
|
QWidget *additionalReplaceWidget() const;
|
2011-09-02 11:51:31 +02:00
|
|
|
|
|
|
|
|
public slots:
|
2016-11-17 17:33:22 +01:00
|
|
|
void addResult(const QString &fileName,
|
|
|
|
|
int lineNumber,
|
|
|
|
|
const QString &lineText,
|
|
|
|
|
int searchTermStart,
|
|
|
|
|
int searchTermLength,
|
|
|
|
|
const QVariant &userData = QVariant());
|
|
|
|
|
void addResult(const QString &fileName,
|
|
|
|
|
const QString &lineText,
|
|
|
|
|
Search::TextRange mainRange,
|
|
|
|
|
const QVariant &userData = QVariant());
|
2011-09-02 11:51:31 +02:00
|
|
|
void addResults(const QList<SearchResultItem> &items, AddMode mode);
|
2012-05-16 15:59:16 +02:00
|
|
|
void finishSearch(bool canceled);
|
2011-09-02 11:51:31 +02:00
|
|
|
void setTextToReplace(const QString &textToReplace);
|
2012-02-07 15:44:12 +01:00
|
|
|
void restart();
|
2011-12-14 15:55:05 +01:00
|
|
|
void setSearchAgainEnabled(bool enabled);
|
2012-05-25 16:45:18 +02:00
|
|
|
void popup();
|
2011-08-09 11:08:01 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
signals:
|
2014-01-13 16:17:34 +01:00
|
|
|
void activated(const Core::SearchResultItem &item);
|
|
|
|
|
void replaceButtonClicked(const QString &replaceText, const QList<Core::SearchResultItem> &checkedItems, bool preserveCase);
|
2011-09-09 08:46:51 +02:00
|
|
|
void cancelled();
|
2012-05-25 16:45:18 +02:00
|
|
|
void paused(bool paused);
|
2011-08-09 11:08:01 +02:00
|
|
|
void visibilityChanged(bool visible);
|
2011-12-12 15:16:49 +01:00
|
|
|
void countChanged(int count);
|
2011-12-13 10:50:57 +01:00
|
|
|
void searchAgainRequested();
|
2013-02-12 18:37:14 +01:00
|
|
|
void requestEnabledCheck();
|
2009-09-29 16:59:19 +02:00
|
|
|
|
2011-09-06 13:03:15 +02:00
|
|
|
private:
|
|
|
|
|
SearchResult(Internal::SearchResultWidget *widget);
|
|
|
|
|
friend class SearchResultWindow; // for the constructor
|
2011-08-09 11:08:01 +02:00
|
|
|
|
|
|
|
|
private:
|
2011-09-06 13:03:15 +02:00
|
|
|
Internal::SearchResultWidget *m_widget;
|
2011-08-09 11:08:01 +02:00
|
|
|
QVariant m_userData;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2014-11-16 10:52:41 +02:00
|
|
|
class CORE_EXPORT SearchResultWindow : public IOutputPane
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2009-10-05 16:01:50 +02:00
|
|
|
enum SearchMode {
|
|
|
|
|
SearchOnly,
|
|
|
|
|
SearchAndReplace
|
|
|
|
|
};
|
|
|
|
|
|
2014-03-11 16:06:33 -03:00
|
|
|
enum PreserveCaseMode {
|
|
|
|
|
PreserveCaseEnabled,
|
|
|
|
|
PreserveCaseDisabled
|
|
|
|
|
};
|
|
|
|
|
|
2010-07-19 14:46:53 +02:00
|
|
|
|
2011-09-09 08:46:51 +02:00
|
|
|
SearchResultWindow(QWidget *newSearchPanel);
|
2018-05-07 15:00:03 +02:00
|
|
|
~SearchResultWindow() override;
|
2010-07-12 12:46:50 +02:00
|
|
|
static SearchResultWindow *instance();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2018-05-07 15:00:03 +02:00
|
|
|
QWidget *outputWidget(QWidget *) override;
|
|
|
|
|
QList<QWidget*> toolBarWidgets() const override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2018-05-07 15:00:03 +02:00
|
|
|
QString displayName() const override { return tr("Search Results"); }
|
|
|
|
|
int priorityInStatusBar() const override;
|
|
|
|
|
void visibilityChanged(bool visible) override;
|
|
|
|
|
bool hasFocus() const override;
|
|
|
|
|
bool canFocus() const override;
|
|
|
|
|
void setFocus() override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2018-05-07 15:00:03 +02:00
|
|
|
bool canNext() const override;
|
|
|
|
|
bool canPrevious() const override;
|
|
|
|
|
void goToNext() override;
|
|
|
|
|
void goToPrev() override;
|
|
|
|
|
bool canNavigate() const override;
|
2009-04-30 12:50:52 +02:00
|
|
|
|
2012-10-18 08:02:25 +02:00
|
|
|
void setTextEditorFont(const QFont &font,
|
|
|
|
|
const QColor &textForegroundColor,
|
|
|
|
|
const QColor &textBackgroundColor,
|
|
|
|
|
const QColor &highlightForegroundColor,
|
|
|
|
|
const QColor &highlightBackgroundColor);
|
2013-07-03 18:23:03 +02:00
|
|
|
void setTabWidth(int width);
|
2011-09-09 08:46:51 +02:00
|
|
|
void openNewSearchPanel();
|
2009-10-05 16:01:50 +02:00
|
|
|
|
2011-09-09 16:10:57 +02:00
|
|
|
// The search result window owns the returned SearchResult
|
|
|
|
|
// and might delete it any time, even while the search is running
|
|
|
|
|
// (e.g. when the user clears the search result pane, or if the user opens so many other searches
|
|
|
|
|
// that this search falls out of the history).
|
|
|
|
|
SearchResult *startNewSearch(const QString &label,
|
|
|
|
|
const QString &toolTip,
|
|
|
|
|
const QString &searchTerm,
|
|
|
|
|
SearchMode searchOrSearchAndReplace = SearchOnly,
|
2014-03-11 16:06:33 -03:00
|
|
|
PreserveCaseMode preserveCaseMode = PreserveCaseEnabled,
|
2011-05-06 16:06:25 +02:00
|
|
|
const QString &cfgGroup = QString());
|
2009-09-29 16:40:52 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
public slots:
|
2018-05-07 15:00:03 +02:00
|
|
|
void clearContents() override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-01-13 16:17:34 +01:00
|
|
|
public: // Used by plugin, do not use
|
|
|
|
|
void writeSettings();
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
2008-12-02 15:08:31 +01:00
|
|
|
void readSettings();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-06-29 13:16:54 +02:00
|
|
|
Internal::SearchResultWindowPrivate *d;
|
2010-07-12 12:46:50 +02:00
|
|
|
static SearchResultWindow *m_instance;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2014-01-13 16:17:34 +01:00
|
|
|
} // namespace Core
|