Skip to content

Commit 3fb49d8

Browse files
author
timlinux
committedJun 10, 2004
Modified projectio (serialisation and deserialisation of project files) to use maplayerregistry and not mapcanvas.
Implemented state handling of 'showInOverview' property in project io. git-svn-id: http://svn.osgeo.org/qgis/trunk@1554 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 077dcef commit 3fb49d8

File tree

10 files changed

+500
-404
lines changed

10 files changed

+500
-404
lines changed
 

‎ChangeLog

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
QGIS Change Log
2-
ChangeLog,v 1.122 2004/06/10 15:38:53 sbr00pwb Exp
2+
ChangeLog,v 1.123 2004/06/10 23:10:16 timlinux Exp
33
------------------------------------------------------------------------------
44
Version 0.3 'Madison' .... development version
5+
2004-06-10 [ts] 0.3.0devel27
6+
** Modified projectio (serialisation and deserialisation of project files) to use maplayerregistry and not mapcanvas.
57

8+
** Implemented state handling of 'showInOverview' property in project io.
69
2004-06-10 [petebr] 0.3.0devel26
710
Tidied up the SPIT gui to match the plugin template.
811
Fixed bug in scale bar which displayed the bar the wrong size!

‎configure.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
dnl Process this file with autoconf to produce a configure script.
3-
dnl configure.in,v 1.125 2004/06/10 15:38:53 sbr00pwb Exp
3+
dnl configure.in,v 1.126 2004/06/10 23:10:16 timlinux Exp
44

55
AC_INIT
66

@@ -24,7 +24,7 @@ dnl ---------------------------------------------------------------------------
2424
MAJOR_VERSION=0
2525
MINOR_VERSION=3
2626
MICRO_VERSION=0
27-
EXTRA_VERSION=26
27+
EXTRA_VERSION=27
2828
if test $EXTRA_VERSION -eq 0; then
2929
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}
3030
else

