diff --git a/ChangeLog b/ChangeLog
index c7645c0271b..e531d5e7982 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,11 @@
QGIS Change Log
-ChangeLog,v 1.122 2004/06/10 15:38:53 sbr00pwb Exp
+ChangeLog,v 1.123 2004/06/10 23:10:16 timlinux Exp
------------------------------------------------------------------------------
Version 0.3 'Madison' .... development version
+2004-06-10 [ts] 0.3.0devel27
+** Modified projectio (serialisation and deserialisation of project files) to use maplayerregistry and not mapcanvas.
+** Implemented state handling of 'showInOverview' property in project io.
2004-06-10 [petebr] 0.3.0devel26
Tidied up the SPIT gui to match the plugin template.
Fixed bug in scale bar which displayed the bar the wrong size!
diff --git a/configure.in b/configure.in
index f9d19d73e64..9ed131a5eb8 100644
--- a/configure.in
+++ b/configure.in
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
-dnl configure.in,v 1.125 2004/06/10 15:38:53 sbr00pwb Exp
+dnl configure.in,v 1.126 2004/06/10 23:10:16 timlinux Exp
AC_INIT
@@ -24,7 +24,7 @@ dnl ---------------------------------------------------------------------------
MAJOR_VERSION=0
MINOR_VERSION=3
MICRO_VERSION=0
-EXTRA_VERSION=26
+EXTRA_VERSION=27
if test $EXTRA_VERSION -eq 0; then
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}
else
diff --git a/qgis.dtd b/qgis.dtd
index ed5135e6dea..bb22034b641 100644
--- a/qgis.dtd
+++ b/qgis.dtd
@@ -31,7 +31,11 @@
-
+
+
+
+
diff --git a/qgis.kdevelop b/qgis.kdevelop
index 880a124c48e..9abfd529a34 100644
--- a/qgis.kdevelop
+++ b/qgis.kdevelop
@@ -9,7 +9,7 @@
.
false
-
+
@@ -21,7 +21,7 @@
src/qgis
executable
/
-
+
false
true
@@ -61,19 +61,19 @@
--prefix=$HOME --enable-debug
-
-
-
-
+
+
+
+
kdevgccoptions
kdevgppoptions
kdevpgf77options
-
-
-
-
+
+
+
+
-O0 -g3
-
+
@@ -84,17 +84,17 @@
true
1
false
-
+
libtool
-
-
-
-
-
+
+
+
+
+
true
false
false
@@ -142,16 +142,24 @@
400
250
-
- Qt
- GDAL
-
+
-
+
+ false
+ false
+
*.o,*.lo,CVS
false
+ false
+
+ true
+ true
+ true
+ true
+ -C
+
diff --git a/src/qgisapp.cpp b/src/qgisapp.cpp
index a9a8857068d..e78ae426ebb 100644
--- a/src/qgisapp.cpp
+++ b/src/qgisapp.cpp
@@ -1612,7 +1612,7 @@ void QgisApp::fileOpen()
if (answer != QMessageBox::Cancel)
{
mMapCanvas->freeze(true);
- QgsProjectIo *pio = new QgsProjectIo(mMapCanvas, QgsProjectIo::OPEN, this);
+ QgsProjectIo *pio = new QgsProjectIo( QgsProjectIo::OPEN, this);
if (pio->read())
{
@@ -1630,9 +1630,9 @@ void QgisApp::fileOpen()
void QgisApp::fileSave()
{
- QgsProjectIo *pio = new QgsProjectIo(mMapCanvas, QgsProjectIo::SAVE);
+ QgsProjectIo *pio = new QgsProjectIo( QgsProjectIo::SAVE);
pio->setFileName(mFullPathName);
- if (pio->write())
+ if (pio->write(mMapCanvas->extent()))
{
setCaption(tr("Quantum GIS --") + " " + pio->baseName());
statusBar()->message(tr("Saved map to:") + " " + pio->fullPathName());
@@ -1644,8 +1644,8 @@ void QgisApp::fileSave()
void QgisApp::fileSaveAs()
{
- QgsProjectIo *pio = new QgsProjectIo(mMapCanvas, QgsProjectIo::SAVEAS);
- if (pio->write())
+ QgsProjectIo *pio = new QgsProjectIo( QgsProjectIo::SAVEAS);
+ if (pio->write(mMapCanvas->extent()))
{
setCaption(tr("Quantum GIS --") + " " + pio->baseName());
statusBar()->message(tr("Saved map to:") + " " + pio->fullPathName());
@@ -1782,7 +1782,7 @@ bool QgisApp::addProject(QString projectFile)
// adds a saved project to qgis, usually called on startup by
// specifying a project file on the command line
bool returnValue = false;
- QgsProjectIo *pio = new QgsProjectIo(mMapCanvas, QgsProjectIo::OPEN, this);
+ QgsProjectIo *pio = new QgsProjectIo(QgsProjectIo::OPEN, this);
#ifdef QGISDEBUG
std::cout << "Loading Project - about to call ProjectIO->read()" << std::endl;
#endif
@@ -2086,6 +2086,17 @@ void QgisApp::removeLayer()
mMapCanvas->clear();
mMapCanvas->render();
}
+void QgisApp::removeAllLayers()
+{
+ std::map myMapLayers = mMapLayerRegistry->mapLayers();
+ std::map::iterator myMapIterator;
+ for ( myMapIterator = myMapLayers.begin(); myMapIterator != myMapLayers.end(); ++myMapIterator )
+ {
+ mMapLayerRegistry->removeMapLayer( myMapIterator->first );
+ }
+ mOverviewCanvas->clear();
+ mMapCanvas->clear();
+} //remove all layers
void QgisApp::zoomToLayerExtent()
{
@@ -2789,6 +2800,47 @@ void QgisApp::addVectorLayer(QString vectorLayerPath, QString baseName, QString
}
+void QgisApp::addMapLayer(QgsMapLayer *theMapLayer)
+{
+ mMapCanvas->freeze();
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+ if(theMapLayer->isValid())
+ {
+ // Register this layer with the layers registry
+ mMapLayerRegistry->addMapLayer(theMapLayer);
+ // init the context menu so it can connect to slots in main app
+ theMapLayer->initContextMenu(this);
+ // add it to the mapcanvas collection
+ mMapCanvas->addLayer(theMapLayer);
+ //connect up a request from the raster layer to show in overview map
+ QObject::connect(theMapLayer,
+ SIGNAL(showInOverview(QString,bool)),
+ this,
+ SLOT(setLayerOverviewStatus(QString,bool)));
+
+ mProjectIsDirtyFlag = true;
+ statusBar()->message(mMapCanvas->extent().stringRep(2));
+
+ }else
+ {
+ QMessageBox::critical(this,"Layer is not valid",
+ "The layer is not a valid layer and can not be added to the map");
+ }
+ qApp->processEvents();
+ mMapCanvas->freeze(false);
+ mMapCanvas->render();
+ QApplication::restoreOverrideCursor();
+
+}
+
+void QgisApp::setExtent(QgsRect theRect)
+{
+ mMapCanvas->setExtent(theRect);
+}
+
+
+
+
int QgisApp::saveDirty()
{
int answer = 0;
diff --git a/src/qgisapp.h b/src/qgisapp.h
index 9c93a619bdc..e4558669c0b 100644
--- a/src/qgisapp.h
+++ b/src/qgisapp.h
@@ -115,6 +115,14 @@ public:
*/
bool addRasterLayer(QFileInfo const & rasterFile);
+ /** Add a 'pre-made' map layer to the project */
+ void addMapLayer(QgsMapLayer *theMapLayer);
+
+ /** Set the extents of the map canvas */
+ void setExtent(QgsRect theRect);
+
+ //! Remove all layers from the map and legend
+ void removeAllLayers();
/** opens a qgis project file
@returns false if unable to open the project
diff --git a/src/qgsmaplayerregistry.cpp b/src/qgsmaplayerregistry.cpp
index 830854f2089..dd907edb9d8 100644
--- a/src/qgsmaplayerregistry.cpp
+++ b/src/qgsmaplayerregistry.cpp
@@ -91,3 +91,8 @@ void QgsMapLayerRegistry::removeAllMapLayers()
//delete mMapLayers[theLayerId];
//mMapLayers.erase(theLayerId);
}
+
+std::map QgsMapLayerRegistry::mapLayers()
+{
+ return mMapLayers;
+}
diff --git a/src/qgsmaplayerregistry.h b/src/qgsmaplayerregistry.h
index 64ab904c790..ee2c85b8f4a 100644
--- a/src/qgsmaplayerregistry.h
+++ b/src/qgsmaplayerregistry.h
@@ -39,6 +39,8 @@ public:
QStringList mapLayerList();
//! Retrieve a pointer to a loaded plugin by id
QgsMapLayer * mapLayer(QString theLayerId);
+ //! Retrieve the mapLayers collection (mainly intended for use by projectio)
+ std::map mapLayers();
//! Add a layer to the map of loaded layers
void addMapLayer(QgsMapLayer * theMapLayer);
//! Remove a layer from qgis - any canvases using that layer will need to remove it
diff --git a/src/qgsprojectio.cpp b/src/qgsprojectio.cpp
index 683ca3c065e..5151e478842 100644
--- a/src/qgsprojectio.cpp
+++ b/src/qgsprojectio.cpp
@@ -1,10 +1,10 @@
/***************************************************************************
- qgsprojectio.cpp - Save/Restore QGIS project
- --------------------------------------
- Date : 19-Oct-2003
- Copyright : (C) 2003 by Gary E.Sherman
- email : sherman at mrcc.com
-/***************************************************************************
+ qgsprojectio.cpp - Save/Restore QGIS project
+ --------------------------------------
+Date : 19-Oct-2003
+Copyright : (C) 2003 by Gary E.Sherman
+email : sherman at mrcc.com
+ ***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -12,7 +12,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
-/* qgsprojectio.cpp,v 1.38 2004/06/09 15:02:33 timlinux Exp */
+/* qgsprojectio.cpp,v 1.39 2004/06/10 23:07:08 timlinux Exp */
#include
#include
#include
@@ -40,9 +40,11 @@
#include "qgsdlgvectorlayerproperties.h"
#include "qgisapp.h"
#include "qgsmarkersymbol.h"
+#include "qgsmaplayerregistry.h"
+#include