19 #include <QDialogButtonBox>
31 for (
int i = 0; i < ( vectorPattern.size() - 1 ); ++i )
33 dash = vectorPattern.at( i );
35 space = vectorPattern.at( i );
36 QTreeWidgetItem *entry =
new QTreeWidgetItem();
37 entry->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
38 entry->setText( 0, QString::number( dash ) );
39 entry->setText( 1, QString::number( space ) );
40 mDashSpaceTreeWidget->addTopLevelItem( entry );
43 connect( mAddButton, &QPushButton::clicked,
this, &QgsDashSpaceWidget::mAddButton_clicked );
44 connect( mRemoveButton, &QPushButton::clicked,
this, &QgsDashSpaceWidget::mRemoveButton_clicked );
45 connect( mDashSpaceTreeWidget, &QTreeWidget::itemChanged,
this, [
this ] { emit
widgetChanged(); } );
48 void QgsDashSpaceWidget::mAddButton_clicked()
51 QTreeWidgetItem *entry =
new QTreeWidgetItem();
52 entry->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
53 entry->setText( 0, QStringLiteral(
"5" ) );
54 entry->setText( 1, QStringLiteral(
"2" ) );
55 mDashSpaceTreeWidget->addTopLevelItem( entry );
59 void QgsDashSpaceWidget::mRemoveButton_clicked()
62 QTreeWidgetItem *currentItem = mDashSpaceTreeWidget->currentItem();
65 mDashSpaceTreeWidget->takeTopLevelItem( mDashSpaceTreeWidget->indexOfTopLevelItem( currentItem ) );
72 QVector<qreal> dashVector;
73 int nTopLevelItems = mDashSpaceTreeWidget->topLevelItemCount();
74 for (
int i = 0; i < nTopLevelItems; ++i )
76 QTreeWidgetItem *currentItem = mDashSpaceTreeWidget->topLevelItem( i );
79 dashVector << currentItem->text( 0 ).toDouble() << currentItem->text( 1 ).toDouble();
87 QTreeWidgetItem *headerItem = mDashSpaceTreeWidget->headerItem();
94 QVBoxLayout *vLayout =
new QVBoxLayout();
96 vLayout->addWidget( mWidget );
97 QDialogButtonBox *bbox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal );
98 connect( bbox, &QDialogButtonBox::accepted,
this, &QgsDashSpaceDialog::accept );
99 connect( bbox, &QDialogButtonBox::rejected,
this, &QgsDashSpaceDialog::reject );
100 vLayout->addWidget( bbox );
101 setLayout( vLayout );
102 setWindowTitle( tr(
"Custom Dash Pattern" ) );