Typica is a free program for professional coffee roasters. https://typica.us
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

freeannotation.w 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. @* Free text annotation control configuration.
  2. \noindent Some roasting firms like to be able to provide arbitrary text as an
  3. annotation in addition to or instead of fixed form annotations. There is very
  4. little to configure for an annotation control that facilitates that
  5. functionality. The existence and position of the control is implicit in the
  6. existence of a node representing the control in the configuration. An optional
  7. label next to the control is the only configurable option at present. A
  8. configuration widget and associated registrations to integrate with the
  9. configuration system is still required.
  10. @<Class declarations@>=
  11. class FreeAnnotationConfWidget : public BasicDeviceConfigurationWidget
  12. {
  13. Q_OBJECT
  14. public:
  15. Q_INVOKABLE FreeAnnotationConfWidget(DeviceTreeModel *model, const QModelIndex &index);
  16. private slots:
  17. void updateLabel(const QString &text);
  18. };
  19. @ The constructor should seem familiar by now.
  20. @<FreeAnnotationConfWidget implementation@>=
  21. FreeAnnotationConfWidget::FreeAnnotationConfWidget(DeviceTreeModel *model,
  22. const QModelIndex &index)
  23. : BasicDeviceConfigurationWidget(model, index)
  24. {
  25. QFormLayout *layout = new QFormLayout;
  26. QLineEdit *labelEdit = new QLineEdit;
  27. layout->addRow(tr("Label Text:"), labelEdit);
  28. @<Get device configuration data for current node@>@;
  29. for(int i = 0; i < configData.size(); i++)
  30. {
  31. node = configData.at(i).toElement();
  32. if(node.attribute("name") == "labeltext")
  33. {
  34. labelEdit->setText(node.attribute("value"));
  35. }
  36. }
  37. updateLabel(labelEdit->text());
  38. connect(labelEdit, SIGNAL(textEdited(QString)),
  39. this, SLOT(updateLabel(QString)));
  40. setLayout(layout);
  41. }
  42. @ The update slot is trivial.
  43. @<FreeAnnotationConfWidget implementation@>=
  44. void FreeAnnotationConfWidget::updateLabel(const QString &text)
  45. {
  46. updateAttribute("labeltext", text);
  47. }
  48. @ There is nothing unusual in the control registration.
  49. @<Register device configuration widgets@>=
  50. app.registerDeviceConfigurationWidget("freeannotation",
  51. FreeAnnotationConfWidget::staticMetaObject);