|
@@ -336,10 +336,16 @@ class SerialScaleConfWidget : public BasicDeviceConfigurationWidget
|
336
|
336
|
const QModelIndex &index);
|
337
|
337
|
private slots:
|
338
|
338
|
void updatePort(const QString &newPort);
|
339
|
|
- void updateBaudRate(const QString &newRate);
|
340
|
|
- void updateParity(const QString &newParity);
|
341
|
|
- void updateFlowControl(const QString &newFlow);
|
342
|
|
- void updateStopBits(const QString &newStopBits);
|
|
339
|
+ void updateBaudRate(const QString &rate);
|
|
340
|
+ void updateParity(int index);
|
|
341
|
+ void updateFlowControl(int index);
|
|
342
|
+ void updateStopBits(int index);
|
|
343
|
+ private:
|
|
344
|
+ PortSelector *port;
|
|
345
|
+ BaudSelector *baud;
|
|
346
|
+ ParitySelector *parity;
|
|
347
|
+ FlowSelector *flow;
|
|
348
|
+ StopSelector *stop;
|
343
|
349
|
};
|
344
|
350
|
|
345
|
351
|
@ This is very similar to other configuration widgets.
|
|
@@ -347,31 +353,28 @@ class SerialScaleConfWidget : public BasicDeviceConfigurationWidget
|
347
|
353
|
@<SerialScaleConfWidget implementation@>=
|
348
|
354
|
SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel *model,
|
349
|
355
|
const QModelIndex &index)
|
350
|
|
-: BasicDeviceConfigurationWidget(model, index)
|
|
356
|
+: BasicDeviceConfigurationWidget(model, index),
|
|
357
|
+ port(new PortSelector), baud(new BaudSelector), parity(new ParitySelector),
|
|
358
|
+ flow(new FlowSelector), stop(new StopSelector)
|
351
|
359
|
{
|
352
|
360
|
QFormLayout *layout = new QFormLayout;
|
353
|
|
- PortSelector *port = new PortSelector;
|
354
|
361
|
layout->addRow(tr("Port:"), port);
|
355
|
362
|
connect(port, SIGNAL(currentIndexChanged(QString)),
|
356
|
363
|
this, SLOT(updatePort(QString)));
|
357
|
364
|
connect(port, SIGNAL(editTextChanged(QString)),
|
358
|
365
|
this, SLOT(updatePort(QString)));
|
359
|
|
- BaudSelector *rate = new BaudSelector;
|
360
|
|
- layout->addRow(tr("Baud:"), rate);
|
361
|
|
- connect(rate, SIGNAL(currentIndexChanged(QString)),
|
|
366
|
+ layout->addRow(tr("Baud:"), baud);
|
|
367
|
+ connect(baud, SIGNAL(currentIndexChanged(QString)),
|
362
|
368
|
this, SLOT(updateBaudRate(QString)));
|
363
|
|
- ParitySelector *parity = new ParitySelector;
|
364
|
369
|
layout->addRow(tr("Parity:"), parity);
|
365
|
|
- connect(parity, SIGNAL(currentIndexChanged(QString)),
|
366
|
|
- this, SLOT(updateParity(QString)));
|
367
|
|
- FlowSelector *flow = new FlowSelector;
|
|
370
|
+ connect(parity, SIGNAL(currentIndexChanged(int)),
|
|
371
|
+ this, SLOT(updateParity(int)));
|
368
|
372
|
layout->addRow(tr("Flow Control:"), flow);
|
369
|
|
- connect(flow, SIGNAL(currentIndexChanged(QString)),
|
370
|
|
- this, SLOT(updateFlowControl(QString)));
|
371
|
|
- StopSelector *stop = new StopSelector;
|
|
373
|
+ connect(flow, SIGNAL(currentIndexChanged(int)),
|
|
374
|
+ this, SLOT(updateFlowControl(int)));
|
372
|
375
|
layout->addRow(tr("Stop Bits:"), stop);
|
373
|
|
- connect(stop, SIGNAL(currentIndexChanged(QString)),
|
374
|
|
- this, SLOT(updateStopBits(QString)));
|
|
376
|
+ connect(stop, SIGNAL(currentIndexChanged(int)),
|
|
377
|
+ this, SLOT(updateStopBits(int)));
|
375
|
378
|
@<Get device configuration data for current node@>@;
|
376
|
379
|
for(int i = 0; i < configData.size(); i++)
|
377
|
380
|
{
|
|
@@ -391,26 +394,26 @@ SerialScaleConfWidget::SerialScaleConfWidget(DeviceTreeModel *model,
|
391
|
394
|
}
|
392
|
395
|
else if(node.attribute("name") == "baudrate")
|
393
|
396
|
{
|
394
|
|
- rate->setCurrentIndex(rate->findText(node.attribute("value")));
|
|
397
|
+ baud->setCurrentIndex(baud->findText(node.attribute("value")));
|
395
|
398
|
}
|
396
|
399
|
else if(node.attribute("name") == "parity")
|
397
|
400
|
{
|
398
|
|
- parity->setCurrentIndex(parity->findText(node.attribute("value")));
|
|
401
|
+ parity->setCurrentIndex(parity->findData(node.attribute("value")));
|
399
|
402
|
}
|
400
|
403
|
else if(node.attribute("name") == "flowcontrol")
|
401
|
404
|
{
|
402
|
|
- flow->setCurrentIndex(flow->findText(node.attribute("value")));
|
|
405
|
+ flow->setCurrentIndex(flow->findData(node.attribute("value")));
|
403
|
406
|
}
|
404
|
407
|
else if(node.attribute("name") == "stopbits")
|
405
|
408
|
{
|
406
|
|
- stop->setCurrentIndex(stop->findText(node.attribute("value")));
|
|
409
|
+ stop->setCurrentIndex(stop->findData(node.attribute("value")));
|
407
|
410
|
}
|
408
|
411
|
}
|
409
|
412
|
updatePort(port->currentText());
|
410
|
|
- updateBaudRate(rate->currentText());
|
411
|
|
- updateParity(parity->currentText());
|
412
|
|
- updateFlowControl(flow->currentText());
|
413
|
|
- updateStopBits(stop->currentText());
|
|
413
|
+ updateBaudRate(baud->currentText());
|
|
414
|
+ updateParity(parity->currentIndex());
|
|
415
|
+ updateFlowControl(flow->currentIndex());
|
|
416
|
+ updateStopBits(stop->currentIndex());
|
414
|
417
|
setLayout(layout);
|
415
|
418
|
}
|
416
|
419
|
|
|
@@ -422,24 +425,24 @@ void SerialScaleConfWidget::updatePort(const QString &newPort)
|
422
|
425
|
updateAttribute("port", newPort);
|
423
|
426
|
}
|
424
|
427
|
|
425
|
|
-void SerialScaleConfWidget::updateBaudRate(const QString &newRate)
|
|
428
|
+void SerialScaleConfWidget::updateBaudRate(const QString &rate)
|
426
|
429
|
{
|
427
|
|
- updateAttribute("baudrate", newRate);
|
|
430
|
+ updateAttribute("baudrate", rate);
|
428
|
431
|
}
|
429
|
432
|
|
430
|
|
-void SerialScaleConfWidget::updateParity(const QString &newParity)
|
|
433
|
+void SerialScaleConfWidget::updateParity(int index)
|
431
|
434
|
{
|
432
|
|
- updateAttribute("parity", newParity);
|
|
435
|
+ updateAttribute("parity", parity->itemData(index).toString());
|
433
|
436
|
}
|
434
|
437
|
|
435
|
|
-void SerialScaleConfWidget::updateFlowControl(const QString &newFlow)
|
|
438
|
+void SerialScaleConfWidget::updateFlowControl(int index)
|
436
|
439
|
{
|
437
|
|
- updateAttribute("flowcontrol", newFlow);
|
|
440
|
+ updateAttribute("flowcontrol", flow->itemData(index).toString());
|
438
|
441
|
}
|
439
|
442
|
|
440
|
|
-void SerialScaleConfWidget::updateStopBits(const QString &newStopBits)
|
|
443
|
+void SerialScaleConfWidget::updateStopBits(int index)
|
441
|
444
|
{
|
442
|
|
- updateAttribute("stopbits", newStopBits);
|
|
445
|
+ updateAttribute("stopbits", stop->itemData(index).toString());
|
443
|
446
|
}
|
444
|
447
|
|
445
|
448
|
@ The configuration widget is registered with the configuration system.
|