Skip to content

Commit c43a173

Browse files
committedAug 7, 2017
Add a clear all guides button to guide manager
1 parent 33aa352 commit c43a173

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed
 

‎src/app/layout/qgslayoutguidewidget.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ QgsLayoutGuideWidget::QgsLayoutGuideWidget( QWidget *parent, QgsLayout *layout,
5151
connect( mDeleteHozGuideButton, &QPushButton::clicked, this, &QgsLayoutGuideWidget::deleteHorizontalGuide );
5252
connect( mDeleteVertGuideButton, &QPushButton::clicked, this, &QgsLayoutGuideWidget::deleteVerticalGuide );
5353

54+
connect( mClearAllButton, &QPushButton::clicked, this, &QgsLayoutGuideWidget::clearAll );
55+
5456
connect( layoutView, &QgsLayoutView::pageChanged, this, &QgsLayoutGuideWidget::pageChanged );
5557
pageChanged( 0 );
5658
}
@@ -110,6 +112,22 @@ void QgsLayoutGuideWidget::pageChanged( int page )
110112
mPageLabel->setText( tr( "Guides for page %1" ).arg( page + 1 ) );
111113
}
112114

115+
void QgsLayoutGuideWidget::clearAll()
116+
{
117+
// qt - y u no do this for me?
118+
Q_FOREACH ( const QModelIndex &index, mHozGuidesTableView->selectionModel()->selectedIndexes() )
119+
{
120+
mHozGuidesTableView->closePersistentEditor( index );
121+
}
122+
Q_FOREACH ( const QModelIndex &index, mVertGuidesTableView->selectionModel()->selectedIndexes() )
123+
{
124+
mVertGuidesTableView->closePersistentEditor( index );
125+
}
126+
127+
mVertProxyModel->removeRows( 0, mVertProxyModel->rowCount() );
128+
mHozProxyModel->removeRows( 0, mHozProxyModel->rowCount() );
129+
}
130+
113131

114132
QgsLayoutGuidePositionDelegate::QgsLayoutGuidePositionDelegate( QgsLayout *layout, QAbstractItemModel *model )
115133
: mLayout( layout )

‎src/app/layout/qgslayoutguidewidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class QgsLayoutGuideWidget: public QgsPanelWidget, private Ui::QgsLayoutGuideWid
4242

4343
void pageChanged( int page );
4444

45+
void clearAll();
46+
4547
private:
4648

4749
QgsLayout *mLayout = nullptr;

‎src/ui/layout/qgslayoutguidewidgetbase.ui

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>377</width>
10-
<height>629</height>
9+
<width>231</width>
10+
<height>518</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -54,8 +54,8 @@
5454
<rect>
5555
<x>0</x>
5656
<y>0</y>
57-
<width>349</width>
58-
<height>675</height>
57+
<width>231</width>
58+
<height>518</height>
5959
</rect>
6060
</property>
6161
<layout class="QVBoxLayout" name="verticalLayout_2">
@@ -103,6 +103,12 @@
103103
</item>
104104
<item row="0" column="0" colspan="2">
105105
<widget class="QTableView" name="mHozGuidesTableView">
106+
<property name="minimumSize">
107+
<size>
108+
<width>0</width>
109+
<height>120</height>
110+
</size>
111+
</property>
106112
<property name="selectionBehavior">
107113
<enum>QAbstractItemView::SelectRows</enum>
108114
</property>
@@ -160,6 +166,12 @@
160166
</item>
161167
<item row="0" column="0" colspan="2">
162168
<widget class="QTableView" name="mVertGuidesTableView">
169+
<property name="minimumSize">
170+
<size>
171+
<width>0</width>
172+
<height>120</height>
173+
</size>
174+
</property>
163175
<property name="selectionBehavior">
164176
<enum>QAbstractItemView::SelectRows</enum>
165177
</property>
@@ -180,6 +192,13 @@
180192
</layout>
181193
</widget>
182194
</item>
195+
<item>
196+
<widget class="QPushButton" name="mClearAllButton">
197+
<property name="text">
198+
<string>Clear All Guides</string>
199+
</property>
200+
</widget>
201+
</item>
183202
<item>
184203
<spacer name="verticalSpacer">
185204
<property name="orientation">

0 commit comments

Comments
 (0)
Please sign in to comment.