[Marble-commits] KDE/kdeedu/marble/src/lib
Thibaut Gridel
tgridel at free.fr
Mon Nov 2 20:40:09 CET 2009
SVN commit 1043982 by tgridel:
PlacemarkManager: deal with all Placemarks of a document recursively
M +25 -3 PlacemarkManager.cpp
M +2 -0 PlacemarkManager.h
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkManager.cpp #1043981:1043982
@@ -46,6 +46,7 @@
MarbleDataFacade* m_datafacade;
FileManager *m_fileManager;
QVector<GeoDataPlacemark> m_placemarkContainer;
+ QVector<int> m_sizeForDocument;
};
}
@@ -88,12 +89,14 @@
if (file)
{
const GeoDataDocument &document = *file->document();
- QVector<GeoDataPlacemark> result = document.placemarks();
+ QVector<GeoDataPlacemark> result = recurseContainer(document);
if (!result.isEmpty())
{
createFilterProperties( result );
int start = d->m_placemarkContainer.size();
d->m_placemarkContainer << result;
+ d->m_sizeForDocument.resize(index+1);
+ d->m_sizeForDocument[index] = result.size();
qDebug() << "PlacemarkManager::addGeoDataDocument:"
<< document.fileName() << " size " << result.size();
d->m_datafacade->placemarkModel()->addPlacemarks( start, result.size() );
@@ -112,10 +115,11 @@
int start = 0;
for ( int i = 0; i < index; ++i )
{
- start += d->m_fileManager->at(i)->size();
+ start += d->m_sizeForDocument[i];
}
- int size = d->m_fileManager->at(index)->size();
+ int size = d->m_sizeForDocument[index];
d->m_placemarkContainer.remove(start, size);
+ d->m_sizeForDocument.remove(index);
qDebug() << "PlacemarkManager::removeGeoDataDocument:"
<< document.fileName() << " size " << size;
d->m_datafacade->placemarkModel()->removePlacemarks(
@@ -123,6 +127,24 @@
}
}
+QVector<GeoDataPlacemark> PlacemarkManager::recurseContainer(GeoDataContainer container)
+{
+ QVector<GeoDataPlacemark> results;
+
+ const QVector<GeoDataFeature> features = container.features();
+ QVector<GeoDataFeature>::const_iterator it = features.constBegin();
+ QVector<GeoDataFeature>::const_iterator end = features.constEnd();
+
+ results += container.placemarks();
+ for (; it != end; ++it) {
+ if ( GeoDataFolderId == it->featureId() ) {
+ const GeoDataContainer *cont = static_cast<const GeoDataContainer*>(it);
+ results += recurseContainer(*cont);
+ }
+ }
+ return results;
+}
+
void PlacemarkManager::createFilterProperties( QVector<Marble::GeoDataPlacemark> &container )
{
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkManager.h #1043981:1043982
@@ -21,6 +21,7 @@
{
class FileManager;
+class GeoDataContainer;
class GeoDataDocument;
class GeoDataPlacemark;
class MarblePlacemarkModel;
@@ -76,6 +77,7 @@
void removeGeoDataDocument( int index );
private:
+ QVector<GeoDataPlacemark> recurseContainer(GeoDataContainer container);
void createFilterProperties( QVector<Marble::GeoDataPlacemark> &container );
int cityPopIdx( qint64 population ) const;
int spacePopIdx( qint64 diameter ) const;
More information about the Marble-commits
mailing list