summaryrefslogtreecommitdiffstats
path: root/tests/guidevtest/maindialog.h
blob: 3e1a261282e1a87ab5216d2a2423952fdfe68be3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef MAINDIALOG_H
#define MAINDIALOG_H

#include <QtGui/QDialog>
#include <QtCore/QAbstractListModel>



namespace Ui {
class MainDialog;
}

class UnitTestBase;

class TestsViewModel : public QAbstractListModel
{
    Q_OBJECT
public:
    explicit TestsViewModel(const QList<UnitTestBase *> &list, QObject *parent = 0);
    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
    virtual QVariant data(const QModelIndex &index, int role) const;
    virtual QVariant headerData(int section, Qt::Orientation orientation,
                                int role = Qt::DisplayRole) const;
    virtual  Qt::ItemFlags flags(const QModelIndex &index) const;
    virtual bool setData(const QModelIndex &index, const QVariant &value,
                         int role = Qt::EditRole);
    virtual QModelIndex index(int row, int column,
                              const QModelIndex &parent = QModelIndex()) const;

private:
    QList<UnitTestBase *> m_testsList;
};


class DescriptionDialog : public QDialog
{
public:
    explicit DescriptionDialog(const QString &content, QWidget *parent = 0);
};


class Logger;
class QModelIndex;

class MainDialog : public QDialog
{
    Q_OBJECT
public:
    explicit MainDialog(QWidget *parent = 0);
    ~MainDialog();

private slots:
    void procLogChanged(const QString &log);
    void procClearLogOnStartChanged(bool enable);
    void procBreakAllOnErrorChanged(bool enable);

    void procStartButtonClick();
    void procTestStarted();
    void procTestFinished();
    void procTestError();

    void procItemDoubleClick(const QModelIndex &index);

private:
    Ui::MainDialog *ui;
    TestsViewModel *m_model;
    QList<UnitTestBase *> m_testsList;
    Logger *m_logger;
    int m_enabledTestsCount;
    int m_it;

    static const QString logFileSettingsKey;
    static const QString breakOnErrorSettingsKey;
    static const QString clearLogOnStartSettingsKey;

    void showSettings();
    void createAvailableTests();
    void fillPairs();
    void enableUi(bool enable);
};

#endif // MAINDIALOG_H