Skip to content

Commit

Permalink
use signals to mark project dirty when canvas layer or extents change (
Browse files Browse the repository at this point in the history
…fixes #943)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12926 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Feb 11, 2010
1 parent 6cdb7ae commit 8386fef
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 49 deletions.
8 changes: 2 additions & 6 deletions src/app/legend/qgslegend.cpp
Expand Up @@ -161,6 +161,8 @@ void QgsLegend::selectAll( bool select )

// Turn on rendering (if it was on previously)
mMapCanvas->setRenderFlag( renderFlagState );

QgsProject::instance()->dirty( true );
}

void QgsLegend::removeGroup( int groupIndex )
Expand Down Expand Up @@ -1619,9 +1621,6 @@ void QgsLegend::legendLayerZoom()
//zoom to bounding box
mMapCanvas->setExtent( extent );
mMapCanvas->refresh();

// notify the project we've made a change
QgsProject::instance()->dirty( true );
}

void QgsLegend::legendLayerZoomNative()
Expand All @@ -1641,9 +1640,6 @@ void QgsLegend::legendLayerZoomNative()
mMapCanvas->refresh();

QgsDebugMsg( "MapUnitsPerPixel after : " + QString::number( mMapCanvas->mapUnitsPerPixel() ) );

// notify the project we've made a change
QgsProject::instance()->dirty( true );
}
}

Expand Down
57 changes: 14 additions & 43 deletions src/app/qgisapp.cpp
Expand Up @@ -1831,6 +1831,10 @@ void QgisApp::setupConnections()
connect( mMapCanvas, SIGNAL( selectionChanged( QgsMapLayer * ) ),
this, SLOT( activateDeactivateLayerRelatedActions( QgsMapLayer * ) ) );

// track of canvas layers and extents and mark project dirty on changes
connect( mMapCanvas, SIGNAL( extentsChanged() ), this, SLOT( markDirty() ) );
connect( mMapCanvas, SIGNAL( layersChanged() ), this, SLOT( markDirty() ) );

connect( mRenderSuppressionCBox, SIGNAL( toggled( bool ) ), mMapCanvas, SLOT( setRenderFlag( bool ) ) );
//
// Do we really need this ??? - its already connected to the esc key...TS
Expand Down Expand Up @@ -2397,8 +2401,6 @@ bool QgisApp::addVectorLayers( QStringList const & theLayerQStringList, const QS
layer->setLayerName( elements.at( 1 ) );
// Register this layer with the layers registry
QgsMapLayerRegistry::instance()->addMapLayer( layer );
// notify the project we've made a change
QgsProject::instance()->dirty( true );
}
}
else
Expand Down Expand Up @@ -2553,8 +2555,6 @@ void QgisApp::addDatabaseLayer()
{
// register this layer with the central layers registry
QgsMapLayerRegistry::instance()->addMapLayer( layer );
// notify the project we've made a change
QgsProject::instance()->dirty( true );
}
else
{
Expand Down Expand Up @@ -2635,8 +2635,6 @@ void QgisApp::addSpatiaLiteLayer()
{
// register this layer with the central layers registry
QgsMapLayerRegistry::instance()->addMapLayer( layer );
// notify the project we've made a change
QgsProject::instance()->dirty( true );
}
else
{
Expand Down Expand Up @@ -3362,8 +3360,7 @@ void QgisApp::addAllToOverview()
mMapLegend->enableOverviewModeAllLayers( true );
}

// notify the project we've made a change
QgsProject::instance()->dirty( true );
markDirty();
}

//reimplements method from base (gui) class
Expand All @@ -3374,8 +3371,7 @@ void QgisApp::removeAllFromOverview()
mMapLegend->enableOverviewModeAllLayers( false );
}

// notify the project we've made a change
QgsProject::instance()->dirty( true );
markDirty();
}

void QgisApp::toggleFullScreen()
Expand Down Expand Up @@ -3506,26 +3502,17 @@ void QgisApp::zoomIn()
QgsDebugMsg( "Setting map tool to zoomIn" );

mMapCanvas->setMapTool( mMapTools.mZoomIn );

