1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Author: Andreas Hartmetz, KDAB (andreas.hartmetz@kdab.com)
9 ** Contact: Nokia Corporation (info@qt.nokia.com)
12 ** GNU Lesser General Public License Usage
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.
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.
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.
30 ** If you have questions regarding the use of this file, please contact
31 ** Nokia at qt-info@nokia.com.
33 **************************************************************************/
35 #ifndef MEMCHECKERRORVIEW_H
36 #define MEMCHECKERRORVIEW_H
38 #include <QtGui/QListView>
39 #include <QtGui/QStyledItemDelegate>
40 #include <QtGui/QLabel>
47 namespace ProjectExplorer {
53 class AnalyzerSettings;
57 class MemcheckErrorDelegate : public QStyledItemDelegate
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();
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;
72 void currentChanged(const QModelIndex &now, const QModelIndex &previous);
78 void verticalScrolled();
79 void openLinkInEditor(const QString &link);
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;
85 static const int s_itemMargin = 2;
86 mutable QPersistentModelIndex m_detailsIndex;
87 mutable QWidget *m_detailsWidget;
88 mutable int m_detailsWidgetHeight;
91 class MemcheckErrorView : public QListView
96 MemcheckErrorView(QWidget *parent = 0);
99 // reimplemented to connect delegate to connection model after it has been set by
100 // superclass implementation
101 void setModel(QAbstractItemModel *model);
103 void setDefaultSuppressionFile(const QString &suppFile);
104 QString defaultSuppressionFile() const;
105 AnalyzerSettings *settings() const { return m_settings; }
111 void settingsChanged(AnalyzerSettings *settings);
114 void suppressError();
117 void resizeEvent(QResizeEvent *e);
118 void contextMenuEvent(QContextMenuEvent *e);
121 QAction *m_copyAction;
122 QAction *m_suppressAction;
123 QString m_defaultSuppFile;
124 AnalyzerSettings *m_settings;
127 } // namespace Internal
128 } // namespace Analyzer
130 #endif // MEMCHECKERRORVIEW_H