33 mHozProxyModel->setSourceModel( &mLayout->
guides() );
35 mVertProxyModel->setSourceModel( &mLayout->
guides() );
37 mHozGuidesTableView->setModel( mHozProxyModel );
38 mVertGuidesTableView->setModel( mVertProxyModel );
40 mHozGuidesTableView->setEditTriggers( QAbstractItemView::AllEditTriggers );
41 mVertGuidesTableView->setEditTriggers( QAbstractItemView::AllEditTriggers );
49 connect( mAddHozGuideButton, &QPushButton::clicked,
this, &QgsLayoutGuideWidget::addHorizontalGuide );
50 connect( mAddVertGuideButton, &QPushButton::clicked,
this, &QgsLayoutGuideWidget::addVerticalGuide );
52 connect( mDeleteHozGuideButton, &QPushButton::clicked,
this, &QgsLayoutGuideWidget::deleteHorizontalGuide );
53 connect( mDeleteVertGuideButton, &QPushButton::clicked,
this, &QgsLayoutGuideWidget::deleteVerticalGuide );
55 connect( mClearAllButton, &QPushButton::clicked,
this, &QgsLayoutGuideWidget::clearAll );
56 connect( mApplyToAllButton, &QPushButton::clicked,
this, &QgsLayoutGuideWidget::applyToAll );
60 connect( mPageNumberComboBox, qOverload< int >( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
69 void QgsLayoutGuideWidget::addHorizontalGuide()
75 void QgsLayoutGuideWidget::addVerticalGuide()
81 void QgsLayoutGuideWidget::deleteHorizontalGuide()
84 const auto constSelectedIndexes = mHozGuidesTableView->selectionModel()->selectedIndexes();
85 for (
const QModelIndex &index : constSelectedIndexes )
87 mHozGuidesTableView->closePersistentEditor( index );
88 if ( index.column() == 0 )
89 mHozProxyModel->removeRow( index.row() );
94 void QgsLayoutGuideWidget::deleteVerticalGuide()
97 const auto constSelectedIndexes = mVertGuidesTableView->selectionModel()->selectedIndexes();
98 for (
const QModelIndex &index : constSelectedIndexes )
100 mVertGuidesTableView->closePersistentEditor( index );
101 if ( index.column() == 0 )
102 mVertProxyModel->removeRow( index.row() );
114 const auto horizontalSelectedIndexes = mHozGuidesTableView->selectionModel()->selectedIndexes();
115 for (
const QModelIndex &index : horizontalSelectedIndexes )
117 mHozGuidesTableView->closePersistentEditor( index );
119 const auto verticalSelectedIndexes = mVertGuidesTableView->selectionModel()->selectedIndexes();
120 for (
const QModelIndex &index : verticalSelectedIndexes )
122 mVertGuidesTableView->closePersistentEditor( index );
125 mHozProxyModel->
setPage( page );
126 mVertProxyModel->
setPage( page );
128 whileBlocking( mPageNumberComboBox )->setCurrentIndex( page );
131 void QgsLayoutGuideWidget::clearAll()
134 const auto horizontalSelectedIndexes = mHozGuidesTableView->selectionModel()->selectedIndexes();
135 for (
const QModelIndex &index : horizontalSelectedIndexes )
137 mHozGuidesTableView->closePersistentEditor( index );
139 const auto verticalSelectedIndexes = mVertGuidesTableView->selectionModel()->selectedIndexes();
140 for (
const QModelIndex &index : verticalSelectedIndexes )
142 mVertGuidesTableView->closePersistentEditor( index );
146 mVertProxyModel->removeRows( 0, mVertProxyModel->rowCount() );
147 mHozProxyModel->removeRows( 0, mHozProxyModel->rowCount() );
151 void QgsLayoutGuideWidget::applyToAll()
156 void QgsLayoutGuideWidget::updatePageCount()
158 const int prevPage = mPageNumberComboBox->currentIndex();
159 mPageNumberComboBox->clear();
160 for (
int i = 0; i < mLayout->
pageCollection()->pageCount(); ++ i )
161 mPageNumberComboBox->addItem( QString::number( i + 1 ), i );
163 if ( mPageNumberComboBox->count() > prevPage )
164 mPageNumberComboBox->setCurrentIndex( prevPage );
169 : QStyledItemDelegate( parent )
177 spin->setMinimum( 0 );
178 spin->setMaximum( 1000000 );
179 spin->setDecimals( 2 );
181 connect( spin,
static_cast < void (
QgsDoubleSpinBox::* )(
double )
> ( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
double )
196 : QStyledItemDelegate( parent )