-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidgetqmfobject.h
More file actions
180 lines (149 loc) · 5.71 KB
/
widgetqmfobject.h
File metadata and controls
180 lines (149 loc) · 5.71 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef WIDGETQMFOBJECT_H
#define WIDGETQMFOBJECT_H
#include <QWidget>
#include <QPushButton>
#include <QLabel>
#include <QTableWidget>
#include <QVariant>
#include "qpid/types/Variant.h"
#include <qmf/Data.h>
#include "related-model.h"
#include "object-model.h"
#include "propertydelegate.h"
#include "relatedheaderview.h"
namespace Ui {
class WidgetQmfObject;
}
class WidgetQmfObject : public QWidget
{
Q_OBJECT
public:
enum ArrowDirection {
arrowNone,
arrowLeft,
arrowRight
};
enum StatMode {
modeMessages,
modeBytes,
modeMessageRate,
modeByteRate
};
explicit WidgetQmfObject(QWidget *parent = 0);
~WidgetQmfObject();
static const QColor colors[];
bool current();
void setCurrent(bool b=true);
void setSectionName(const QString&);
const QString §ionName() {return sectionTitle; }
void initRelatedButtons();
void setAction(QAction *myAction);
QAction * getAction() { return action; }
void setRelatedModel(ObjectListModel *, QWidget *);
void reset();
void setArrow(ArrowDirection a) {_arrow = a;}
QStringList getSampleProperties();
// expose the pushbutton publically so signal/slots can be connected
QPushButton* pushButton();
// the other widgets in the ui
typedef QList<WidgetQmfObject *> qmfWidgetList;
qmfWidgetList peers;
WidgetQmfObject *leftBuddy;
WidgetQmfObject *rightBuddy;
const qmf::DataAddr& getDataAddr();
bool hasData();
public slots:
void setCurrentObject(const qmf::Data& object);
void setCurrentMode(StatMode);
void objectRefreshed();
void setEnabled(bool enabled);
void initRelated();
void showChart(bool b);
void setDrawAsRect(bool b);
void showRelatedButtons(bool);
void setUpdateStrategy(bool);
void setChartType(bool);
protected:
QString sectionTitle;
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event);
void focusInEvent ( QFocusEvent * event );
void keyPressEvent ( QKeyEvent * event );
virtual void showRelated(const qmf::Data& object, const QString& widget_name, ArrowDirection a);
void showChart(const qmf::Data& object, ObjectListModel *model);
int reservedY(); // amount reserved at top of widget for button and label
int mid_paint(); // use this as a common mid point for painting
virtual QString unique_property(bool useKey=false); // allow derived classes to override object name
void setRelatedText(const std::string&);
ArrowDirection arrow() { return _arrow; }
QColor getLineColor(); // the color to draw the section's background icon (based on focus)
QColor getFillColor(); // the color to draw the section's background icon (based on focus)
// the columns that are to be displayed in the summary box
struct Column {
std::string name;
QString header;
Qt::Alignment alignment;
std::string format;
StatMode mode;
bool chart;
QColor color;
Column(const std::string& _n, const char* _h, Qt::Alignment _a, const std::string& _f, StatMode _m, bool _c=false, QColor _co=QColor(Qt::red)):
name(_n), header(_h), alignment(_a), format(_f), mode(_m), chart(_c), color(_co) {}
};
typedef QList<Column> ObjectColumnList;
ObjectColumnList summaryColumns;
RelatedFilterProxyModel *related;
QColor backgroundColor;
StatMode currentMode;
QAction *action;
bool updateAll; // current update strategy (all or just the current object)
bool chartType; // true->area chart
// the currently displayed object
qmf::Data data;
signals:
void needData(); // send query that gets all objects of this type
void needUpdate(); // send query that updated only the current object
void pivotTo(const QModelIndex&); // select this row in the associated dialog box
private slots:
void relatedIndexChanged(int index);
void pivot(); // make the current related object the base/root object
private:
void setLabelName();
void fillTableWidget();
void resetOthers();
void updateComboboxIndex(int i, bool all);
bool reallyHasFocus();
void showData(const qmf::Data& object);
QString fmtBytes(const qpid::types::Variant& v) const;
QString value(const qpid::types::Variant::Map::const_iterator& iter, const QString& uname, const std::string &);
bool _current; // this section is the primary one, others show related objects to this one
bool chart; // should we show the chart
ArrowDirection _arrow; // direction to draw a background arrow 0->none 1->left 2->right
Ui::WidgetQmfObject *ui;
int duration;
QIcon redIcon;
QIcon greenIcon;
QIcon blueIcon;
bool drawAsRect; // add a white background and border when the layout is cascading
PropertyDelegate * propertyDelegate;
RelatedHeaderView * relatedHeader;
};
#endif // WIDGETQMFOBJECT_H