OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / find / searchresulttreemodel.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef SEARCHRESULTTREEMODEL_H
34 #define SEARCHRESULTTREEMODEL_H
35
36 #include "searchresultwindow.h"
37
38 #include <QtCore/QAbstractItemModel>
39 #include <QtCore/QRegExp>
40 #include <QtGui/QFont>
41 #include <QtGui/QTextDocument>
42
43 namespace Find {
44 namespace Internal {
45
46 class SearchResultTreeItem;
47
48 class SearchResultTreeModel : public QAbstractItemModel
49 {
50     Q_OBJECT
51
52 public:
53     SearchResultTreeModel(QObject *parent = 0);
54     ~SearchResultTreeModel();
55
56     void setShowReplaceUI(bool show);
57     void setTextEditorFont(const QFont &font);
58
59     Qt::ItemFlags flags(const QModelIndex &index) const;
60     QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
61     QModelIndex parent(const QModelIndex &child) const;
62     int rowCount(const QModelIndex &parent = QModelIndex()) const;
63     int columnCount(const QModelIndex &parent = QModelIndex()) const;
64     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
65     bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
66     QVariant headerData(int section, Qt::Orientation orientation, int role) const;
67
68     QModelIndex next(const QModelIndex &idx, bool includeGenerated = false, bool *wrapped = 0) const;
69     QModelIndex prev(const QModelIndex &idx, bool includeGenerated = false, bool *wrapped = 0) const;
70
71     QList<QModelIndex> addResults(const QList<SearchResultItem> &items, SearchResultWindow::AddMode mode);
72
73     QModelIndex find(const QRegExp &expr, const QModelIndex &index,
74                      QTextDocument::FindFlags flags, bool *wrapped = 0);
75     QModelIndex find(const QString &term, const QModelIndex &index,
76                      QTextDocument::FindFlags flags, bool *wrapped = 0);
77
78 signals:
79     void jumpToSearchResult(const QString &fileName, int lineNumber,
80                             int searchTermStart, int searchTermLength);
81
82 public slots:
83     void clear();
84
85 private:
86     QModelIndex index(SearchResultTreeItem *item) const;
87     void addResultsToCurrentParent(const QList<SearchResultItem> &items, SearchResultWindow::AddMode mode);
88     QSet<SearchResultTreeItem *> addPath(const QStringList &path);
89     QVariant data(const SearchResultTreeItem *row, int role) const;
90     bool setCheckState(const QModelIndex &idx, Qt::CheckState checkState, bool firstCall = true);
91     QModelIndex nextIndex(const QModelIndex &idx, bool *wrapped = 0) const;
92     QModelIndex prevIndex(const QModelIndex &idx, bool *wrapped = 0) const;
93     SearchResultTreeItem *treeItemAtIndex(const QModelIndex &idx) const;
94
95     SearchResultTreeItem *m_rootItem;
96     SearchResultTreeItem *m_currentParent;
97     QModelIndex m_currentIndex;
98     QStringList m_currentPath; // the path that belongs to the current parent
99     QFont m_textEditorFont;
100     bool m_showReplaceUI;
101 };
102
103 } // namespace Internal
104 } // namespace Find
105
106 #endif // SEARCHRESULTTREEMODEL_H