Skip to content
Permalink
Browse files

Save extent sychronized state in project for views

  • Loading branch information
nyalldawson committed Mar 13, 2017
1 parent 73c09bf commit 40bb4e9ae0b81985bfbf76774f160c841de00093
Showing with 26 additions and 3 deletions.
  1. +7 −2 src/app/qgisapp.cpp
  2. +2 −1 src/app/qgisapp.h
  3. +10 −0 src/app/qgsmapcanvasdockwidget.cpp
  4. +7 −0 src/app/qgsmapcanvasdockwidget.h
@@ -3113,7 +3113,7 @@ QgsMapCanvas *QgisApp::mapCanvas()
return mMapCanvas;
}

QgsMapCanvas *QgisApp::createNewMapCanvas( const QString &name, bool isFloating, const QRect &dockGeometry )
QgsMapCanvas *QgisApp::createNewMapCanvas( const QString &name, bool isFloating, const QRect &dockGeometry, bool synced )
{
Q_FOREACH ( QgsMapCanvas *canvas, mapCanvases() )
{
@@ -3166,6 +3166,9 @@ QgsMapCanvas *QgisApp::createNewMapCanvas( const QString &name, bool isFloating,
markDirty();
connect( mapCanvasWidget, &QgsMapCanvasDockWidget::closed, this, &QgisApp::markDirty );
connect( mapCanvasWidget, &QgsMapCanvasDockWidget::renameTriggered, this, &QgisApp::renameView );

mapCanvasWidget->setViewExtentSynchronized( synced );

return mapCanvas;
}

@@ -11748,6 +11751,7 @@ void QgisApp::writeProject( QDomDocument &doc )
node.setAttribute( QStringLiteral( "width" ), w->width() );
node.setAttribute( QStringLiteral( "height" ), w->height() );
node.setAttribute( QStringLiteral( "floating" ), w->isFloating() ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
node.setAttribute( QStringLiteral( "synced" ), w->isViewExtentSynchronized() ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
mapViewNode.appendChild( node );
}
qgisNode.appendChild( mapViewNode );
@@ -11782,8 +11786,9 @@ void QgisApp::readProject( const QDomDocument &doc )
int w = elementNode.attribute( QStringLiteral( "width" ), QStringLiteral( "400" ) ).toInt();
int h = elementNode.attribute( QStringLiteral( "height" ), QStringLiteral( "400" ) ).toInt();
bool floating = elementNode.attribute( QStringLiteral( "floating" ), QStringLiteral( "0" ) ).toInt();
bool synced = elementNode.attribute( QStringLiteral( "synced" ), QStringLiteral( "0" ) ).toInt();

QgsMapCanvas *mapCanvas = createNewMapCanvas( mapName, floating, QRect( x, y, w, h ) );
QgsMapCanvas *mapCanvas = createNewMapCanvas( mapName, floating, QRect( x, y, w, h ), synced );
mapCanvas->readProject( doc );
}
}
@@ -241,7 +241,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
* and \a dockGeometry arguments can be used to specify an initial floating state
* and widget geometry rect for the dock.
*/
QgsMapCanvas *createNewMapCanvas( const QString &name, bool isFloating = false, const QRect &dockGeometry = QRect() );
QgsMapCanvas *createNewMapCanvas( const QString &name, bool isFloating = false, const QRect &dockGeometry = QRect(),
bool synced = false );

/**
* Closes any additional map canvases. The main map canvas will not
@@ -177,6 +177,16 @@ void QgsMapCanvasDockWidget::closeWithoutWarning()
close();
}

void QgsMapCanvasDockWidget::setViewExtentSynchronized( bool enabled )
{
mActionSyncView->setChecked( enabled );
}

bool QgsMapCanvasDockWidget::isViewExtentSynchronized() const
{
return mActionSyncView->isChecked();
}

void QgsMapCanvasDockWidget::closeEvent( QCloseEvent *event )
{
if ( mShowCloseWarning && mMapCanvas->layerCount() > 0
@@ -54,6 +54,13 @@ class APP_EXPORT QgsMapCanvasDockWidget : public QgsDockWidget, private Ui::QgsM
*/
void closeWithoutWarning();

/**
* Sets whether the view extent should be synchronized with the main canvas extent.
*/
void setViewExtentSynchronized( bool enabled );

bool isViewExtentSynchronized() const;

signals:

void renameTriggered();

0 comments on commit 40bb4e9

Please sign in to comment.
You can’t perform that action at this time.