OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / memcheck / memcheckerrorview.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: Andreas Hartmetz, KDAB (andreas.hartmetz@kdab.com)
8 **
9 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 **
11 **
12 ** GNU Lesser General Public License Usage
13 **
14 ** This file may be used under the terms of the GNU Lesser General Public
15 ** License version 2.1 as published by the Free Software Foundation and
16 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
17 ** Please review the following information to ensure the GNU Lesser General
18 ** Public License version 2.1 requirements will be met:
19 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
20 **
21 ** In addition, as a special exception, Nokia gives you certain additional
22 ** rights. These rights are described in the Nokia Qt LGPL Exception
23 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
24 **
25 ** Other Usage
26 **
27 ** Alternatively, this file may be used in accordance with the terms and
28 ** conditions contained in a signed written agreement between you and Nokia.
29 **
30 ** If you have questions regarding the use of this file, please contact
31 ** Nokia at qt-info@nokia.com.
32 **
33 **************************************************************************/
34
35 #ifndef MEMCHECKERRORVIEW_H
36 #define MEMCHECKERRORVIEW_H
37
38 #include <QtGui/QListView>
39 #include <QtGui/QStyledItemDelegate>
40 #include <QtGui/QLabel>
41
42 QT_BEGIN_NAMESPACE
43 class QListView;
44 class QVBoxLayout;
45 QT_END_NAMESPACE
46
47 namespace ProjectExplorer {
48 class Project;
49 }
50
51 namespace Analyzer {
52
53 class AnalyzerSettings;
54
55 namespace Internal {
56
57 class MemcheckErrorDelegate : public QStyledItemDelegate
58 {
59     Q_OBJECT
60
61 public:
62     /// This delegate can only work on one view at a time, parent. parent will also be the parent
63     /// in the QObject parent-child system.
64     MemcheckErrorDelegate(QListView *parent);
65     virtual ~MemcheckErrorDelegate();
66
67     virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
68     virtual void paint(QPainter *painter, const QStyleOptionViewItem &option,
69                        const QModelIndex &index) const;
70
71 public slots:
72     void currentChanged(const QModelIndex &now, const QModelIndex &previous);
73     void viewResized();
74     void layoutChanged();
75     void copy();
76
77 private slots:
78     void verticalScrolled();
79     void openLinkInEditor(const QString &link);
80
81 private:
82     // the constness of this method is a necessary lie because it is called from paint() const.
83     QWidget *createDetailsWidget(const QModelIndex &errorIndex, QWidget *parent) const;
84
85     static const int s_itemMargin = 2;
86     mutable QPersistentModelIndex m_detailsIndex;
87     mutable QWidget *m_detailsWidget;
88     mutable int m_detailsWidgetHeight;
89 };
90
91 class MemcheckErrorView : public QListView
92 {
93     Q_OBJECT
94
95 public:
96     MemcheckErrorView(QWidget *parent = 0);
97     ~MemcheckErrorView();
98
99     // reimplemented to connect delegate to connection model after it has been set by
100     // superclass implementation
101     void setModel(QAbstractItemModel *model);
102
103     void setDefaultSuppressionFile(const QString &suppFile);
104     QString defaultSuppressionFile() const;
105     AnalyzerSettings *settings() const { return m_settings; }
106
107 signals:
108     void resized();
109
110 public slots:
111     void settingsChanged(AnalyzerSettings *settings);
112
113 private slots:
114     void suppressError();
115
116 protected:
117     void resizeEvent(QResizeEvent *e);
118     void contextMenuEvent(QContextMenuEvent *e);
119
120 private:
121     QAction *m_copyAction;
122     QAction *m_suppressAction;
123     QString m_defaultSuppFile;
124     AnalyzerSettings *m_settings;
125 };
126
127 } // namespace Internal
128 } // namespace Analyzer
129
130 #endif // MEMCHECKERRORVIEW_H