Skip to content

Commit

Permalink
Add a clear all guides button to guide manager
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 7, 2017
1 parent 33aa352 commit c43a173
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
18 changes: 18 additions & 0 deletions src/app/layout/qgslayoutguidewidget.cpp
Expand Up @@ -51,6 +51,8 @@ QgsLayoutGuideWidget::QgsLayoutGuideWidget( QWidget *parent, QgsLayout *layout,
connect( mDeleteHozGuideButton, &QPushButton::clicked, this, &QgsLayoutGuideWidget::deleteHorizontalGuide );
connect( mDeleteVertGuideButton, &QPushButton::clicked, this, &QgsLayoutGuideWidget::deleteVerticalGuide );

connect( mClearAllButton, &QPushButton::clicked, this, &QgsLayoutGuideWidget::clearAll );

connect( layoutView, &QgsLayoutView::pageChanged, this, &QgsLayoutGuideWidget::pageChanged );
pageChanged( 0 );
}
Expand Down Expand Up @@ -110,6 +112,22 @@ void QgsLayoutGuideWidget::pageChanged( int page )
mPageLabel->setText( tr( "Guides for page %1" ).arg( page + 1 ) );
}

void QgsLayoutGuideWidget::clearAll()
{
// qt - y u no do this for me?
Q_FOREACH ( const QModelIndex &index, mHozGuidesTableView->selectionModel()->selectedIndexes() )
{
mHozGuidesTableView->closePersistentEditor( index );
}
Q_FOREACH ( const QModelIndex &index, mVertGuidesTableView->selectionModel()->selectedIndexes() )
{
mVertGuidesTableView->closePersistentEditor( index );
}

mVertProxyModel->removeRows( 0, mVertProxyModel->rowCount() );
mHozProxyModel->removeRows( 0, mHozProxyModel->rowCount() );
}


QgsLayoutGuidePositionDelegate::QgsLayoutGuidePositionDelegate( QgsLayout *layout, QAbstractItemModel *model )
: mLayout( layout )
Expand Down
2 changes: 2 additions & 0 deletions src/app/layout/qgslayoutguidewidget.h
Expand Up @@ -42,6 +42,8 @@ class QgsLayoutGuideWidget: public QgsPanelWidget, private Ui::QgsLayoutGuideWid

void pageChanged( int page );

void clearAll();

private:

QgsLayout *mLayout = nullptr;
Expand Down
27 changes: 23 additions & 4 deletions src/ui/layout/qgslayoutguidewidgetbase.ui
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>377</width>
<height>629</height>
<width>231</width>
<height>518</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -54,8 +54,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>349</width>
<height>675</height>
<width>231</width>
<height>518</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
Expand Down Expand Up @@ -103,6 +103,12 @@
</item>
<item row="0" column="0" colspan="2">
<widget class="QTableView" name="mHozGuidesTableView">
<property name="minimumSize">
<size>
<width>0</width>
<height>120</height>
</size>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
Expand Down Expand Up @@ -160,6 +166,12 @@
</item>
<item row="0" column="0" colspan="2">
<widget class="QTableView" name="mVertGuidesTableView">
<property name="minimumSize">
<size>
<width>0</width>
<height>120</height>
</size>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
Expand All @@ -180,6 +192,13 @@
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="mClearAllButton">
<property name="text">
<string>Clear All Guides</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
Expand Down

0 comments on commit c43a173

Please sign in to comment.