@@ -51,9 +51,8 public: | |||||
51 |
|
51 | |||
52 | int count = series->barSets().first()->count(); |
|
52 | int count = series->barSets().first()->count(); | |
53 |
|
53 | |||
54 |
for(int i =0 |
|
54 | for (int i = 0; i < count; i++) | |
55 | barcategory->append(QString::number(i)); |
|
55 | barcategory->append(QString::number(i)); | |
56 | } |
|
|||
57 |
|
56 | |||
58 | chart->setAxisY(valueaxis, series); |
|
57 | chart->setAxisY(valueaxis, series); | |
59 | chart->setAxisX(barcategory, series); |
|
58 | chart->setAxisX(barcategory, series); |
@@ -51,9 +51,8 public: | |||||
51 |
|
51 | |||
52 | int count = series->barSets().first()->count(); |
|
52 | int count = series->barSets().first()->count(); | |
53 |
|
53 | |||
54 |
for(int i =0 |
|
54 | for (int i = 0; i < count; i++) | |
55 | barcategory->append(QString::number(i)); |
|
55 | barcategory->append(QString::number(i)); | |
56 | } |
|
|||
57 |
|
56 | |||
58 | chart->setAxisX(valueaxis, series); |
|
57 | chart->setAxisX(valueaxis, series); | |
59 | chart->setAxisY(barcategory, series); |
|
58 | chart->setAxisY(barcategory, series); |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -25,7 +25,8 | |||||
25 | #include <QGraphicsSceneMouseEvent> |
|
25 | #include <QGraphicsSceneMouseEvent> | |
26 | #include <QDebug> |
|
26 | #include <QDebug> | |
27 |
|
27 | |||
28 |
Grid::Grid(int size,QGraphicsItem *parent) |
|
28 | Grid::Grid(int size, QGraphicsItem *parent) | |
|
29 | : QGraphicsWidget(parent), | |||
29 | m_listCount(3), |
|
30 | m_listCount(3), | |
30 | m_valueMax(10), |
|
31 | m_valueMax(10), | |
31 | m_valueCount(7), |
|
32 | m_valueCount(7), | |
@@ -55,23 +56,18 void Grid::createCharts(const QString& category) | |||||
55 | Charts::ChartList list = Charts::chartList(); |
|
56 | Charts::ChartList list = Charts::chartList(); | |
56 |
|
57 | |||
57 | if (category.isEmpty()) { |
|
58 | if (category.isEmpty()) { | |
58 |
|
||||
59 | for (int i = 0; i < m_size * m_size; ++i) { |
|
59 | for (int i = 0; i < m_size * m_size; ++i) { | |
60 | QChart *chart = 0; |
|
60 | QChart *chart = 0; | |
61 | if (i < list.size()) { |
|
61 | if (i < list.size()) { | |
62 | chart = list.at(i)->createChart(m_dataTable); |
|
62 | chart = list.at(i)->createChart(m_dataTable); | |
63 | } |
|
63 | } else { | |
64 | else { |
|
|||
65 | chart = new QChart(); |
|
64 | chart = new QChart(); | |
66 | chart->setTitle(QObject::tr("Empty")); |
|
65 | chart->setTitle(QObject::tr("Empty")); | |
67 | } |
|
66 | } | |
68 |
|
||||
69 | m_gridLayout->addItem(chart, i / m_size, i % m_size); |
|
67 | m_gridLayout->addItem(chart, i / m_size, i % m_size); | |
70 | m_chartHash[chart] = i; |
|
68 | m_chartHash[chart] = i; | |
71 | } |
|
69 | } | |
72 | } |
|
70 | } else { | |
73 | else { |
|
|||
74 |
|
||||
75 | int j = 0; |
|
71 | int j = 0; | |
76 | for (int i = 0; i < list.size(); ++i) { |
|
72 | for (int i = 0; i < list.size(); ++i) { | |
77 | Chart *chart = list.at(i); |
|
73 | Chart *chart = list.at(i); | |
@@ -95,9 +91,8 void Grid::createCharts(const QString& category) | |||||
95 |
|
91 | |||
96 | void Grid::clear() |
|
92 | void Grid::clear() | |
97 | { |
|
93 | { | |
98 |
for (int i = 0; i < m_gridLayout->count(); ++i) |
|
94 | for (int i = 0; i < m_gridLayout->count(); ++i) | |
99 | m_gridLayout->removeAt(i); |
|
95 | m_gridLayout->removeAt(i); | |
100 | } |
|
|||
101 |
|
96 | |||
102 | qDeleteAll(m_chartHash.keys()); |
|
97 | qDeleteAll(m_chartHash.keys()); | |
103 | m_chartHash.clear(); |
|
98 | m_chartHash.clear(); | |
@@ -115,8 +110,7 void Grid::setState(State state) | |||||
115 |
|
110 | |||
116 | void Grid::setSize(int size) |
|
111 | void Grid::setSize(int size) | |
117 | { |
|
112 | { | |
118 | if(m_size !=size) |
|
113 | if (m_size != size) { | |
119 | { |
|
|||
120 | m_size = size; |
|
114 | m_size = size; | |
121 | createCharts(m_category); |
|
115 | createCharts(m_category); | |
122 | } |
|
116 | } | |
@@ -152,7 +146,6 void Grid::mousePressEvent(QGraphicsSceneMouseEvent *event) | |||||
152 | m_currentState = NoState; |
|
146 | m_currentState = NoState; | |
153 |
|
147 | |||
154 | foreach (QChart *chart, charts()) { |
|
148 | foreach (QChart *chart, charts()) { | |
155 |
|
||||
156 | QRectF geometryRect = chart->geometry(); |
|
149 | QRectF geometryRect = chart->geometry(); | |
157 | QRectF plotArea = chart->plotArea(); |
|
150 | QRectF plotArea = chart->plotArea(); | |
158 | plotArea.translate(geometryRect.topLeft()); |
|
151 | plotArea.translate(geometryRect.topLeft()); | |
@@ -181,11 +174,9 void Grid::mouseMoveEvent(QGraphicsSceneMouseEvent *event) | |||||
181 | if (m_currentState != NoState) { |
|
174 | if (m_currentState != NoState) { | |
182 |
|
175 | |||
183 | foreach (QChart *chart, charts()) { |
|
176 | foreach (QChart *chart, charts()) { | |
184 |
|
||||
185 | QRectF geometryRect = chart->geometry(); |
|
177 | QRectF geometryRect = chart->geometry(); | |
186 | QRectF plotArea = chart->plotArea(); |
|
178 | QRectF plotArea = chart->plotArea(); | |
187 | plotArea.translate(geometryRect.topLeft()); |
|
179 | plotArea.translate(geometryRect.topLeft()); | |
188 |
|
||||
189 | if (plotArea.contains(m_origin)) { |
|
180 | if (plotArea.contains(m_origin)) { | |
190 | if (m_currentState == ScrollState) { |
|
181 | if (m_currentState == ScrollState) { | |
191 | QPointF delta = m_origin - event->pos(); |
|
182 | QPointF delta = m_origin - event->pos(); | |
@@ -209,11 +200,9 void Grid::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) | |||||
209 | m_rubberBand->setVisible(false); |
|
200 | m_rubberBand->setVisible(false); | |
210 |
|
201 | |||
211 | foreach (QChart *chart, charts()) { |
|
202 | foreach (QChart *chart, charts()) { | |
212 |
|
||||
213 | QRectF geometryRect = chart->geometry(); |
|
203 | QRectF geometryRect = chart->geometry(); | |
214 | QRectF plotArea = chart->plotArea(); |
|
204 | QRectF plotArea = chart->plotArea(); | |
215 | plotArea.translate(geometryRect.topLeft()); |
|
205 | plotArea.translate(geometryRect.topLeft()); | |
216 |
|
||||
217 | if (plotArea.contains(m_origin)) { |
|
206 | if (plotArea.contains(m_origin)) { | |
218 | QRectF rect = m_rubberBand->rect(); |
|
207 | QRectF rect = m_rubberBand->rect(); | |
219 | rect.translate(-geometryRect.topLeft()); |
|
208 | rect.translate(-geometryRect.topLeft()); | |
@@ -222,20 +211,16 void Grid::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) | |||||
222 | } |
|
211 | } | |
223 | } |
|
212 | } | |
224 | } |
|
213 | } | |
225 |
|
||||
226 | m_currentState = NoState; |
|
214 | m_currentState = NoState; | |
227 | event->accept(); |
|
215 | event->accept(); | |
228 | } |
|
216 | } | |
229 |
|
217 | |||
230 | if (event->button() == Qt::RightButton) { |
|
218 | if (event->button() == Qt::RightButton) { | |
231 |
|
||||
232 | if (m_currentState == ZoomState) { |
|
219 | if (m_currentState == ZoomState) { | |
233 | foreach (QChart *chart, charts()) { |
|
220 | foreach (QChart *chart, charts()) { | |
234 |
|
||||
235 | QRectF geometryRect = chart->geometry(); |
|
221 | QRectF geometryRect = chart->geometry(); | |
236 | QRectF plotArea = chart->plotArea(); |
|
222 | QRectF plotArea = chart->plotArea(); | |
237 | plotArea.translate(geometryRect.topLeft()); |
|
223 | plotArea.translate(geometryRect.topLeft()); | |
238 |
|
||||
239 | if (plotArea.contains(m_origin)) { |
|
224 | if (plotArea.contains(m_origin)) { | |
240 | chart->zoomOut(); |
|
225 | chart->zoomOut(); | |
241 | break; |
|
226 | break; |
@@ -39,8 +39,10 class Grid : public QGraphicsWidget | |||||
39 | Q_OBJECT |
|
39 | Q_OBJECT | |
40 | public: |
|
40 | public: | |
41 | enum State { NoState = 0, ZoomState, ScrollState}; |
|
41 | enum State { NoState = 0, ZoomState, ScrollState}; | |
|
42 | ||||
42 |
Grid(int size |
|
43 | Grid(int size, QGraphicsItem *parent = 0); | |
43 | ~Grid(); |
|
44 | ~Grid(); | |
|
45 | ||||
44 | QList<QChart*> charts(); |
|
46 | QList<QChart *> charts(); | |
45 |
void createCharts(const QString& |
|
47 | void createCharts(const QString &category = QString()); | |
46 |
void replaceChart(QChart* |
|
48 | void replaceChart(QChart *oldChart, Chart *newChart); | |
@@ -49,14 +51,18 public: | |||||
49 |
void setRubberPen(const QPen& |
|
51 | void setRubberPen(const QPen &pen); | |
50 | void setSize(int size); |
|
52 | void setSize(int size); | |
51 | int size() const {return m_size;} |
|
53 | int size() const {return m_size;} | |
52 | Q_SIGNAL |
|
54 | ||
|
55 | Q_SIGNALS: | |||
53 |
void chartSelected(QChart* |
|
56 | void chartSelected(QChart *chart); | |
|
57 | ||||
54 | protected: |
|
58 | protected: | |
55 | void mousePressEvent(QGraphicsSceneMouseEvent *event); |
|
59 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | |
56 | void mouseMoveEvent(QGraphicsSceneMouseEvent *event); |
|
60 | void mouseMoveEvent(QGraphicsSceneMouseEvent *event); | |
57 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); |
|
61 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); | |
|
62 | ||||
58 | private: |
|
63 | private: | |
59 | void clear(); |
|
64 | void clear(); | |
|
65 | ||||
60 | private: |
|
66 | private: | |
61 | int m_listCount; |
|
67 | int m_listCount; | |
62 | int m_valueMax; |
|
68 | int m_valueMax; |
@@ -34,19 +34,17 QVariantHash parseArgs(QStringList args) | |||||
34 |
|
34 | |||
35 | if (args.isEmpty() || args.first().startsWith("--")) { |
|
35 | if (args.isEmpty() || args.first().startsWith("--")) { | |
36 | parameters[param] = true; |
|
36 | parameters[param] = true; | |
37 | } |
|
37 | } else { | |
38 | else { |
|
|||
39 |
|
||||
40 | QString value = args.takeFirst(); |
|
38 | QString value = args.takeFirst(); | |
41 | if (value == "true" || value == "on" || value == "enabled") { |
|
39 | if (value == "true" || value == "on" || value == "enabled") { | |
42 | parameters[param] = true; |
|
40 | parameters[param] = true; | |
43 | } |
|
41 | } else if (value == "false" || value == "off" || value == "disable") { | |
44 | else if (value == "false" || value == "off" || value == "disable") { |
|
|||
45 | parameters[param] = false; |
|
42 | parameters[param] = false; | |
46 | } |
|
43 | } else { | |
47 | else { |
|
44 | if (value.endsWith('"')) | |
48 |
|
|
45 | value.chop(1); | |
49 |
if(value.startsWith( |
|
46 | if (value.startsWith('"')) | |
|
47 | value.remove(0, 1); | |||
50 | parameters[param] = value; |
|
48 | parameters[param] = value; | |
51 | } |
|
49 | } | |
52 | } |
|
50 | } |
@@ -41,8 +41,8 | |||||
41 | #include <QMenu> |
|
41 | #include <QMenu> | |
42 | #include <QPushButton> |
|
42 | #include <QPushButton> | |
43 |
|
43 | |||
44 |
Window::Window(const QVariantHash& |
|
44 | Window::Window(const QVariantHash ¶meters, QWidget *parent) | |
45 | QMainWindow(parent), |
|
45 | : QMainWindow(parent), | |
46 | m_scene(new QGraphicsScene(this)), |
|
46 | m_scene(new QGraphicsScene(this)), | |
47 | m_view(0), |
|
47 | m_view(0), | |
48 | m_form(0), |
|
48 | m_form(0), | |
@@ -258,7 +258,6 void Window::initializeFromParamaters(const QVariantHash& parameters) | |||||
258 |
|
|
258 | int t = parameters["view"].toInt(); | |
259 |
|
|
259 | for (int i = 0; i < m_viewComboBox->count(); ++i) { | |
260 |
|
|
260 | if (m_viewComboBox->itemData(i).toInt() == t) { | |
261 |
|
||||
262 |
|
|
261 | m_viewComboBox->setCurrentIndex(i); | |
263 |
|
|
262 | break; | |
264 |
|
|
263 | } | |
@@ -415,7 +414,8 void Window::comboBoxFocused(QComboBox *combobox) | |||||
415 |
|
414 | |||
416 | void Window::handleChartSelected(QChart *qchart) |
|
415 | void Window::handleChartSelected(QChart *qchart) | |
417 | { |
|
416 | { | |
418 |
if(m_templateComboBox->currentIndex() != 0) |
|
417 | if (m_templateComboBox->currentIndex() != 0) | |
|
418 | return; | |||
419 |
|
419 | |||
420 | QAction *chosen = m_menu->exec(QCursor::pos()); |
|
420 | QAction *chosen = m_menu->exec(QCursor::pos()); | |
421 |
|
421 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
General Comments 0
You need to be logged in to leave comments.
Login now