1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
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.
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef SEARCHRESULTTREEMODEL_H
34 #define SEARCHRESULTTREEMODEL_H
36 #include "searchresultwindow.h"
38 #include <QtCore/QAbstractItemModel>
39 #include <QtCore/QRegExp>
40 #include <QtGui/QFont>
41 #include <QtGui/QTextDocument>
46 class SearchResultTreeItem;
48 class SearchResultTreeModel : public QAbstractItemModel
53 SearchResultTreeModel(QObject *parent = 0);
54 ~SearchResultTreeModel();
56 void setShowReplaceUI(bool show);
57 void setTextEditorFont(const QFont &font);
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;
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;
71 QList<QModelIndex> addResults(const QList<SearchResultItem> &items, SearchResultWindow::AddMode mode);
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);
79 void jumpToSearchResult(const QString &fileName, int lineNumber,
80 int searchTermStart, int searchTermLength);
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;
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;
103 } // namespace Internal
106 #endif // SEARCHRESULTTREEMODEL_H