@@ -57,15 +57,11 void Grid::createCharts(const QString &category) | |||||
57 |
|
57 | |||
58 | if (category.isEmpty()) { |
|
58 | if (category.isEmpty()) { | |
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 = |
|
60 | QChart *chart = new QChart(); | |
61 | if (i < list.size()) { |
|
61 | chart->setTitle(QObject::tr("Empty")); | |
62 | chart = list.at(i)->createChart(m_dataTable); |
|
|||
63 | } else { |
|
|||
64 | chart = new QChart(); |
|
|||
65 | chart->setTitle(QObject::tr("Empty")); |
|
|||
66 | } |
|
|||
67 | m_gridLayout->addItem(chart, i / m_size, i % m_size); |
|
62 | m_gridLayout->addItem(chart, i / m_size, i % m_size); | |
68 | m_chartHash[chart] = i; |
|
63 | m_chartHash[chart] = i; | |
|
64 | m_chartHashRev[i] = chart; | |||
69 | } |
|
65 | } | |
70 | } else { |
|
66 | } else { | |
71 | int j = 0; |
|
67 | int j = 0; | |
@@ -75,6 +71,7 void Grid::createCharts(const QString &category) | |||||
75 | qchart = list.at(i)->createChart(m_dataTable); |
|
71 | qchart = list.at(i)->createChart(m_dataTable); | |
76 | m_gridLayout->addItem(qchart, j / m_size, j % m_size); |
|
72 | m_gridLayout->addItem(qchart, j / m_size, j % m_size); | |
77 | m_chartHash[qchart] = j; |
|
73 | m_chartHash[qchart] = j; | |
|
74 | m_chartHashRev[j] = qchart; | |||
78 | j++; |
|
75 | j++; | |
79 | } |
|
76 | } | |
80 | } |
|
77 | } | |
@@ -83,19 +80,58 void Grid::createCharts(const QString &category) | |||||
83 | qchart->setTitle(QObject::tr("Empty")); |
|
80 | qchart->setTitle(QObject::tr("Empty")); | |
84 | m_gridLayout->addItem(qchart, j / m_size, j % m_size); |
|
81 | m_gridLayout->addItem(qchart, j / m_size, j % m_size); | |
85 | m_chartHash[qchart] = j; |
|
82 | m_chartHash[qchart] = j; | |
|
83 | m_chartHashRev[j] = qchart; | |||
86 | } |
|
84 | } | |
87 | } |
|
85 | } | |
88 | m_category = category; |
|
86 | m_gridLayout->activate(); | |
|
87 | } | |||
|
88 | ||||
|
89 | void Grid::createCharts(const QString &category, const QString &subcategory, const QString &name) | |||
|
90 | { | |||
|
91 | clear(); | |||
|
92 | ||||
|
93 | QChart *qchart(0); | |||
|
94 | Charts::ChartList list = Charts::chartList(); | |||
|
95 | Chart *chart; | |||
|
96 | ||||
|
97 | //find chart | |||
|
98 | for (int i = 0; i < list.size(); ++i) { | |||
|
99 | ||||
|
100 | chart = list.at(i); | |||
|
101 | if (chart->category() == category && | |||
|
102 | chart->subCategory() == subcategory && | |||
|
103 | chart->name() == name) { | |||
|
104 | break; | |||
|
105 | } | |||
|
106 | chart = 0; | |||
|
107 | } | |||
|
108 | ||||
|
109 | //create charts | |||
|
110 | for (int j = 0; j < m_size * m_size; ++j) { | |||
|
111 | ||||
|
112 | if(!chart){ | |||
|
113 | qchart = new QChart(); | |||
|
114 | }else{ | |||
|
115 | qchart = chart->createChart(m_dataTable); | |||
|
116 | } | |||
|
117 | qchart->setTitle(QObject::tr("Empty")); | |||
|
118 | m_gridLayout->addItem(qchart, j / m_size, j % m_size); | |||
|
119 | m_chartHash[qchart] = j; | |||
|
120 | m_chartHashRev[j] = qchart; | |||
|
121 | } | |||
|
122 | ||||
89 | m_gridLayout->activate(); |
|
123 | m_gridLayout->activate(); | |
90 | } |
|
124 | } | |
91 |
|
125 | |||
92 | void Grid::clear() |
|
126 | void Grid::clear() | |
93 | { |
|
127 | { | |
94 |
|
|
128 | int count = m_gridLayout->count(); | |
95 | m_gridLayout->removeAt(i); |
|
129 | for (int i = 0; i < count; ++i) | |
|
130 | m_gridLayout->removeAt(0); | |||
96 |
|
131 | |||
97 | qDeleteAll(m_chartHash.keys()); |
|
132 | qDeleteAll(m_chartHash.keys()); | |
98 | m_chartHash.clear(); |
|
133 | m_chartHash.clear(); | |
|
134 | m_chartHashRev.clear(); | |||
99 | } |
|
135 | } | |
100 |
|
136 | |||
101 | QList<QChart *> Grid::charts() |
|
137 | QList<QChart *> Grid::charts() | |
@@ -111,8 +147,40 void Grid::setState(State state) | |||||
111 | void Grid::setSize(int size) |
|
147 | void Grid::setSize(int size) | |
112 | { |
|
148 | { | |
113 | if (m_size != size) { |
|
149 | if (m_size != size) { | |
|
150 | ||||
|
151 | //remove old; | |||
|
152 | int count = m_gridLayout->count(); | |||
|
153 | for (int i = 0; i < count; ++i) { | |||
|
154 | m_gridLayout->removeAt(0); | |||
|
155 | } | |||
|
156 | ||||
|
157 | ||||
|
158 | QChart* qchart = 0; | |||
|
159 | int j = 0; | |||
|
160 | ||||
|
161 | for (; j < size * size; ++j) { | |||
|
162 | ||||
|
163 | qchart = m_chartHashRev[j]; | |||
|
164 | ||||
|
165 | if (!qchart){ | |||
|
166 | qchart = new QChart(); | |||
|
167 | qchart->setTitle(QObject::tr("Empty")); | |||
|
168 | } | |||
|
169 | ||||
|
170 | m_chartHash[qchart] = j; | |||
|
171 | m_chartHashRev[j] = qchart; | |||
|
172 | m_gridLayout->addItem(qchart, j / size, j % size); | |||
|
173 | } | |||
|
174 | ||||
|
175 | //delete rest | |||
|
176 | while (j < m_size * m_size) { | |||
|
177 | QChart* qchart = m_chartHashRev.take(j); | |||
|
178 | delete(qchart); | |||
|
179 | m_chartHash.remove(qchart); | |||
|
180 | j++; | |||
|
181 | } | |||
|
182 | ||||
114 | m_size = size; |
|
183 | m_size = size; | |
115 | createCharts(m_category); |
|
|||
116 | } |
|
184 | } | |
117 | } |
|
185 | } | |
118 |
|
186 | |||
@@ -132,9 +200,11 void Grid::replaceChart(QChart *oldChart, Chart *newChart) | |||||
132 | } |
|
200 | } | |
133 | } |
|
201 | } | |
134 | m_chartHash.remove(oldChart); |
|
202 | m_chartHash.remove(oldChart); | |
|
203 | m_chartHashRev.remove(index); | |||
135 | QChart *chart = newChart->createChart(m_dataTable); |
|
204 | QChart *chart = newChart->createChart(m_dataTable); | |
136 | m_gridLayout->addItem(chart, index / m_size, index % m_size); |
|
205 | m_gridLayout->addItem(chart, index / m_size, index % m_size); | |
137 | m_chartHash[chart] = index; |
|
206 | m_chartHash[chart] = index; | |
|
207 | m_chartHashRev[index] = chart; | |||
138 | delete oldChart; |
|
208 | delete oldChart; | |
139 | } |
|
209 | } | |
140 |
|
210 |
@@ -45,6 +45,7 public: | |||||
45 |
|
45 | |||
46 | QList<QChart *> charts(); |
|
46 | QList<QChart *> charts(); | |
47 | void createCharts(const QString &category = QString()); |
|
47 | void createCharts(const QString &category = QString()); | |
|
48 | void createCharts(const QString &category, const QString &subcategory, const QString &name); | |||
48 | void replaceChart(QChart *oldChart, Chart *newChart); |
|
49 | void replaceChart(QChart *oldChart, Chart *newChart); | |
49 | void setState(State state); |
|
50 | void setState(State state); | |
50 | State state() const { return m_state; }; |
|
51 | State state() const { return m_state; }; | |
@@ -70,12 +71,12 private: | |||||
70 | int m_size; |
|
71 | int m_size; | |
71 | DataTable m_dataTable; |
|
72 | DataTable m_dataTable; | |
72 | QHash<QChart *, int> m_chartHash; |
|
73 | QHash<QChart *, int> m_chartHash; | |
|
74 | QHash<int, QChart *> m_chartHashRev; | |||
73 | State m_state; |
|
75 | State m_state; | |
74 | State m_currentState; |
|
76 | State m_currentState; | |
75 | QPointF m_origin; |
|
77 | QPointF m_origin; | |
76 | QGraphicsRectItem *m_rubberBand; |
|
78 | QGraphicsRectItem *m_rubberBand; | |
77 | QGraphicsGridLayout *m_gridLayout; |
|
79 | QGraphicsGridLayout *m_gridLayout; | |
78 | QString m_category; |
|
|||
79 | }; |
|
80 | }; | |
80 |
|
81 | |||
81 | #endif /* GRID_H_ */ |
|
82 | #endif /* GRID_H_ */ |
@@ -58,7 +58,7 Window::Window(const QVariantHash ¶meters, QWidget *parent) | |||||
58 | m_baseLayout(new QGraphicsLinearLayout()), |
|
58 | m_baseLayout(new QGraphicsLinearLayout()), | |
59 | m_menu(createMenu()), |
|
59 | m_menu(createMenu()), | |
60 | m_template(0), |
|
60 | m_template(0), | |
61 | m_grid(new Grid(1)) |
|
61 | m_grid(new Grid(-1)) | |
62 | { |
|
62 | { | |
63 | createProxyWidgets(); |
|
63 | createProxyWidgets(); | |
64 | // create layout |
|
64 | // create layout | |
@@ -82,8 +82,6 Window::Window(const QVariantHash ¶meters, QWidget *parent) | |||||
82 | settingsLayout->addItem(m_widgetHash["zoomCheckBox"]); |
|
82 | settingsLayout->addItem(m_widgetHash["zoomCheckBox"]); | |
83 | settingsLayout->addStretch(); |
|
83 | settingsLayout->addStretch(); | |
84 |
|
84 | |||
85 | m_grid->createCharts(); |
|
|||
86 |
|
||||
87 | m_baseLayout->setOrientation(Qt::Horizontal); |
|
85 | m_baseLayout->setOrientation(Qt::Horizontal); | |
88 | m_baseLayout->addItem(m_grid); |
|
86 | m_baseLayout->addItem(m_grid); | |
89 | m_baseLayout->addItem(settingsLayout); |
|
87 | m_baseLayout->addItem(settingsLayout); | |
@@ -99,6 +97,10 Window::Window(const QVariantHash ¶meters, QWidget *parent) | |||||
99 | m_antialiasCheckBox->setChecked(true); |
|
97 | m_antialiasCheckBox->setChecked(true); | |
100 | initializeFromParamaters(parameters); |
|
98 | initializeFromParamaters(parameters); | |
101 | updateUI(); |
|
99 | updateUI(); | |
|
100 | if(!m_category.isEmpty() && !m_subcategory.isEmpty() && !m_name.isEmpty()) | |||
|
101 | m_grid->createCharts(m_category,m_subcategory,m_name); | |||
|
102 | ||||
|
103 | ||||
102 | handleGeometryChanged(); |
|
104 | handleGeometryChanged(); | |
103 | setCentralWidget(m_view); |
|
105 | setCentralWidget(m_view); | |
104 |
|
106 | |||
@@ -214,12 +216,34 QComboBox *Window::createTempleteBox() | |||||
214 |
|
216 | |||
215 | void Window::initializeFromParamaters(const QVariantHash ¶meters) |
|
217 | void Window::initializeFromParamaters(const QVariantHash ¶meters) | |
216 | { |
|
218 | { | |
|
219 | if (parameters.contains("view")) { | |||
|
220 | int t = parameters["view"].toInt(); | |||
|
221 | for (int i = 0; i < m_viewComboBox->count(); ++i) { | |||
|
222 | if (m_viewComboBox->itemData(i).toInt() == t) { | |||
|
223 | m_viewComboBox->setCurrentIndex(i); | |||
|
224 | break; | |||
|
225 | } | |||
|
226 | } | |||
|
227 | } | |||
|
228 | ||||
217 | if (parameters.contains("chart")) { |
|
229 | if (parameters.contains("chart")) { | |
218 | QString t = parameters["chart"].toString(); |
|
230 | QString t = parameters["chart"].toString(); | |
219 | for (int i = 0; i < m_templateComboBox->count(); ++i) { |
|
231 | ||
220 | if (m_templateComboBox->itemText(i) == t) { |
|
232 | QRegExp rx("([a-zA-Z0-9_]*)::([a-zA-Z0-9_]*)::([a-zA-Z0-9_]*)"); | |
221 | m_templateComboBox->setCurrentIndex(i); |
|
233 | int pos = rx.indexIn(t); | |
222 | break; |
|
234 | ||
|
235 | if (pos > -1) { | |||
|
236 | m_category = rx.cap(1); | |||
|
237 | m_subcategory = rx.cap(2); | |||
|
238 | m_name = rx.cap(3); | |||
|
239 | m_templateComboBox->setCurrentIndex(0); | |||
|
240 | } | |||
|
241 | else { | |||
|
242 | for (int i = 0; i < m_templateComboBox->count(); ++i) { | |||
|
243 | if (m_templateComboBox->itemText(i) == t) { | |||
|
244 | m_templateComboBox->setCurrentIndex(i); | |||
|
245 | break; | |||
|
246 | } | |||
223 | } |
|
247 | } | |
224 | } |
|
248 | } | |
225 | } |
|
249 | } | |
@@ -254,21 +278,12 void Window::initializeFromParamaters(const QVariantHash ¶meters) | |||||
254 | } |
|
278 | } | |
255 | } |
|
279 | } | |
256 | } |
|
280 | } | |
257 | if (parameters.contains("view")) { |
|
|||
258 | int t = parameters["view"].toInt(); |
|
|||
259 | for (int i = 0; i < m_viewComboBox->count(); ++i) { |
|
|||
260 | if (m_viewComboBox->itemData(i).toInt() == t) { |
|
|||
261 | m_viewComboBox->setCurrentIndex(i); |
|
|||
262 | break; |
|
|||
263 | } |
|
|||
264 | } |
|
|||
265 | } |
|
|||
266 | } |
|
281 | } | |
267 |
|
282 | |||
268 | void Window::updateUI() |
|
283 | void Window::updateUI() | |
269 | { |
|
284 | { | |
270 | checkTemplate(); |
|
|||
271 | checkView(); |
|
285 | checkView(); | |
|
286 | checkTemplate(); | |||
272 | checkOpenGL(); |
|
287 | checkOpenGL(); | |
273 | checkTheme(); |
|
288 | checkTheme(); | |
274 | checkAnimationOptions(); |
|
289 | checkAnimationOptions(); | |
@@ -279,7 +294,10 void Window::updateUI() | |||||
279 | void Window::checkView() |
|
294 | void Window::checkView() | |
280 | { |
|
295 | { | |
281 | int count(m_viewComboBox->itemData(m_viewComboBox->currentIndex()).toInt()); |
|
296 | int count(m_viewComboBox->itemData(m_viewComboBox->currentIndex()).toInt()); | |
282 |
m_grid->s |
|
297 | if(m_grid->size()!=count){ | |
|
298 | m_grid->setSize(count); | |||
|
299 | m_template = 0; | |||
|
300 | } | |||
283 | } |
|
301 | } | |
284 |
|
302 | |||
285 | void Window::checkLegend() |
|
303 | void Window::checkLegend() |
General Comments 0
You need to be logged in to leave comments.
Login now