searchresulttreemodel.h 3.1 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
5
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
** Commercial Usage
10
**
11
12
13
14
** 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.
15
**
16
** GNU Lesser General Public License Usage
17
**
18
19
20
21
22
23
** 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.
24
**
25
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
27
**
28
**************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30
31
32
33
#ifndef SEARCHRESULTTREEMODEL_H
#define SEARCHRESULTTREEMODEL_H

#include <QtCore/QAbstractItemModel>
34
#include <QtGui/QFont>
con's avatar
con committed
35

hjk's avatar
hjk committed
36
namespace Find {
con's avatar
con committed
37
38
39
40
41
42
namespace Internal {

class SearchResultTreeItem;
class SearchResultTextRow;
class SearchResultFile;

hjk's avatar
hjk committed
43
class SearchResultTreeModel : public QAbstractItemModel
con's avatar
con committed
44
45
46
47
48
49
50
{
    Q_OBJECT

public:
    SearchResultTreeModel(QObject *parent = 0);
    ~SearchResultTreeModel();

51
52
    void setTextEditorFont(const QFont &font);

Thorbjørn Lindeijer's avatar
Thorbjørn Lindeijer committed
53
    QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
con's avatar
con committed
54
55
56
57
58
59
    QModelIndex parent(const QModelIndex &child) const;
    int rowCount(const QModelIndex &parent = QModelIndex()) const;
    int columnCount(const QModelIndex &parent = QModelIndex()) const;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    QVariant headerData(int section, Qt::Orientation orientation, int role) const;

60
61
62
    QModelIndex next(const QModelIndex &idx) const;
    QModelIndex prev(const QModelIndex &idx) const;

con's avatar
con committed
63
64
signals:
    void jumpToSearchResult(const QString &fileName, int lineNumber,
Thorbjørn Lindeijer's avatar
Thorbjørn Lindeijer committed
65
                            int searchTermStart, int searchTermLength);
con's avatar
con committed
66
67
68

public slots:
    void clear();
69
70
71
72
    void appendResultLine(int index, int lineNumber, const QString &rowText,
                          int searchTermStart, int searchTermLength);
    void appendResultLine(int index, const QString &fileName, int lineNumber, const QString &rowText,
                          int searchTermStart, int searchTermLength);
con's avatar
con committed
73
74
75
76
77

private:
    void appendResultFile(const QString &fileName);
    QVariant data(const SearchResultTextRow *row, int role) const;
    QVariant data(const SearchResultFile *file, int role) const;
Thorbjørn Lindeijer's avatar
Thorbjørn Lindeijer committed
78
79
    void initializeData();
    void disposeData();
con's avatar
con committed
80
81
82

    SearchResultTreeItem *m_rootItem;
    SearchResultFile *m_lastAppendedResultFile;
83
    QFont m_textEditorFont;
con's avatar
con committed
84
85
};

hjk's avatar
hjk committed
86
87
} // namespace Internal
} // namespace Find
con's avatar
con committed
88

hjk's avatar
hjk committed
89
#endif // SEARCHRESULTTREEMODEL_H