[Marble-commits] KDE/kdeedu/marble/src/lib
Thibaut Gridel
tgridel at free.fr
Fri Sep 11 22:39:15 CEST 2009
SVN commit 1022476 by tgridel:
PlacemarkManager: react to FileManager::fileRemoved signal
M +0 -1 AbstractFileViewItem.h
M +12 -11 FileManager.cpp
M +0 -6 GpxFileViewItem.cpp
M +0 -1 GpxFileViewItem.h
M +0 -6 KmlFileViewItem.cpp
M +0 -1 KmlFileViewItem.h
M +2 -3 MarbleModel.cpp
M +44 -7 PlacemarkManager.cpp
M +9 -2 PlacemarkManager.h
--- trunk/KDE/kdeedu/marble/src/lib/AbstractFileViewItem.h #1022475:1022476
@@ -27,7 +27,6 @@
virtual ~AbstractFileViewItem() {};
virtual void saveFile() = 0;
- virtual void closeFile( int start ) = 0;
virtual int size() const { return 0; };
virtual bool isShown() const = 0;
virtual void setShown( bool value ) = 0;
--- trunk/KDE/kdeedu/marble/src/lib/FileManager.cpp #1022475:1022476
@@ -150,10 +150,20 @@
qDebug() << "FileManager::closeFile";
if (index < d->m_fileItemList.size() )
{
- d->m_fileItemList.at( index )->closeFile( indexStart( index ));
+ emit fileRemoved( index );
+ KmlFileViewItem *file =
+ static_cast<KmlFileViewItem*>(d->m_fileItemList.at(index));
+ if (file)
+ {
+ MarbleGeometryModel *geometryModel =
+ d->m_datafacade->geometryModel();
+ if (geometryModel->geoDataRoot() == file->document())
+ {
+ geometryModel->setGeoDataRoot(0);
+ }
+ }
delete d->m_fileItemList.at( index );
d->m_fileItemList.removeAt( index );
- emit fileRemoved( index );
}
}
@@ -206,13 +216,4 @@
}
}
-int FileManager::indexStart( int index )
-{
- int start = 0;
- for( int i = 0; i < index; i++ ) {
- start += d->m_fileItemList.at( i )->size();
- }
- return start;
-}
-
#include "FileManager.moc"
--- trunk/KDE/kdeedu/marble/src/lib/GpxFileViewItem.cpp #1022475:1022476
@@ -55,12 +55,6 @@
stream << ( *m_gpxFile );
}
-void GpxFileViewItem::closeFile( int start )
-{
- Q_UNUSED( start );
- //TODO
-}
-
bool GpxFileViewItem::isShown() const
{
return (m_gpxFile->checkState() == Qt::Checked );
--- trunk/KDE/kdeedu/marble/src/lib/GpxFileViewItem.h #1022475:1022476
@@ -34,7 +34,6 @@
* AbstractFileViewItem methods
*/
virtual void saveFile();
- virtual void closeFile( int start );
virtual bool isShown() const;
virtual void setShown( bool value );
virtual QString name() const;
--- trunk/KDE/kdeedu/marble/src/lib/KmlFileViewItem.cpp #1022475:1022476
@@ -42,12 +42,6 @@
return &m_document;
}
-void KmlFileViewItem::closeFile( int start )
-{
- qDebug() << "closing file" << m_document.name() << m_document.fileName();
- m_fileManager.dataFacade()->placemarkModel()->removePlacemarks( m_document.fileName(), start, size() );
-}
-
int KmlFileViewItem::size() const
{
return m_document.placemarks().size();
--- trunk/KDE/kdeedu/marble/src/lib/KmlFileViewItem.h #1022475:1022476
@@ -31,7 +31,6 @@
* AbstractFileViewItem methods
*/
virtual void saveFile();
- virtual void closeFile( int start );
virtual bool isShown() const;
virtual void setShown( bool value );
virtual int size() const;
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1022475:1022476
@@ -169,13 +169,12 @@
}
d->m_fileManager = new FileManager();
d->m_fileManager->setDataFacade(d->m_dataFacade);
+
d->m_placemarkmanager = new PlacemarkManager();
d->m_placemarkmanager->setDataFacade(d->m_dataFacade);
-
- connect( d->m_fileManager, SIGNAL( geoDataDocumentAdded( const GeoDataDocument & ) ),
- d->m_placemarkmanager, SLOT(addGeoDataDocument(const GeoDataDocument & )) );
connect( d->m_fileManager, SIGNAL( geoDataDocumentAdded( const GeoDataDocument& ) ),
this, SLOT( geoDataDocumentAdded( const GeoDataDocument& ) ) );
+ d->m_placemarkmanager->setFileManager(d->m_fileManager);
d->m_popSortModel = new QSortFilterProxyModel( this );
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkManager.cpp #1022475:1022476
@@ -19,6 +19,7 @@
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
+#include "FileManager.h"
#include "KmlFileViewItem.h"
#include "FileViewModel.h"
#include "MarbleDirs.h"
@@ -44,6 +45,7 @@
}
MarbleDataFacade* m_datafacade;
+ FileManager *m_fileManager;
};
}
@@ -70,15 +72,50 @@
// d->m_datafacade->placemarkModel()->setPlacemarkContainer(&d->m_placemarkContainer);
}
-void PlacemarkManager::addGeoDataDocument(const GeoDataDocument &document)
+void PlacemarkManager::setFileManager( FileManager *fileManager )
{
- qDebug() << "PlacemarkManager::geoDataDocumentAdded:" << document.name();
- if (!document.placemarks().isEmpty())
- {
-// d->m_placemarkContainer << document->placemarks();
- QVector<GeoDataPlacemark> result = document.placemarks();
- d->m_datafacade->placemarkModel()->addPlacemarks( result );
+ d->m_fileManager = fileManager;
+ connect( d->m_fileManager, SIGNAL( fileAdded(int)),
+ this, SLOT(addGeoDataDocument(int)) );
+ connect( d->m_fileManager, SIGNAL( fileRemoved(int)),
+ this, SLOT(removeGeoDataDocument(int)) );
+}
+
+void PlacemarkManager::addGeoDataDocument( int index )
+{
+ KmlFileViewItem *file =
+ static_cast<KmlFileViewItem*>(d->m_fileManager->at(index));
+ if (file)
+ {
+ const GeoDataDocument &document = *file->document();
+ qDebug() << "PlacemarkManager::addGeoDataDocument:"
+ << document.fileName();
+ if (!document.placemarks().isEmpty())
+ {
+ QVector<GeoDataPlacemark> result = document.placemarks();
+ d->m_datafacade->placemarkModel()->addPlacemarks( result );
+ }
}
}
+void PlacemarkManager::removeGeoDataDocument( int index )
+{
+ KmlFileViewItem *file =
+ static_cast<KmlFileViewItem*>(d->m_fileManager->at(index));
+ if (file)
+ {
+ const GeoDataDocument &document = *file->document();
+ qDebug() << "PlacemarkManager::removeGeoDataDocument:"
+ << document.fileName();
+ int start = 0;
+ for ( int i = 0; i < index; ++i )
+ {
+ start += d->m_fileManager->at(i)->size();
+ }
+ d->m_datafacade->placemarkModel()->removePlacemarks(
+ document.fileName(), start, d->m_fileManager->at(index)->size() );
+
+ }
+}
+
#include "PlacemarkManager.moc"
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkManager.h #1022475:1022476
@@ -20,6 +20,7 @@
namespace Marble
{
+class FileManager;
class GeoDataDocument;
class MarblePlacemarkModel;
class MarbleDataFacade;
@@ -64,9 +65,15 @@
*/
void setDataFacade ( MarbleDataFacade *facade );
- public Q_SLOTS:
- void addGeoDataDocument( const GeoDataDocument & );
+ /**
+ * Sets the FileManager from which the placemarks are loaded.
+ */
+ void setFileManager ( FileManager *fileManager );
+public Q_SLOTS:
+ void addGeoDataDocument( int index );
+ void removeGeoDataDocument( int index );
+
private:
Q_DISABLE_COPY( PlacemarkManager )
More information about the Marble-commits
mailing list