|
@@ -152,3 +152,96 @@ void setRateOfChangeProperties(QScriptValue value, QScriptEngine *engine)
|
152
|
152
|
setQObjectProperties(value, engine);
|
153
|
153
|
}
|
154
|
154
|
|
|
155
|
+@ To make use of this feature conveniently, we must integrate this with the
|
|
156
|
+in-program configuration system by providing a configuration widget.
|
|
157
|
+
|
|
158
|
+@<Class declarations@>=
|
|
159
|
+class RateOfChangeConfWidget : public BasicDeviceConfigurationWidget
|
|
160
|
+{
|
|
161
|
+ Q_OBJECT
|
|
162
|
+ public:
|
|
163
|
+ Q_INVOKABLE RateOfChangeConfWidget(DeviceTreeModel *model, const QModelIndex &index);
|
|
164
|
+ private slots:
|
|
165
|
+ void updateColumn(const QString &column);
|
|
166
|
+ void updateCacheTime(const QString &seconds);
|
|
167
|
+ void updateScaleTime(const QString &seconds);
|
|
168
|
+};
|
|
169
|
+
|
|
170
|
+@ The constructor sets up the user interface.
|
|
171
|
+
|
|
172
|
+@<RateOfChangeConfWidget implementation@>=
|
|
173
|
+RateOfChangeConfWidget::RateOfChangeConfWidget(DeviceTreeModel *model, const QModelIndex &index)
|
|
174
|
+: BasicDeviceConfigurationWidget(model, index)
|
|
175
|
+{
|
|
176
|
+ QFormLayout *layout = new QFormLayout;
|
|
177
|
+ QLineEdit *column = new QLineEdit;
|
|
178
|
+ layout->addRow(tr("Primary series column name:"), column);
|
|
179
|
+ QSpinBox *cacheTime = new QSpinBox;
|
|
180
|
+ cacheTime->setMinimum(0);
|
|
181
|
+ cacheTime->setMaximum(300);
|
|
182
|
+ layout->addRow(tr("Cache time:"), cacheTime);
|
|
183
|
+ QSpinBox *scaleTime = new QSpinBox;
|
|
184
|
+ scaleTime->setMinimum(1);
|
|
185
|
+ scaleTime->setMaximum(300);
|
|
186
|
+ layout->addRow(tr("Scale time:"), scaleTime);
|
|
187
|
+ @<Get device configuration data for current node@>@;
|
|
188
|
+ for(int i = 0; i < configData.size(); i++)
|
|
189
|
+ {
|
|
190
|
+ node = configData.at(i).toElement();
|
|
191
|
+ if(node.attribute("name") == "column")
|
|
192
|
+ {
|
|
193
|
+ column->setText(node.attribute("value"));
|
|
194
|
+ }
|
|
195
|
+ else if(node.attribute("name") == "cache")
|
|
196
|
+ {
|
|
197
|
+ cacheTime->setValue(node.attribute("value").toInt());
|
|
198
|
+ }
|
|
199
|
+ else if(node.attribute("name") == "scale")
|
|
200
|
+ {
|
|
201
|
+ scaleTime->setValue(node.attribute("value").toInt());
|
|
202
|
+ }
|
|
203
|
+ }
|
|
204
|
+ updateColumn(column->text());
|
|
205
|
+ updateCacheTime(cacheTime->text());
|
|
206
|
+ updateScaleTime(scaleTime->text());
|
|
207
|
+ connect(column, SIGNAL(textEdited(QString)), this, SLOT(updateColumn(QString)));
|
|
208
|
+ connect(cacheTime, SIGNAL(valueChanged(QString)), this, SLOT(updateCacheTime(QString)));
|
|
209
|
+ connect(scaleTime, SIGNAL(valueChanged(QString)), this, SLOT(updateScaleTime(QString)));
|
|
210
|
+ setLayout(layout);
|
|
211
|
+}
|
|
212
|
+
|
|
213
|
+@ A set of update methods modify the device configuration to reflect changes in
|
|
214
|
+the configuration widget.
|
|
215
|
+
|
|
216
|
+@<RateOfChangeConfWidget implementation@>=
|
|
217
|
+void RateOfChangeConfWidget::updateColumn(const QString &column)
|
|
218
|
+{
|
|
219
|
+ updateAttribute("column", column);
|
|
220
|
+}
|
|
221
|
+
|
|
222
|
+void RateOfChangeConfWidget::updateCacheTime(const QString &seconds)
|
|
223
|
+{
|
|
224
|
+ updateAttribute("cache", seconds);
|
|
225
|
+}
|
|
226
|
+
|
|
227
|
+void RateOfChangeConfWidget::updateScaleTime(const QString &seconds)
|
|
228
|
+{
|
|
229
|
+ updateAttribute("scale", seconds);
|
|
230
|
+}
|
|
231
|
+
|
|
232
|
+@ This is registered with the configuration system.
|
|
233
|
+
|
|
234
|
+@<Register device configuration widgets@>=
|
|
235
|
+app.registerDeviceConfigurationWidget("rate", RateOfChangeConfWidget::staticMetaObject);
|
|
236
|
+
|
|
237
|
+@ This is accessed through the advanced features menu.
|
|
238
|
+
|
|
239
|
+@<Add node inserters to advanced features menu@>=
|
|
240
|
+NodeInserter *rateOfChangeInserter = new NodeInserter(tr("Rate of Change"), tr("Rate of Change"), "rate");
|
|
241
|
+connect(rateOfChangeInserter, SIGNAL(triggered(QString, QString)), this, SLOT(insertChildNode(QString, QString)));
|
|
242
|
+advancedMenu->addAction(rateOfChangeInserter);
|
|
243
|
+
|
|
244
|
+@ Our class implementation is currently expanded into |"typica.cpp"|.
|
|
245
|
+
|
|
246
|
+@<Class implementations@>=
|
|
247
|
+@<RateOfChangeConfWidget implementation@>
|