// notify the project we've made a change
QgsProject::instance()->dirty( true );
}


void QgisApp::zoomOut()
{
mMapCanvas->setMapTool( mMapTools.mZoomOut );

// notify the project we've made a change
QgsProject::instance()->dirty( true );
}

void QgisApp::zoomToSelected()
{
mMapCanvas->zoomToSelected();

// notify the project we've made a change
QgsProject::instance()->dirty( true );
}

void QgisApp::pan()
Expand All @@ -3536,25 +3523,16 @@ void QgisApp::pan()
void QgisApp::zoomFull()
{
mMapCanvas->zoomToFullExtent();
// notify the project we've made a change
QgsProject::instance()->dirty( true );

}

void QgisApp::zoomToPrevious()
{
mMapCanvas->zoomToPreviousExtent();
// notify the project we've made a change
QgsProject::instance()->dirty( true );

}

void QgisApp::zoomToNext()
{
mMapCanvas->zoomToNextExtent();
// notify the project we've made a change
QgsProject::instance()->dirty( true );

}

void QgisApp::zoomActualSize()
Expand Down Expand Up @@ -3668,8 +3646,6 @@ void QgisApp::deleteSelected( QgsMapLayer *layer )
}

vlayer->endEditCommand();
// notify the project we've made a change
QgsProject::instance()->dirty( true );
}

void QgisApp::moveFeature()
Expand Down Expand Up @@ -4396,8 +4372,6 @@ void QgisApp::isInOverview()
void QgisApp::removeLayer()
{
mMapLegend->removeCurrentLayer();
// notify the project we've made a change
QgsProject::instance()->dirty( true );
}


Expand All @@ -4420,8 +4394,6 @@ void QgisApp::removeAllLayers()
}

mMapCanvas->refresh();
// notify the project we've made a change
QgsProject::instance()->dirty( true );
} //remove all layers

void QgisApp::showGpsTool()
Expand Down Expand Up @@ -4783,9 +4755,6 @@ QgsVectorLayer* QgisApp::addVectorLayer( QString vectorLayerPath, QString baseNa
{
// Register this layer with the layers registry
QgsMapLayerRegistry::instance()->addMapLayer( layer );
// notify the project we've made a change
QgsProject::instance()->dirty( true );

statusBar()->showMessage( mMapCanvas->extent().toString( 2 ) );

}
Expand Down Expand Up @@ -4830,9 +4799,6 @@ void QgisApp::addMapLayer( QgsMapLayer *theMapLayer )
// not necessary since adding to registry adds to canvas mMapCanvas->addLayer(theMapLayer);

statusBar()->showMessage( mMapCanvas->extent().toString( 2 ) );
// notify the project we've made a change
QgsProject::instance()->dirty( true );

}
else
{
Expand Down Expand Up @@ -4877,7 +4843,8 @@ bool QgisApp::saveDirty()
{
// flag project as dirty since dirty state of canvas is reset if "dirty"
// is based on a zoom or pan
QgsProject::instance()->dirty( true );
markDirty();

// old code: mProjectIsDirtyFlag = true;

// prompt user to save
Expand Down Expand Up @@ -5095,6 +5062,12 @@ void QgisApp::extentsViewToggled( bool theFlag )
}
}

void QgisApp::markDirty()
{
// notify the project that there was a change
QgsProject::instance()->dirty( true );
}

void QgisApp::showExtents()
{
if ( !mToggleExtentsViewButton->isChecked() )
Expand Down Expand Up @@ -5634,8 +5607,6 @@ bool QgisApp::addRasterLayer( QgsRasterLayer * theRasterLayer )
SIGNAL( statusChanged( QString ) ),
this,
SLOT( showStatusMessage( QString ) ) );
// notify the project we've made a change
QgsProject::instance()->dirty( true );

return true;
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -365,6 +365,9 @@ class QgisApp : public QMainWindow
//! Zoom to selected features
void zoomToSelected();

//! mark project dirty
void markDirty();

void updateUndoActions();

//! cuts selected features on the active layer to the clipboard
Expand Down

0 comments on commit 8386fef

Please sign in to comment.