~timo-jyrinki/ubuntu/saucy/qtcreator/add_workaround_back

« back to all changes in this revision

Viewing changes to src/plugins/qtestlib/qtestlibplugin.h

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2011-11-18 16:18:49 UTC
  • mfrom: (1.1.16)
  • Revision ID: package-import@ubuntu.com-20111118161849-5t8jugl6egvs4iev
Tags: 2.4.0~rc-0ubuntu1
* New upstream release candidate.
* Drop 04_fix_ftbfs_arm_qreal.diff, merged upstream.
* Refresh 01_fix_installation_paths.diff.
* Compress binary packages with xz.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**************************************************************************
2
 
**
3
 
** This file is part of Qt Creator
4
 
**
5
 
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6
 
**
7
 
** Contact: Nokia Corporation (info@qt.nokia.com)
8
 
**
9
 
**
10
 
** GNU Lesser General Public License Usage
11
 
**
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.
18
 
**
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.
22
 
**
23
 
** Other Usage
24
 
**
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.
27
 
**
28
 
** If you have questions regarding the use of this file, please contact
29
 
** Nokia at info@qt.nokia.com.
30
 
**
31
 
**************************************************************************/
32
 
 
33
 
#ifndef QTESTLIBPLUGIN_H
34
 
#define QTESTLIBPLUGIN_H
35
 
 
36
 
#include <coreplugin/ioutputpane.h>
37
 
#include <extensionsystem/pluginmanager.h>
38
 
#include <projectexplorer/projectexplorer.h>
39
 
 
40
 
#include <QtGui/QPixmap>
41
 
#include <QtGui/QSortFilterProxyModel>
42
 
#include <QtGui/QStandardItem>
43
 
#include <QtGui/QWidget>
44
 
 
45
 
QT_BEGIN_NAMESPACE
46
 
class QComboBox;
47
 
class QStandardItemModel;
48
 
class QTextEdit;
49
 
class QTreeView;
50
 
QT_END_NAMESPACE
51
 
 
52
 
namespace QTestLib {
53
 
namespace Internal {
54
 
 
55
 
class QTestLibPlugin;
56
 
class QTestOutputWidget;
57
 
 
58
 
struct QTestLocation
59
 
{
60
 
    QString file;
61
 
    QString line;
62
 
};
63
 
 
64
 
class QTestFunction : public QStandardItem
65
 
{
66
 
public:
67
 
    enum IncidentType {
68
 
        Pass,
69
 
        XFail,
70
 
        Fail,
71
 
        XPass
72
 
    };
73
 
 
74
 
    enum MessageType {
75
 
        Warning,
76
 
        QWarning,
77
 
        QDebug,
78
 
        QSystem,
79
 
        QFatal,
80
 
        Skip,
81
 
        Info
82
 
    };
83
 
 
84
 
    inline QTestFunction(const QString &name)
85
 
        : QStandardItem(name) {
86
 
        setColumnCount(2);
87
 
        // ### hardcoding colors sucks...
88
 
        setForeground(Qt::darkBlue);
89
 
    }
90
 
 
91
 
    void addIncident(IncidentType type,
92
 
                     const QString &file = QString(),
93
 
                     const QString &line = QString(),
94
 
                     const QString &details = QString());
95
 
 
96
 
    void addMessage(MessageType type, const QString &text);
97
 
 
98
 
    static bool indexHasIncidents(const QModelIndex &function, IncidentType type);
99
 
};
100
 
 
101
 
class QTestOutputPane : public Core::IOutputPane
102
 
{
103
 
    Q_OBJECT
104
 
 
105
 
public:
106
 
    QTestOutputPane(QTestLibPlugin *plugin);
107
 
 
108
 
    void addFunction(QTestFunction *function);
109
 
 
110
 
    virtual QWidget *outputWidget(QWidget *parent);
111
 
    QList<QWidget*> toolBarWidgets(void) const { return QList<QWidget *>(); }
112
 
    virtual QString name() const;
113
 
 
114
 
    virtual void clearContents();
115
 
    virtual void visibilityChanged(bool visible);
116
 
 
117
 
    void show();
118
 
 
119
 
    // FIXME:
120
 
    virtual int priorityInStatusBar() const { return 0;}
121
 
    virtual void setFocus() {}
122
 
    virtual bool hasFocus() { return false;}
123
 
    virtual bool canFocus() { return false;}
124
 
 
125
 
signals:
126
 
    void showPage();
127
 
 
128
 
private:
129
 
    QTestLibPlugin *m_plugin;
130
 
    QTestOutputWidget *m_widget;
131
 
    QStandardItemModel *m_model;
132
 
};
133
 
 
134
 
class QTestOutputFilter : public QSortFilterProxyModel
135
 
{
136
 
public:
137
 
    inline QTestOutputFilter(QObject *parent)
138
 
        : QSortFilterProxyModel(parent), m_filter(QTestFunction::Fail)
139
 
    {}
140
 
 
141
 
    inline void setIncidentFilter(QTestFunction::IncidentType incident) {
142
 
        m_filter = incident;
143
 
        filterChanged();
144
 
    }
145
 
 
146
 
protected:
147
 
    virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
148
 
 
149
 
private:
150
 
    QTestFunction::IncidentType m_filter;
151
 
};
152
 
 
153
 
class QTestOutputWidget : public QWidget
154
 
{
155
 
    Q_OBJECT
156
 
 
157
 
public:
158
 
    QTestOutputWidget(QStandardItemModel *model, QWidget *parent);
159
 
 
160
 
    void expand();
161
 
 
162
 
private Q_SLOTS:
163
 
    void activateComboFilter(int index);
164
 
    void gotoLocation(QModelIndex index);
165
 
 
166
 
private:
167
 
    QStandardItemModel *m_model;
168
 
    QTreeView *m_resultsView;
169
 
    QComboBox *m_filterCombo;
170
 
    QTestOutputFilter *m_filterModel;
171
 
};
172
 
 
173
 
class QTestLibPlugin : public QObject
174
 
{
175
 
    Q_OBJECT
176
 
 
177
 
public:
178
 
    QTestLibPlugin();
179
 
    virtual ~QTestLibPlugin();
180
 
 
181
 
    bool init(const QStringList &args, QString *errorMessage);
182
 
    void extensionsInitialized();
183
 
 
184
 
    // IApplicationOutput
185
 
    virtual void clear();
186
 
    virtual void appendOutput(const QString &out);
187
 
    virtual void processExited(int exitCode);
188
 
 
189
 
private slots:
190
 
    void projectRunHook(ProjectExplorer::Project *project);
191
 
 
192
 
private:
193
 
    ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
194
 
    QString m_outputFile;
195
 
    QString m_projectDirectory;
196
 
    QTestOutputPane *m_outputPane;
197
 
};
198
 
 
199
 
} // namespace Internal
200
 
} // namespace QTestLibPlugin
201
 
 
202
 
Q_DECLARE_METATYPE(QTestLib::Internal::QTestLocation)
203
 
Q_DECLARE_METATYPE(QTestLib::Internal::QTestFunction::IncidentType)
204
 
Q_DECLARE_METATYPE(QTestLib::Internal::QTestFunction::MessageType)
205
 
 
206
 
#endif // QTESTLIBPLUGIN_H