Skip to content

Commit

Permalink
[FEATURE] Add clear guides action to composer view menu
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson authored and mhugent committed Oct 29, 2013
1 parent 616588e commit 46009c6
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions python/core/composer/qgscomposition.sip
Expand Up @@ -52,6 +52,9 @@ class QgsComposition : QGraphicsScene

void setGridVisible( bool b );
bool gridVisible() const;

/**Removes all snap lines*/
void clearSnapLines();

void setSnapGridResolution( double r );
double snapGridResolution() const;
Expand Down
10 changes: 10 additions & 0 deletions src/app/composer/qgscomposer.cpp
Expand Up @@ -265,6 +265,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
viewMenu->addAction( mActionShowGuides );
viewMenu->addAction( mActionSnapGuides );
viewMenu->addAction( mActionSmartGuides );
viewMenu->addAction( mActionClearGuides );

// Panel and toolbar submenus
mPanelMenu = new QMenu( tr( "Panels" ), this );
Expand Down Expand Up @@ -727,6 +728,15 @@ void QgsComposer::on_mActionSmartGuides_triggered( bool checked )
}
}

void QgsComposer::on_mActionClearGuides_triggered()
{
//clear guide lines
if ( mComposition )
{
mComposition->clearSnapLines();
}
}

void QgsComposer::on_mActionExportAsPDF_triggered()
{
if ( !mComposition || !mView )
Expand Down
3 changes: 3 additions & 0 deletions src/app/composer/qgscomposer.h
Expand Up @@ -300,6 +300,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
//!Enable or disable smart guides
void on_mActionSmartGuides_triggered( bool checked );

//!Clear guides
void on_mActionClearGuides_triggered();

//! Save window state
void saveWindowState();

Expand Down
11 changes: 11 additions & 0 deletions src/core/composer/qgscomposition.cpp
Expand Up @@ -1428,6 +1428,17 @@ void QgsComposition::removeSnapLine( QGraphicsLineItem* line )
delete line;
}

void QgsComposition::clearSnapLines()
{
QList< QGraphicsLineItem* >::iterator it = mSnapLines.begin();
for ( ; it != mSnapLines.end(); ++it )
{
removeItem(( *it ) );
delete( *it );
}
mSnapLines.clear();
}

void QgsComposition::setSnapLinesVisible( bool visible )
{
mGuidesVisible = visible;
Expand Down
3 changes: 3 additions & 0 deletions src/core/composer/qgscomposition.h
Expand Up @@ -124,6 +124,9 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
void setSmartGuidesEnabled( bool b ) { mSmartGuides = b; };
bool smartGuidesEnabled() const {return mSmartGuides;}

/**Removes all snap lines*/
void clearSnapLines();

void setSnapGridResolution( double r );
double snapGridResolution() const {return mSnapGridResolution;}

Expand Down
10 changes: 9 additions & 1 deletion src/ui/qgscomposerbase.ui
Expand Up @@ -339,7 +339,15 @@
<property name="shortcut">
<string>Ctrl+Alt+;</string>
</property>
</action>
</action>
<action name="mActionClearGuides">
<property name="text">
<string>Clear Guides</string>
</property>
<property name="toolTip">
<string>Clear guides</string>
</property>
</action>
<action name="mActionAddImage">
<property name="icon">
<iconset resource="../../images/images.qrc">
Expand Down

0 comments on commit 46009c6

Please sign in to comment.