‎qgis.dtd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
<!ELEMENT datasource (#PCDATA) >
3232
<!ELEMENT zorder (#PCDATA) >
3333
<!-- Attribute Lists -->
34-
<!ATTLIST maplayer
34+
<!--Raster : flag indicating whether the layer should be represented in overview or not -->
35+
<!ELEMENT showInOverviewFlag>
36+
<!-- Attribute lists -->
37+
<!ATTLIST showInOverViewFlag boolean (1|0|true|false) "false">
38+
<!ATTLIST maplayer
3539
type (vector|raster|database) "vector"
3640
visible (1|0) "0"
3741
>

‎qgis.kdevelop

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<ignoreparts/>
1010
<projectdirectory>.</projectdirectory>
1111
<absoluteprojectpath>false</absoluteprojectpath>
12-
<description></description>
12+
<description/>
1313
<secondaryLanguages/>
1414
</general>
1515
<kdevautoproject>
@@ -21,7 +21,7 @@
2121
<mainprogram>src/qgis</mainprogram>
2222
<directoryradio>executable</directoryradio>
2323
<customdirectory>/</customdirectory>
24-
<programargs></programargs>
24+
<programargs/>
2525
<terminal>false</terminal>
2626
<autocompile>true</autocompile>
2727
<envvars/>
@@ -61,19 +61,19 @@
6161
</debug>
6262
<default>
6363
<configargs>--prefix=$HOME --enable-debug</configargs>
64-
<builddir></builddir>
65-
<topsourcedir></topsourcedir>
66-
<cppflags></cppflags>
67-
<ldflags></ldflags>
64+
<builddir/>
65+
<topsourcedir/>
66+
<cppflags/>
67+
<ldflags/>
6868
<ccompiler>kdevgccoptions</ccompiler>
6969
<cxxcompiler>kdevgppoptions</cxxcompiler>
7070
<f77compiler>kdevpgf77options</f77compiler>
71-
<ccompilerbinary></ccompilerbinary>
72-
<cxxcompilerbinary></cxxcompilerbinary>
73-
<f77compilerbinary></f77compilerbinary>
74-
<cflags></cflags>
71+
<ccompilerbinary/>
72+
<cxxcompilerbinary/>
73+
<f77compilerbinary/>
74+
<cflags/>
7575
<cxxflags>-O0 -g3</cxxflags>
76-
<f77flags></f77flags>
76+
<f77flags/>
7777
</default>
7878
</configurations>
7979
<make>
@@ -84,17 +84,17 @@
8484
<abortonerror>true</abortonerror>
8585
<numberofjobs>1</numberofjobs>
8686
<dontact>false</dontact>
87-
<makebin></makebin>
87+
<makebin/>
8888
</make>
8989
</kdevautoproject>
9090
<kdevdebugger>
9191
<general>
9292
<dbgshell>libtool</dbgshell>
93-
<programargs></programargs>
94-
<gdbpath></gdbpath>
95-
<configGdbScript></configGdbScript>
96-
<runShellScript></runShellScript>
97-
<runGdbScript></runGdbScript>
93+
<programargs/>
94+
<gdbpath/>
95+
<configGdbScript/>
96+
<runShellScript/>
97+
<runGdbScript/>
9898
<breakonloadinglibs>true</breakonloadinglibs>
9999
<separatetty>false</separatetty>
100100
<floatingtoolbar>false</floatingtoolbar>
@@ -142,16 +142,24 @@
142142
<argumentsHintDelay>400</argumentsHintDelay>
143143
<headerCompletionDelay>250</headerCompletionDelay>
144144
</codecompletion>
145-
<references>
146-
<pcs>Qt</pcs>
147-
<pcs>GDAL</pcs>
148-
</references>
145+
<references/>
149146
</kdevcppsupport>
150147
<kdevfileview>
151-
<groups/>
148+
<groups>
149+
<hidenonprojectfiles>false</hidenonprojectfiles>
150+
<hidenonlocation>false</hidenonlocation>
151+
</groups>
152152
<tree>
153153
<hidepatterns>*.o,*.lo,CVS</hidepatterns>
154154
<hidenonprojectfiles>false</hidenonprojectfiles>
155+
<showvcsfields>false</showvcsfields>
155156
</tree>
156157
</kdevfileview>
158+
<kdevcvsservice>
159+
<recursivewhenupdate>true</recursivewhenupdate>
160+
<prunedirswhenupdate>true</prunedirswhenupdate>
161+
<createdirswhenupdate>true</createdirswhenupdate>
162+
<recursivewhencommitremove>true</recursivewhencommitremove>
163+
<revertoptions>-C</revertoptions>
164+
</kdevcvsservice>
157165
</kdevelop>

‎src/qgisapp.cpp

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,7 @@ void QgisApp::fileOpen()
16121612
if (answer != QMessageBox::Cancel)
16131613
{
16141614
mMapCanvas->freeze(true);
1615-
QgsProjectIo *pio = new QgsProjectIo(mMapCanvas, QgsProjectIo::OPEN, this);
1615+
QgsProjectIo *pio = new QgsProjectIo( QgsProjectIo::OPEN, this);
16161616

16171617
if (pio->read())
16181618
{
@@ -1630,9 +1630,9 @@ void QgisApp::fileOpen()
16301630

16311631
void QgisApp::fileSave()
16321632
{
1633-
QgsProjectIo *pio = new QgsProjectIo(mMapCanvas, QgsProjectIo::SAVE);
1633+
QgsProjectIo *pio = new QgsProjectIo( QgsProjectIo::SAVE);
16341634
pio->setFileName(mFullPathName);
1635-
if (pio->write())
1635+
if (pio->write(mMapCanvas->extent()))
16361636
{
16371637
setCaption(tr("Quantum GIS --") + " " + pio->baseName());
16381638
statusBar()->message(tr("Saved map to:") + " " + pio->fullPathName());
@@ -1644,8 +1644,8 @@ void QgisApp::fileSave()
16441644

16451645
void QgisApp::fileSaveAs()
16461646
{
1647-
QgsProjectIo *pio = new QgsProjectIo(mMapCanvas, QgsProjectIo::SAVEAS);
1648-
if (pio->write())
1647+
QgsProjectIo *pio = new QgsProjectIo( QgsProjectIo::SAVEAS);
1648+
if (pio->write(mMapCanvas->extent()))
16491649
{
16501650
setCaption(tr("Quantum GIS --") + " " + pio->baseName());
16511651
statusBar()->message(tr("Saved map to:") + " " + pio->fullPathName());
@@ -1782,7 +1782,7 @@ bool QgisApp::addProject(QString projectFile)
17821782
// adds a saved project to qgis, usually called on startup by
17831783
// specifying a project file on the command line
17841784
bool returnValue = false;
1785-
QgsProjectIo *pio = new QgsProjectIo(mMapCanvas, QgsProjectIo::OPEN, this);
1785+
QgsProjectIo *pio = new QgsProjectIo(QgsProjectIo::OPEN, this);
17861786
#ifdef QGISDEBUG
17871787
std::cout << "Loading Project - about to call ProjectIO->read()" << std::endl;
17881788
#endif
@@ -2086,6 +2086,17 @@ void QgisApp::removeLayer()
20862086
mMapCanvas->clear();
20872087
mMapCanvas->render();
20882088
}
2089+
void QgisApp::removeAllLayers()
2090+
{
2091+
std::map<QString, QgsMapLayer *> myMapLayers = mMapLayerRegistry->mapLayers();
2092+
std::map<QString, QgsMapLayer *>::iterator myMapIterator;
2093+
for ( myMapIterator = myMapLayers.begin(); myMapIterator != myMapLayers.end(); ++myMapIterator )
2094+
{
2095+
mMapLayerRegistry->removeMapLayer( myMapIterator->first );
2096+
}
2097+
mOverviewCanvas->clear();
2098+
mMapCanvas->clear();
2099+
} //remove all layers
20892100

20902101
void QgisApp::zoomToLayerExtent()
20912102
{
@@ -2789,6 +2800,47 @@ void QgisApp::addVectorLayer(QString vectorLayerPath, QString baseName, QString
27892800

27902801
}
27912802

2803+
void QgisApp::addMapLayer(QgsMapLayer *theMapLayer)
2804+
{
2805+
mMapCanvas->freeze();
2806+
QApplication::setOverrideCursor(Qt::WaitCursor);
2807+
if(theMapLayer->isValid())
2808+
{
2809+
// Register this layer with the layers registry
2810+
mMapLayerRegistry->addMapLayer(theMapLayer);
2811+
// init the context menu so it can connect to slots in main app
2812+
theMapLayer->initContextMenu(this);
2813+
// add it to the mapcanvas collection
2814+
mMapCanvas->addLayer(theMapLayer);
2815+
//connect up a request from the raster layer to show in overview map
2816+
QObject::connect(theMapLayer,
2817+
SIGNAL(showInOverview(QString,bool)),
2818+
this,
2819+
SLOT(setLayerOverviewStatus(QString,bool)));
2820+
2821+
mProjectIsDirtyFlag = true;
2822+
statusBar()->message(mMapCanvas->extent().stringRep(2));
2823+
2824+
}else
2825+
{
2826+
QMessageBox::critical(this,"Layer is not valid",
2827+
"The layer is not a valid layer and can not be added to the map");
2828+
}
2829+
qApp->processEvents();
2830+
mMapCanvas->freeze(false);
2831+
mMapCanvas->render();
2832+
QApplication::restoreOverrideCursor();
2833+
2834+
}
2835+
2836+
void QgisApp::setExtent(QgsRect theRect)
2837+
{
2838+
mMapCanvas->setExtent(theRect);
2839+
}
2840+
2841+
2842+
2843+
27922844
int QgisApp::saveDirty()
27932845
{
27942846
int answer = 0;

‎src/qgisapp.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ Q_OBJECT public:
115115
*/
116116
bool addRasterLayer(QFileInfo const & rasterFile);
117117

118+
/** Add a 'pre-made' map layer to the project */
119+
void addMapLayer(QgsMapLayer *theMapLayer);
120+
121+
/** Set the extents of the map canvas */
122+
void setExtent(QgsRect theRect);
123+
124+
//! Remove all layers from the map and legend
125+
void removeAllLayers();
118126
/** opens a qgis project file
119127
@returns false if unable to open the project
120128

‎src/qgsmaplayerregistry.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,8 @@ void QgsMapLayerRegistry::removeAllMapLayers()
9191
//delete mMapLayers[theLayerId];
9292
//mMapLayers.erase(theLayerId);
9393
}
94+
95+
std::map<QString,QgsMapLayer*> QgsMapLayerRegistry::mapLayers()
96+
{
97+
return mMapLayers;
98+
}

‎src/qgsmaplayerregistry.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Q_OBJECT;
3939
QStringList mapLayerList();
4040
//! Retrieve a pointer to a loaded plugin by id
4141
QgsMapLayer * mapLayer(QString theLayerId);
42+
//! Retrieve the mapLayers collection (mainly intended for use by projectio)
43+
std::map<QString,QgsMapLayer*> mapLayers();
4244
//! Add a layer to the map of loaded layers
4345
void addMapLayer(QgsMapLayer * theMapLayer);
4446
//! Remove a layer from qgis - any canvases using that layer will need to remove it

‎src/qgsprojectio.cpp

Lines changed: 379 additions & 365 deletions
Large diffs are not rendered by default.

‎src/qgsprojectio.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@
1212
* (at your option) any later version. *
1313
* *
1414
***************************************************************************/
15-
/* qgsprojectio.h,v 1.5 2004/02/21 20:54:26 gsherman Exp */
15+
/* qgsprojectio.h,v 1.6 2004/06/10 23:07:08 timlinux Exp */
1616

1717
#ifndef _QGSPROJECTIO_H_
1818
#define _QGSPROJECTIO_H_
1919

20-
class QgsMapCanvas;
2120
class QgisApp;
21+
class QgsMapLayerRegistry;
22+
class QgsRect;
2223
/*! \class QgsProjectIo
2324
* \brief Class to handle reading and writing a Qgis project file
2425
*/
2526
class QgsProjectIo
2627
{
2728

2829
public:
29-
QgsProjectIo(QgsMapCanvas *map=0, int action=SAVE, QgisApp *qgis=0);
30+
QgsProjectIo(int action=SAVE, QgisApp *qgis=0);
3031
~QgsProjectIo();
3132
//! Read the file and create the map
3233
bool read(QString path=0);
3334
//! Write the contents of the map to a file
34-
bool write();
35-
void setMapCanvas(QgsMapCanvas *map);
35+
bool write(QgsRect theExtent);
3636
//! Open a file dialog, the type determined by action (SAVE AS or OPEN)
3737
QString selectFileName();
3838
//! get the basename of the file (no path, just the file name)
@@ -47,13 +47,13 @@ class QgsProjectIo
4747
OPEN
4848
};
4949
private:
50-
void writeXML(void);
50+
void writeXML(QgsRect theExtent);
5151
QString fileName;
5252
QString fullPath;
5353
bool neverSaved;
54-
QgsMapCanvas *map;
5554
//! pointer to the main app for connecting slots
5655
QgisApp *qgisApp;
56+
QgsMapLayerRegistry * mMapLayerRegistry;
5757
int action;
5858
};
5959

0 commit comments

Comments
 (0)
Please sign in to comment.