summaryrefslogtreecommitdiff
path: root/src/plugins/squish/squishperspective.h
blob: 1ab6b59be2e7a6d5aa3952f0a0cc927b07fc2b61 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright (C) 2022 The Qt Company Ltd
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "squishconstants.h"

#include <debugger/debuggermainwindow.h>

#include <utils/treemodel.h>

namespace Utils { class TreeView; }

namespace Squish {
namespace Internal {

class SquishXmlOutputHandler;

class LocalsItem : public Utils::TreeItem
{
public:
    LocalsItem() = default;
    LocalsItem(const QString &n, const QString &t, const QString &v) : name(n), type(t), value(v) {}
    QVariant data(int column, int role) const override;
    QString name;
    QString type;
    QString value;
    bool expanded = false;
};

class InspectedObjectItem : public Utils::TreeItem
{
public:
    InspectedObjectItem() = default;
    InspectedObjectItem(const QString &v, const QString &t) : value(v), type(t) {}
    QVariant data(int column, int role) const override;
    QString value;
    QString type;
    bool expanded = false;
};

class InspectedPropertyItem : public Utils::TreeItem
{
public:
    InspectedPropertyItem() = default;
    InspectedPropertyItem(const QString &n, const QString &v)
        : name(n), value(v) { parseAndUpdateChildren(); }
    QVariant data(int column, int role) const override;
    QString name;
    QString value;
    bool expanded = false;
private:
    void parseAndUpdateChildren();
};

class SquishPerspective : public Utils::Perspective
{
    Q_OBJECT
public:
    enum PerspectiveMode { NoMode, Interrupted, Running, Recording, Querying, Configuring };

    SquishPerspective();
    void initPerspective();
    void setPerspectiveMode(PerspectiveMode mode);
    PerspectiveMode perspectiveMode() const { return m_mode; }

    void updateStatus(const QString &status);

    void showControlBar(SquishXmlOutputHandler *xmlOutputHandler);
    void destroyControlBar();
    void resetAutId();

signals:
    void stopRequested();
    void stopRecordRequested();
    void interruptRequested();
    void runRequested(StepMode mode);
    void inspectTriggered();

private:
    void onStopTriggered();
    void onStopRecordTriggered();
    void onPausePlayTriggered();
    void onLocalsUpdated(const QString &output);
    void onObjectPicked(const QString &output);
    void onPropertiesFetched(const QStringList &properties);

    QAction *m_stopRecordAction = nullptr;
    QAction *m_pausePlayAction = nullptr;
    QAction *m_stepInAction = nullptr;
    QAction *m_stepOverAction = nullptr;
    QAction *m_stepOutAction = nullptr;
    QAction *m_stopAction = nullptr;
    QAction *m_inspectAction = nullptr;
    QLabel *m_status = nullptr;
    class SquishControlBar *m_controlBar = nullptr;
    Utils::TreeModel<LocalsItem> m_localsModel;
    Utils::TreeModel<InspectedObjectItem> m_objectsModel;
    Utils::TreeModel<InspectedPropertyItem> m_propertiesModel;
    Utils::TreeView *m_objectsView = nullptr;
    PerspectiveMode m_mode = NoMode;
    bool m_autIdKnown = false;

    friend class SquishControlBar;
};

} // namespace Internal
} // namespace Squish