]> git.cworth.org Git - apitrace/blob - gui/argumentseditor.h
Use skiplist-based FastCallSet within trace::CallSet
[apitrace] / gui / argumentseditor.h
1 #ifndef ARGUMENTSEDITOR_H
2 #define ARGUMENTSEDITOR_H
3
4 #include "apitracecall.h"
5 #include "ui_argumentseditor.h"
6
7 #include <QComboBox>
8 #include <QDialog>
9 #include <QItemEditorFactory>
10 #include <QStandardItemModel>
11 #include <QSpinBox>
12
13 #include <limits.h>
14 #include <float.h>
15
16
17 class ApiTraceCall;
18
19 class BooleanComboBox : public QComboBox
20 {
21     Q_OBJECT
22     Q_PROPERTY(bool value READ value WRITE setValue USER true)
23 public:
24     BooleanComboBox(QWidget *parent);
25     void setValue(bool);
26     bool value() const;
27 };
28
29
30 class BooleanComboBoxEditorCreator : public BooleanComboBox
31 {
32     Q_OBJECT
33     Q_PROPERTY(bool value READ value WRITE setValue USER true)
34 public:
35     BooleanComboBoxEditorCreator(QWidget *widget = 0) : BooleanComboBox(widget)
36     {
37         this->setFrame(false);
38     };
39 };
40
41 class UIntEditorCreator : public QSpinBox
42 {
43     Q_OBJECT
44     Q_PROPERTY(int value READ value WRITE setValue USER true)
45 public:
46     UIntEditorCreator(QWidget *widget = 0) : QSpinBox(widget)
47     {
48         this->setFrame(false);
49         this->setMaximum(INT_MAX);
50     };
51 };
52
53 class IntEditorCreator : public QSpinBox
54 {
55     Q_OBJECT
56     Q_PROPERTY(int value READ value WRITE setValue USER true)
57 public:
58     IntEditorCreator(QWidget *widget = 0) : QSpinBox(widget)
59     {
60         this->setFrame(false);
61         this->setMinimum(INT_MIN);
62         this->setMaximum(INT_MAX);
63     };
64 };
65
66 class ULongLongEditorCreator : public QSpinBox
67 {
68     Q_OBJECT
69     Q_PROPERTY(int value READ value WRITE setValue USER true)
70 public:
71     ULongLongEditorCreator(QWidget *widget = 0) : QSpinBox(widget)
72     {
73         this->setFrame(false);
74         this->setMaximum(INT_MAX);
75     };
76 };
77
78 class LongLongEditorCreator : public QSpinBox
79 {
80     Q_OBJECT
81     Q_PROPERTY(int value READ value WRITE setValue USER true)
82 public:
83     LongLongEditorCreator(QWidget *widget = 0) : QSpinBox(widget)
84     {
85         this->setFrame(false);
86         this->setMinimum(INT_MIN);
87         this->setMaximum(INT_MAX);
88     };
89 };
90
91 class PixmapEditorCreator : public QLabel
92 {
93     Q_OBJECT
94     Q_PROPERTY(QString text READ text WRITE setText USER true)
95 public:
96     PixmapEditorCreator(QWidget *widget = 0) : QLabel (widget)
97     {
98     };
99 };
100
101 class FloatEditorCreator : public QDoubleSpinBox
102 {
103     Q_OBJECT
104     Q_PROPERTY(double value READ value WRITE setValue USER true)
105 public:
106     FloatEditorCreator(QWidget *widget = 0) : QDoubleSpinBox(widget)
107     {
108         this->setFrame(false);
109         this->setMinimum(-FLT_MAX);
110         this->setMaximum(FLT_MAX);
111         this->setDecimals(8);
112     };
113 };
114
115 class DoubleEditorCreator : public QDoubleSpinBox
116 {
117     Q_OBJECT
118     Q_PROPERTY(double value READ value WRITE setValue USER true)
119 public:
120     DoubleEditorCreator(QWidget *widget = 0) : QDoubleSpinBox(widget)
121     {
122         this->setFrame(false);
123         this->setMinimum(-DBL_MAX);
124         this->setMaximum(DBL_MAX);
125         this->setDecimals(8);
126     };
127 };
128
129 class InvalidEditorCreator : public QLabel
130 {
131     Q_OBJECT
132     Q_PROPERTY(QString text READ text WRITE setText USER true)
133 public:
134     InvalidEditorCreator(QWidget *widget = 0) :  QLabel(widget)
135     {
136     };
137 };
138
139 class ArgumentsEditor : public QDialog
140 {
141     Q_OBJECT
142 public:
143     ArgumentsEditor(QWidget *parent=0);
144     ~ArgumentsEditor();
145
146
147     virtual void accept();
148
149     void setCall(ApiTraceCall *call);
150     ApiTraceCall *call() const;
151
152 private slots:
153     void currentSourceChanged(int idx);
154     void sourceChanged();
155     void revert();
156 private:
157     void init();
158     void setupCall();
159     void setupShaderEditor(const QVector<QVariant> &sources);
160     QVariant valueForName(const QString &name,
161                           const QVariant &orignalValue,
162                           bool *changed) const;
163     QVariant arrayFromIndex(const QModelIndex &index,
164                             const ApiArray &array,
165                             bool *changed) const;
166     QVariant arrayFromEditor(const ApiArray &origArray,
167                              bool *changed) const;
168 private:
169     Ui_ArgumentsEditor m_ui;
170     QStandardItemModel *m_model;
171
172     ApiTraceCall *m_call;
173 };
174
175 #endif