[Marble-commits] KDE/kdeedu/marble/src
Thibaut Gridel
tgridel at free.fr
Mon Aug 17 19:58:15 CEST 2009
SVN commit 1012483 by tgridel:
PlacemarkManager: simplify code
M +2 -2 lib/MarbleModel.cpp
M +23 -41 lib/PlacemarkManager.cpp
M +3 -13 lib/PlacemarkManager.h
M +0 -1 plugins/render/fileview/FileViewFloatItem.cpp
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1012482:1012483
@@ -442,7 +442,7 @@
// load new standard Placemarks
foreach(const QString& container, loadList) {
loadList.pop_front();
- d->m_placemarkmanager->addPlacemarkFile( container, loadList.isEmpty() );
+ d->m_placemarkmanager->addPlacemarkFile( container );
}
d->notifyModelChanged();
d->m_placemarkLayout->requestStyleReset();
@@ -706,7 +706,7 @@
void MarbleModel::addPlacemarkFile( const QString& filename )
{
- d->m_placemarkmanager->loadKml( filename, false );
+ d->m_placemarkmanager->addPlacemarkFile( filename );
d->notifyModelChanged();
}
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkManager.cpp #1012482:1012483
@@ -79,11 +79,6 @@
d->m_datafacade = facade;
}
-void PlacemarkManager::clearPlacemarks()
-{
- d->m_datafacade->placemarkModel()->clearPlacemarks();
-}
-
QStringList PlacemarkManager::containers() const
{
return d->m_datafacade->fileViewModel()->containers() + d->m_pathList;
@@ -94,20 +89,13 @@
return name.remove(".kml").remove(".cache");
}
-void PlacemarkManager::addPlacemarkFile( const QString& filepath, bool finalized )
+void PlacemarkManager::addPlacemarkFile( const QString& filepath )
{
if( ! containers().contains( toRegularName( filepath ) ) ) {
- qDebug() << "adding container:" << toRegularName( filepath ) << finalized;
+ qDebug() << "adding container:" << toRegularName( filepath );
PlacemarkLoader* loader = new PlacemarkLoader( this, filepath );
- connect ( loader, SIGNAL( placemarksLoaded( PlacemarkLoader*, PlacemarkContainer * ) ),
- this, SLOT( loadPlacemarkContainer( PlacemarkLoader*, PlacemarkContainer * ) ) );
- connect ( loader, SIGNAL( placemarkLoaderFailed( PlacemarkLoader* ) ),
- this, SLOT( cleanupLoader( PlacemarkLoader* ) ) );
- connect ( loader, SIGNAL( newGeoDataDocumentAdded( GeoDataDocument* ) ),
- this, SLOT( addGeoDataDocument( GeoDataDocument* ) ) );
- d->m_loaderList.append( loader );
+ appendLoader( loader );
d->m_pathList.append( toRegularName( filepath ) );
- loader->start();
}
}
@@ -136,7 +124,11 @@
void PlacemarkManager::addPlacemarkData( const QString& data, const QString& key )
{
- loadKmlFromData( data, key, false );
+ Q_ASSERT( d->m_datafacade->placemarkModel() != 0 && "You have called loadKmlFromData before creating a model!" );
+
+ qDebug() << "adding container:" << key;
+ PlacemarkLoader* loader = new PlacemarkLoader( this, data, key );
+ appendLoader( loader );
}
void PlacemarkManager::removePlacemarkKey( const QString& key )
@@ -153,6 +145,21 @@
};
}
+void PlacemarkManager::appendLoader( PlacemarkLoader *loader )
+{
+ connect ( loader, SIGNAL( placemarksLoaded( PlacemarkLoader*, PlacemarkContainer * ) ),
+ this, SLOT( loadPlacemarkContainer( PlacemarkLoader*, PlacemarkContainer * ) ) );
+
+ connect ( loader, SIGNAL( placemarkLoaderFailed( PlacemarkLoader* ) ),
+ this, SLOT( cleanupLoader( PlacemarkLoader* ) ) );
+
+ connect ( loader, SIGNAL( newGeoDataDocumentAdded( GeoDataDocument* ) ),
+ this, SLOT( addGeoDataDocument( GeoDataDocument* ) ) );
+
+ d->m_loaderList.append( loader );
+ loader->start();
+}
+
void PlacemarkManager::cleanupLoader( PlacemarkLoader* loader )
{
d->m_loaderList.removeAll( loader );
@@ -181,29 +188,4 @@
}
}
-void PlacemarkManager::loadKml( const QString& filename, bool clearPrevious )
-{
- Q_UNUSED( clearPrevious )
-
- addPlacemarkFile( filename, true );
-}
-
-void PlacemarkManager::loadKmlFromData( const QString& data, const QString& key, bool finalize )
-{
- Q_UNUSED( finalize )
-
- Q_ASSERT( d->m_datafacade->placemarkModel() != 0 && "You have called loadKmlFromData before creating a model!" );
-
- qDebug() << "adding container:" << key;
- PlacemarkLoader* loader = new PlacemarkLoader( this, data, key );
- connect ( loader, SIGNAL( placemarksLoaded( PlacemarkLoader*, PlacemarkContainer * ) ),
- this, SLOT( loadPlacemarkContainer( PlacemarkLoader*, PlacemarkContainer * ) ) );
- connect ( loader, SIGNAL( placemarkLoaderFailed( PlacemarkLoader* ) ),
- this, SLOT( cleanupLoader( PlacemarkLoader* ) ) );
- connect ( loader, SIGNAL( newGeoDataDocumentAdded( GeoDataDocument* ) ),
- this, SLOT( addGeoDataDocument( GeoDataDocument* ) ) );
- d->m_loaderList.append( loader );
- loader->start();
-}
-
#include "PlacemarkManager.moc"
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkManager.h #1012482:1012483
@@ -75,24 +75,12 @@
*/
QStringList containers() const;
- void clearPlacemarks();
-
/**
* Loads a new place mark file into the manager.
*/
- void addPlacemarkFile( const QString &fileName, bool finalize = true );
+ void addPlacemarkFile( const QString &fileName );
/**
- * Loads a new KML file into the manager.
- */
- void loadKml( const QString &fileName, bool clearPrevious = false );
-
- /**
- * Loads a new KML data as string into the manager.
- */
- void loadKmlFromData( const QString& data, const QString& key = "data", bool finalize = true );
-
- /**
* removes an existing GeoDataDocument from the manager
*/
void removePlacemarkKey( const QString& key );
@@ -113,6 +101,8 @@
private:
+ void appendLoader( PlacemarkLoader *loader );
+
/**
* internal helper function which returns the regular name of a kml or cache file
*/
--- trunk/KDE/kdeedu/marble/src/plugins/render/fileview/FileViewFloatItem.cpp #1012482:1012483
@@ -22,7 +22,6 @@
#include <QtGui/QSlider>
#include "FileViewModel.h"
-#include "AbstractFileViewItem.h"
#include "GeoPainter.h"
#include "ViewportParams.h"
#include "MarbleWidget.h"
More information about the Marble-commits
mailing list