OSDN Git Service

51a953011ff9744af130c98d53f518cea805fe53
[qt-creator-jp/qt-creator-jp.git] / src / libs / valgrind / xmlprotocol / errorlistmodel.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 ** Author: Frank Osterfeld, KDAB (frank.osterfeld@kdab.com)
8 **
9 ** Contact: Nokia Corporation (qt-info@nokia.com)
10 **
11 ** No Commercial Usage
12 **
13 ** This file contains pre-release code and may not be distributed.
14 ** You may use this file in accordance with the terms and conditions
15 ** contained in the Technology Preview License Agreement accompanying
16 ** this package.
17 **
18 ** GNU Lesser General Public License Usage
19 **
20 ** Alternatively, this file may be used under the terms of the GNU Lesser
21 ** General Public License version 2.1 as published by the Free Software
22 ** Foundation and appearing in the file LICENSE.LGPL included in the
23 ** packaging of this file.  Please review the following information to
24 ** ensure the GNU Lesser General Public License version 2.1 requirements
25 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
26 **
27 ** In addition, as a special exception, Nokia gives you certain additional
28 ** rights.  These rights are described in the Nokia Qt LGPL Exception
29 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
30 **
31 ** If you have questions regarding the use of this file, please contact
32 ** Nokia at qt-info@nokia.com.
33 **
34 **************************************************************************/
35
36 #ifndef LIBVALGRIND_PROTOCOL_ERRORLISTMODEL_H
37 #define LIBVALGRIND_PROTOCOL_ERRORLISTMODEL_H
38
39 #include "../valgrind_global.h"
40
41 #include <QtCore/QAbstractItemModel>
42 #include <QtCore/QSharedPointer>
43
44 namespace Valgrind {
45 namespace XmlProtocol {
46
47 class Error;
48 class Frame;
49
50 class VALGRINDSHARED_EXPORT ErrorListModel : public QAbstractItemModel
51 {
52     Q_OBJECT
53 public:
54     enum Column {
55         WhatColumn=0,
56         LocationColumn,
57         AbsoluteFilePathColumn,
58         LineColumn,
59         UniqueColumn,
60         TidColumn,
61         KindColumn,
62         LeakedBlocksColumn,
63         LeakedBytesColumn,
64         HelgrindThreadIdColumn,
65         ColumnCount
66     };
67
68     enum Role {
69         ErrorRole=Qt::UserRole,
70         AbsoluteFilePathRole,
71         FileRole,
72         LineRole
73     };
74
75     class RelevantFrameFinder
76     {
77     public:
78         virtual ~RelevantFrameFinder() {}
79         virtual Frame findRelevant(const Error &error) const = 0;
80     };
81
82     explicit ErrorListModel(QObject *parent=0);
83     ~ErrorListModel();
84
85     QSharedPointer<const RelevantFrameFinder> relevantFrameFinder() const;
86     void setRelevantFrameFinder(const QSharedPointer<const RelevantFrameFinder> &finder);
87
88     QVariant data(const QModelIndex &index, int role) const;
89     QVariant headerData(int section, Qt::Orientation orientation, int role) const;
90     QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
91     QModelIndex parent(const QModelIndex &child) const;
92     int rowCount(const QModelIndex &parent = QModelIndex()) const;
93     int columnCount(const QModelIndex &parent = QModelIndex()) const;
94     virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
95
96     Error error(const QModelIndex &index) const;
97
98     Frame findRelevantFrame(const Error &error) const;
99
100     void clear();
101
102 public Q_SLOTS:
103     void addError(const Valgrind::XmlProtocol::Error &error);
104
105 private:
106     class Private;
107     Private *const d;
108 };
109
110 }
111 }
112
113 #endif // LIBVALGRIND_PROTOCOL_ERRORLISTMODEL_H