searchresultwidget.h 4.29 KB
Newer Older
1 2 3 4
/**************************************************************************
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
**
**
** GNU Lesser General Public License Usage
**
** 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.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
29
** Nokia at qt-info@nokia.com.
30 31 32 33 34 35 36 37 38 39
**
**************************************************************************/

#ifndef SEARCHRESULTWIDGET_H
#define SEARCHRESULTWIDGET_H

#include "searchresultwindow.h"

#include <coreplugin/infobar.h>

Eike Ziller's avatar
Eike Ziller committed
40
#include <QFrame>
41 42 43 44
#include <QLabel>
#include <QLineEdit>
#include <QToolButton>
#include <QWidget>
45 46 47 48 49 50 51 52 53 54 55

namespace Find {
namespace Internal {

class SearchResultTreeView;

class SearchResultWidget : public QWidget
{
    Q_OBJECT
public:
    explicit SearchResultWidget(QWidget *parent = 0);
56
    ~SearchResultWidget();
57

58 59
    void setInfo(const QString &label, const QString &toolTip, const QString &term);

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
    void addResult(const QString &fileName, int lineNumber, const QString &lineText,
                   int searchTermStart, int searchTermLength, const QVariant &userData = QVariant());
    void addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode);

    int count() const;

    QString dontAskAgainGroup() const;
    void setDontAskAgainGroup(const QString &group);

    void setTextToReplace(const QString &textToReplace);
    QString textToReplace() const;
    void setShowReplaceUI(bool visible);

    bool hasFocusInternally() const;
    void setFocusInternally();
    bool canFocusInternally() const;

    void notifyVisibilityChanged(bool visible);

    void setTextEditorFont(const QFont &font);

    void setAutoExpandResults(bool expand);
    void expandAll();
    void collapseAll();

    void goToNext();
    void goToPrevious();

Eike Ziller's avatar
Eike Ziller committed
88
    void restart();
89 90

    void setSearchAgainSupported(bool supported);
91
    void setSearchAgainEnabled(bool enabled);
92

93
public slots:
Eike Ziller's avatar
Eike Ziller committed
94
    void finishSearch(bool canceled);
95
    void sendRequestPopup();
96 97 98 99

signals:
    void activated(const Find::SearchResultItem &item);
    void replaceButtonClicked(const QString &replaceText, const QList<Find::SearchResultItem> &checkedItems);
100
    void searchAgainRequested();
101
    void cancelled();
102
    void paused(bool paused);
Eike Ziller's avatar
Eike Ziller committed
103
    void restarted();
104
    void visibilityChanged(bool visible);
105
    void requestPopup(bool focus);
106 107 108 109 110

    void navigateStateChanged();

private slots:
    void hideNoUndoWarning();
111 112
    void continueAfterSizeWarning();
    void cancelAfterSizeWarning();
113 114
    void handleJumpToSearchResult(const SearchResultItem &item);
    void handleReplaceButton();
115
    void cancel();
116
    void searchAgain();
117 118 119 120 121

private:
    bool showWarningMessage() const;
    void setShowWarningMessage(bool showWarningMessage);
    QList<SearchResultItem> checkedItems() const;
122
    void updateMatchesFoundLabel();
123 124 125

    SearchResultTreeView *m_searchResultTreeView;
    int m_count;
126 127
    bool m_sizeWarningActive;
    bool m_sizeWarningOverridden;
128
    QString m_dontAskAgainGroup;
Eike Ziller's avatar
Eike Ziller committed
129
    QFrame *m_messageWidget;
130 131 132 133 134 135
    Core::InfoBar m_infoBar;
    Core::InfoBarDisplay m_infoBarDisplay;
    bool m_isShowingReplaceUI;
    QLabel *m_replaceLabel;
    QLineEdit *m_replaceTextEdit;
    QToolButton *m_replaceButton;
136 137
    QToolButton *m_searchAgainButton;
    bool m_searchAgainSupported;
138 139 140
    QWidget *m_descriptionContainer;
    QLabel *m_label;
    QLabel *m_searchTerm;
141
    QToolButton *m_cancelButton;
142
    QLabel *m_matchesFoundLabel;
143 144 145 146 147 148
};

} // Internal
} // Find

#endif // SEARCHRESULTWIDGET_H