Skip to content
Permalink
Browse files

use signals to mark project dirty when canvas layer or extents change (

…fixes #943)

git-svn-id: http://svn.osgeo.org/qgis/trunk@12926 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Feb 11, 2010
1 parent 91ad1ec commit b1e241a0a61ea6ea0db60695e66f3852844aab01
Showing with 19 additions and 49 deletions.
  1. +2 −6 src/app/legend/qgslegend.cpp
  2. +14 −43 src/app/qgisapp.cpp
  3. +3 −0 src/app/qgisapp.h
@@ -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 )
@@ -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()
@@ -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 );
}
}

@@ -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
@@ -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
@@ -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
{
@@ -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
{
@@ -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
@@ -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()
@@ -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()
@@ -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()
@@ -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()
@@ -4396,8 +4372,6 @@ void QgisApp::isInOverview()
void QgisApp::removeLayer()
{
mMapLegend->removeCurrentLayer();
// notify the project we've made a change
QgsProject::instance()->dirty( true );
}


@@ -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()
@@ -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 ) );

}
@@ -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
{
@@ -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
@@ -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() )
@@ -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;
}
@@ -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

0 comments on commit b1e241a

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