20 #include <QDialogButtonBox>
32 for (
int i = 0; i < ( vectorPattern.size() - 1 ); ++i )
34 dash = vectorPattern.at( i );
36 space = vectorPattern.at( i );
37 QTreeWidgetItem *entry =
new QTreeWidgetItem();
38 entry->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
39 entry->setText( 0, QLocale().toString( dash ) );
40 entry->setText( 1, QLocale().toString( space ) );
41 mDashSpaceTreeWidget->addTopLevelItem( entry );
44 connect( mAddButton, &QPushButton::clicked,
this, &QgsDashSpaceWidget::mAddButton_clicked );
45 connect( mRemoveButton, &QPushButton::clicked,
this, &QgsDashSpaceWidget::mRemoveButton_clicked );
46 connect( mDashSpaceTreeWidget, &QTreeWidget::itemChanged,
this, [
this ] { emit
widgetChanged(); } );
49 void QgsDashSpaceWidget::mAddButton_clicked()
52 QTreeWidgetItem *entry =
new QTreeWidgetItem();
53 entry->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
54 entry->setText( 0, QStringLiteral(
"5" ) );
55 entry->setText( 1, QStringLiteral(
"2" ) );
56 mDashSpaceTreeWidget->addTopLevelItem( entry );
60 void QgsDashSpaceWidget::mRemoveButton_clicked()
63 QTreeWidgetItem *currentItem = mDashSpaceTreeWidget->currentItem();
66 mDashSpaceTreeWidget->takeTopLevelItem( mDashSpaceTreeWidget->indexOfTopLevelItem( currentItem ) );
73 QVector<qreal> dashVector;
74 const int nTopLevelItems = mDashSpaceTreeWidget->topLevelItemCount();
75 for (
int i = 0; i < nTopLevelItems; ++i )
77 QTreeWidgetItem *currentItem = mDashSpaceTreeWidget->topLevelItem( i );
88 QTreeWidgetItem *headerItem = mDashSpaceTreeWidget->headerItem();
95 QVBoxLayout *vLayout =
new QVBoxLayout();
97 vLayout->addWidget( mWidget );
98 QDialogButtonBox *bbox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal );
99 connect( bbox, &QDialogButtonBox::accepted,
this, &QgsDashSpaceDialog::accept );
100 connect( bbox, &QDialogButtonBox::rejected,
this, &QgsDashSpaceDialog::reject );
101 vLayout->addWidget( bbox );
102 setLayout( vLayout );
103 setWindowTitle( tr(
"Custom Dash Pattern" ) );
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
QgsDashSpaceDialog(const QVector< qreal > &v, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
Constructor for QgsDashSpaceDialog.
QVector< qreal > dashDotVector() const
Returns the dash pattern as a list of numbers.
void setUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit type used for the dash space pattern (used to update interface labels)
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
static Q_INVOKABLE QString toAbbreviatedString(QgsUnitTypes::DistanceUnit unit)
Returns a translated abbreviation representing a distance unit.
RenderUnit
Rendering size units.