#include "FlowGraphNodeWidget.h" #include #include #include #include #include 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 FlowGraphComboNodeWidget::items() const { return m_items; } void FlowGraphComboNodeWidget::setItems(QList 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); }