FlowGraphNodeWidget.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #ifndef FLOWGRAPHNODEWIDGET_H
  2. #define FLOWGRAPHNODEWIDGET_H
  3. #include <QWidget>
  4. class QLabel;
  5. class QCheckBox;
  6. class QComboBox;
  7. class QSpinBox;
  8. class QVBoxLayout;
  9. class FlowGraphNodeWidget : public QWidget
  10. {
  11. Q_OBJECT
  12. public:
  13. enum NodeWidgetType
  14. {
  15. Plain,
  16. CheckBox,
  17. ComboBox,
  18. SpinBox,
  19. };
  20. explicit FlowGraphNodeWidget(NodeWidgetType type, QWidget *parent = nullptr);
  21. NodeWidgetType type() const;
  22. signals:
  23. protected:
  24. NodeWidgetType m_type = Plain;
  25. QVBoxLayout *m_layout = nullptr;
  26. };
  27. class FlowGraphPlainNodeWidget : public FlowGraphNodeWidget
  28. {
  29. Q_OBJECT
  30. public:
  31. explicit FlowGraphPlainNodeWidget(QWidget *parent = nullptr);
  32. void setText(const QString text);
  33. private:
  34. QLabel *m_label = nullptr;
  35. };
  36. class FlowGraphCheckNodeWidget : public FlowGraphNodeWidget
  37. {
  38. Q_OBJECT
  39. public:
  40. explicit FlowGraphCheckNodeWidget(QWidget *parent = nullptr);
  41. private:
  42. QCheckBox *m_checkBox = nullptr;
  43. };
  44. class FlowGraphComboNodeWidget : public FlowGraphNodeWidget
  45. {
  46. Q_OBJECT
  47. public:
  48. explicit FlowGraphComboNodeWidget(QWidget *parent = nullptr);
  49. QList<QString> items() const;
  50. void setItems(QList<QString> items);
  51. private:
  52. QComboBox *m_combo = nullptr;
  53. QList<QString> m_items;
  54. };
  55. class FlowGraphSpinNodeWidget : public FlowGraphNodeWidget
  56. {
  57. Q_OBJECT
  58. public:
  59. explicit FlowGraphSpinNodeWidget(QWidget *parent = nullptr);
  60. private:
  61. QSpinBox *m_spinBox = nullptr;
  62. };
  63. #include <SchemePlanManager.h>
  64. class FlowGraphCommonNodeWidget : public QWidget
  65. {
  66. Q_OBJECT
  67. public:
  68. explicit FlowGraphCommonNodeWidget(QWidget *parent = nullptr);
  69. SchemePlanManager::SchemeProcessInfo process() const;
  70. void setProcess(SchemePlanManager::SchemeProcessInfo &i);
  71. void setProcessId(int id);
  72. bool isTitleHidden() const;
  73. void setAllowEdit(bool allow);
  74. signals:
  75. void sigProcessEdited(SchemePlanManager::SchemeProcessInfo process);
  76. protected:
  77. void initWidget();
  78. void connectSignalsAndSlots();
  79. void loadInfo();
  80. QString title() const;
  81. QList<SchemePlanManager::Algorithm> optionalAlgs() const;
  82. QList<SchemePlanManager::SchemeDataSource> optionaldSource() const;
  83. bool isOptional() const;
  84. protected slots:
  85. void slotAlgComboChanged(int index);
  86. void slotDataComboChanged(int index);
  87. void slotSpinBoxChanged(int value);
  88. void slotCheckBoxChanged();
  89. private:
  90. SchemePlanManager::SchemeProcessInfo m_process;
  91. QLabel *m_label = nullptr;
  92. QComboBox *m_algCombo = nullptr;
  93. QComboBox *m_dataCombo = nullptr;
  94. QSpinBox *m_spinBox = nullptr;
  95. QCheckBox *m_checkBox = nullptr;
  96. QVBoxLayout *m_layout = nullptr;
  97. bool m_isLoaded = false;
  98. bool m_allowEdit = true;
  99. };
  100. #endif // FLOWGRAPHNODEWIDGET_H