FlowGraphNodeWidget.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include "FlowGraphNodeWidget.h"
  2. #include <QBoxLayout>
  3. #include <QLabel>
  4. #include <QCheckBox>
  5. #include <QComboBox>
  6. #include <QSpinBox>
  7. FlowGraphNodeWidget::FlowGraphNodeWidget(NodeWidgetType type, QWidget *parent) : QWidget(parent), m_type(type)
  8. {
  9. setFixedSize(QSize(130, 40));
  10. }
  11. FlowGraphNodeWidget::NodeWidgetType FlowGraphNodeWidget::type() const
  12. {
  13. return m_type;
  14. }
  15. FlowGraphPlainNodeWidget::FlowGraphPlainNodeWidget(QWidget *parent) : FlowGraphNodeWidget(Plain, parent)
  16. {
  17. m_label = new QLabel(this);
  18. m_label->setText("test");
  19. m_label->setAlignment(Qt::AlignCenter);
  20. QBoxLayout *l = new QVBoxLayout(this);
  21. l->addWidget(m_label);
  22. }
  23. void FlowGraphPlainNodeWidget::setText(const QString text)
  24. {
  25. m_label->setText(text);
  26. }
  27. FlowGraphCheckNodeWidget::FlowGraphCheckNodeWidget(QWidget *parent) : FlowGraphNodeWidget(CheckBox, parent)
  28. {
  29. m_checkBox = new QCheckBox("执行", this);
  30. QBoxLayout *l = new QVBoxLayout(this);
  31. l->setAlignment(Qt::AlignCenter);
  32. l->addWidget(m_checkBox);
  33. }
  34. FlowGraphComboNodeWidget::FlowGraphComboNodeWidget(QWidget *parent) : FlowGraphNodeWidget(ComboBox, parent)
  35. {
  36. m_combo = new QComboBox(this);
  37. QBoxLayout *l = new QVBoxLayout(this);
  38. l->addWidget(m_combo);
  39. }
  40. QList<QString> FlowGraphComboNodeWidget::items() const
  41. {
  42. return m_items;
  43. }
  44. void FlowGraphComboNodeWidget::setItems(QList<QString> items)
  45. {
  46. m_items = items;
  47. m_combo->clear();
  48. m_combo->addItems(items);
  49. }
  50. FlowGraphSpinNodeWidget::FlowGraphSpinNodeWidget(QWidget *parent) : FlowGraphNodeWidget(SpinBox, parent)
  51. {
  52. m_spinBox = new QSpinBox(this);
  53. m_spinBox->setMinimum(1);
  54. m_spinBox->setMaximum(10);
  55. m_spinBox->setValue(3);
  56. QBoxLayout *l = new QVBoxLayout(this);
  57. l->addWidget(m_spinBox);
  58. }