Skip to content

Commit 0fa3f4e

Browse files
author
g_j_m
committed
Remove and tidy up code that used to do stuff to the overview
canvas. This is handled by the map canvas now. git-svn-id: http://svn.osgeo.org/qgis/trunk@5208 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 370f7bb commit 0fa3f4e

File tree

1 file changed

+17
-34
lines changed

1 file changed

+17
-34
lines changed

src/gui/qgsproject.cpp

+17-34
Original file line numberDiff line numberDiff line change
@@ -719,9 +719,10 @@ static QString _getVersion(QDomDocument const &doc)
719719
/**
720720
locate a qgsMapCanvas object
721721
*/
722-
static QgsMapCanvas * _findMapCanvas(QString const &canonicalMapCanvasName)
722+
static QgsMapCanvas * _findMapCanvas()
723723
{
724724
QgsMapCanvas * theMapCanvas = 0x0;
725+
QString canonicalMapCanvasName = "theMapCanvas";
725726

726727
QWidgetList wlist = QApplication::topLevelWidgets();
727728
foreach (QWidget *widget, QApplication::topLevelWidgets())
@@ -739,7 +740,7 @@ static QgsMapCanvas * _findMapCanvas(QString const &canonicalMapCanvasName)
739740
}
740741
else
741742
{
742-
qDebug(("Unable to find canvas widget " + canonicalMapCanvasName).toLocal8Bit().data());
743+
qDebug("Unable to find the map canvas widget with name " + canonicalMapCanvasName);
743744

744745
return 0x0; // XXX some sort of error value? Exception?
745746
}
@@ -901,14 +902,11 @@ static pair< bool, list<QDomNode> > _getMapLayers(QDomDocument const &doc)
901902
/**
902903
Sets the given canvas' extents
903904
904-
@param canonicalName will be "theMapCanvas" or "theOverviewCanvas"; these
905-
are set when those are created in qgisapp ctor
906905
*/
907-
static void _setCanvasExtent(QString const &canonicalMapCanvasName,
908-
QgsRect const &newExtent)
906+
static void _setCanvasExtent(QgsRect const &newExtent)
909907
{
910908
// first find the canonical map canvas
911-
QgsMapCanvas *theMapCanvas = _findMapCanvas(canonicalMapCanvasName);
909+
QgsMapCanvas *theMapCanvas = _findMapCanvas();
912910

913911
if (!theMapCanvas)
914912
{
@@ -937,28 +935,24 @@ static void _setCanvasExtent(QString const &canonicalMapCanvasName,
937935
set the overview canvas to that instead of stupidly setting the overview
938936
canvas to the *same* extent that's in the main map canvas.
939937
940-
@param canonicalMapCanvasName will be "theMapCanvas" or "theOverviewCanvas"; these
941-
are set when those are created in qgisapp ctor
942-
943938
*/
944-
static QgsRect _getFullExtent(QString const &canonicalMapCanvasName)
939+
static QgsRect _getFullExtent()
945940
{
946941
// XXX since this is a cut-n-paste from above, maybe generalize to a
947942
// XXX separate function?
948943
// first find the canonical map canvas
949-
QgsMapCanvas *theMapCanvas = _findMapCanvas(canonicalMapCanvasName);
944+
QgsMapCanvas *theMapCanvas = _findMapCanvas();
950945

951946
if (!theMapCanvas)
952947
{
953-
qDebug(("Unable to find canvas widget " + canonicalMapCanvasName).toLocal8Bit().data());
954-
948+
// _findMapCanvas() will produce an error if the map canvas wasn't found
955949
return QgsRect(); // XXX some sort of error value? Exception?
956950
}
957951

958952

959953
return theMapCanvas->fullExtent();
960954

961-
} // _getFullExtent( QString const & canonicalMapCanvasName )
955+
} // _getFullExtent( )
962956

963957

964958

@@ -972,28 +966,24 @@ static QgsRect _getFullExtent(QString const &canonicalMapCanvasName)
972966
set the overview canvas to that instead of stupidly setting the overview
973967
canvas to the *same* extent that's in the main map canvas.
974968
975-
@param canonicalMapCanvasName will be "theMapCanvas" or "theOverviewCanvas"; these
976-
are set when those are created in qgisapp ctor
977-
978969
*/
979-
static QgsRect _getExtent(QString const &canonicalMapCanvasName)
970+
static QgsRect _getExtent()
980971
{
981972
// XXX since this is a cut-n-paste from above, maybe generalize to a
982973
// XXX separate function?
983974
// first find the canonical map canvas
984-
QgsMapCanvas *theMapCanvas = _findMapCanvas(canonicalMapCanvasName);
975+
QgsMapCanvas *theMapCanvas = _findMapCanvas();
985976

986977
if (!theMapCanvas)
987978
{
988-
qDebug(("Unable to find canvas widget " + canonicalMapCanvasName).toLocal8Bit().data());
989-
979+
// _findMapCanvas will produce an error if the map canvas wasn't found
990980
return QgsRect(); // XXX some sort of error value? Exception?
991981
}
992982

993983

994984
return theMapCanvas->extent();
995985

996-
} // _getExtent( QString const & canonicalMapCanvasName )
986+
} // _getExtent( )
997987

998988

999989

@@ -1101,7 +1091,9 @@ bool QgsProject::read()
11011091

11021092
// now set the map units; note, alters QgsProject::instance().
11031093
_getMapUnits(*doc);
1104-
_findMapCanvas("theMapCanvas")->setMapUnits(mapUnits());
1094+
QgsMapCanvas* canvas = _findMapCanvas();
1095+
if (canvas)
1096+
canvas->setMapUnits(mapUnits());
11051097

11061098
// get the map layers
11071099
pair< bool, list<QDomNode> > getMapLayersResults = _getMapLayers(*doc);
@@ -1123,12 +1115,6 @@ bool QgsProject::read()
11231115
// return false;
11241116
}
11251117

1126-
// ensure that overview map canvas is set to *entire* extent
1127-
QgsRect mapCanvasFullExtent = _getFullExtent("theMapCanvas");
1128-
_setCanvasExtent("theOverviewCanvas", mapCanvasFullExtent);
1129-
// now restore the extent for the main canvas
1130-
_setCanvasExtent("theMapCanvas", savedExtent);
1131-
11321118
if ( ! getMapLayersResults.first )
11331119
{
11341120
#ifdef QGISDEBUG
@@ -1309,13 +1295,10 @@ bool QgsProject::write()
13091295

13101296
// extents and layers info are written by the map canvas
13111297
// find the canonical map canvas
1312-
QgsMapCanvas *theMapCanvas = _findMapCanvas("theMapCanvas");
1298+
QgsMapCanvas *theMapCanvas = _findMapCanvas();
13131299

13141300
if (!theMapCanvas)
13151301
{
1316-
qDebug("Unable to find canvas widget theMapCanvas");
1317-
1318-
13191302
// Actually this might be run from the test harness, and therefore
13201303
// there won't be a GUI, so no map canvas. Just blithely continue on.
13211304
}

0 commit comments

Comments
 (0)