[Marble-commits] KDE/kdeedu/marble/src/lib
Thibaut Gridel
tgridel at free.fr
Mon Nov 2 20:40:16 CET 2009
SVN commit 1043984 by tgridel:
FileLoader: Save recursive Placemarks in .cache file
M +28 -9 FileLoader.cpp
M +2 -1 FileLoader.h
M +2 -1 PlacemarkManager.cpp
--- trunk/KDE/kdeedu/marble/src/lib/FileLoader.cpp #1043983:1043984
@@ -19,6 +19,7 @@
#include "GeoDataParser.h"
#include "GeoDataDocument.h"
+#include "GeoDataFolder.h"
#include "GeoDataPlacemark.h"
#include "MarbleDirs.h"
@@ -274,25 +275,43 @@
out.setVersion( QDataStream::Qt_4_2 );
+ savePlacemarks(out, m_document);
+}
+
+void FileLoader::savePlacemarks(QDataStream &out, const GeoDataContainer *container)
+{
qreal lon;
qreal lat;
qreal alt;
- QVector<Marble::GeoDataPlacemark>::const_iterator it = m_document->placemarks().constBegin();
- QVector<Marble::GeoDataPlacemark>::const_iterator const end = m_document->placemarks().constEnd();
+ const QVector<GeoDataPlacemark> placemarks = container->placemarks();
+ QVector<Marble::GeoDataPlacemark>::const_iterator it = placemarks.constBegin();
+ QVector<Marble::GeoDataPlacemark>::const_iterator const end = placemarks.constEnd();
for (; it != end; ++it )
{
- out << (*it).name();
- (it)->coordinate( lon, lat, alt );
+ out << it->name();
+ it->coordinate( lon, lat, alt );
// Use double to provide a single cache file format across architectures
out << (double)(lon) << (double)(lat) << (double)(alt);
- out << QString( (*it).role() );
- out << QString( (*it).description() );
- out << QString( (*it).countryCode() );
- out << (double)(*it).area();
- out << (qint64)(*it).population();
+ out << QString( it->role() );
+ out << QString( it->description() );
+ out << QString( it->countryCode() );
+ out << (double) it->area();
+ out << (qint64) it->population();
}
+
+ const QVector<GeoDataFolder> folders = container->folders();
+ QVector<GeoDataFolder>::const_iterator cont = folders.constBegin();
+ QVector<GeoDataFolder>::const_iterator endcont = folders.constEnd();
+ for (; cont != endcont; ++cont )
+ {
+ if (GeoDataFolderId == cont->featureId() )
+ {
+ const GeoDataContainer *subcontainer = static_cast<const GeoDataContainer*>(cont);
+ savePlacemarks(out, subcontainer);
+ }
+ }
}
#include "FileLoader.moc"
--- trunk/KDE/kdeedu/marble/src/lib/FileLoader.h #1043983:1043984
@@ -15,7 +15,7 @@
namespace Marble
{
-
+class GeoDataContainer;
class GeoDataDocument;
class FileLoader : public QThread
@@ -37,6 +37,7 @@
void importKmlFromData();
bool loadFile(const QString &filename );
void saveFile(const QString& filename );
+ void savePlacemarks(QDataStream &out, const GeoDataContainer *container);
QString m_filepath;
QString m_contents;
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkManager.cpp #1043983:1043984
@@ -119,7 +119,8 @@
}
int size = d->m_sizeForDocument[index];
d->m_placemarkContainer.remove(start, size);
- d->m_sizeForDocument.remove(index);
+ if (d->m_sizeForDocument.size() > index)
+ d->m_sizeForDocument.remove(index);
qDebug() << "PlacemarkManager::removeGeoDataDocument:"
<< document.fileName() << " size " << size;
d->m_datafacade->placemarkModel()->removePlacemarks(
More information about the Marble-commits
mailing list