12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #include "FlowGraphNodeWidget.h"
- #include <QBoxLayout>
- #include <QLabel>
- #include <QCheckBox>
- #include <QComboBox>
- #include <QSpinBox>
- FlowGraphNodeWidget::FlowGraphNodeWidget(NodeWidgetType type, QWidget *parent) : QWidget(parent), m_type(type)
- {
- setFixedSize(QSize(130, 30));
- m_layout = new QVBoxLayout(this);
- m_layout->setMargin(0);
- }
- FlowGraphNodeWidget::NodeWidgetType FlowGraphNodeWidget::type() const
- {
- return m_type;
- }
- FlowGraphPlainNodeWidget::FlowGraphPlainNodeWidget(QWidget *parent) : FlowGraphNodeWidget(Plain, parent)
- {
- m_label = new QLabel(this);
- m_label->setText("test");
- m_label->setAlignment(Qt::AlignCenter);
- m_layout->setMargin(0);
- m_layout->addWidget(m_label);
- }
- void FlowGraphPlainNodeWidget::setText(const QString text)
- {
- m_label->setText(text);
- }
- FlowGraphCheckNodeWidget::FlowGraphCheckNodeWidget(QWidget *parent) : FlowGraphNodeWidget(CheckBox, parent)
- {
- m_checkBox = new QCheckBox("执行", this);
- m_layout->setMargin(0);
- m_layout->setAlignment(Qt::AlignCenter);
- m_layout->addWidget(m_checkBox);
- }
- FlowGraphComboNodeWidget::FlowGraphComboNodeWidget(QWidget *parent) : FlowGraphNodeWidget(ComboBox, parent)
- {
- m_combo = new QComboBox(this);
- setStyleSheet("QComboBox {"
- "border: 1px solid gray;"
- "border-radius: 3px;"
- "padding: 1px 18px 1px 3px;"
- "min-width: 6em;"
- "}"
- "QComboBox:editable {"
- "background: white;"
- "}"
- "QComboBox:!editable, QComboBox::drop-down:editable {"
- "background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
- "stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,"
- "stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);"
- "}");
- m_layout->addWidget(m_combo);
- }
- QList<QString> FlowGraphComboNodeWidget::items() const
- {
- return m_items;
- }
- void FlowGraphComboNodeWidget::setItems(QList<QString> items)
- {
- m_items = items;
- m_combo->clear();
- m_combo->addItems(items);
- }
- FlowGraphSpinNodeWidget::FlowGraphSpinNodeWidget(QWidget *parent) : FlowGraphNodeWidget(SpinBox, parent)
- {
- m_spinBox = new QSpinBox(this);
- m_spinBox->setMinimum(1);
- m_spinBox->setMaximum(10);
- m_spinBox->setValue(3);
- m_layout->addWidget(m_spinBox);
- }
|