[Marble-commits] KDE/kdeedu/marble/src/lib
Thibaut Gridel
tgridel at free.fr
Sat Jan 15 14:34:09 CET 2011
SVN commit 1214585 by tgridel:
placemarkModel: replace by descendantsProxyModel and filter proxies
M +1 -0 CMakeLists.txt
M +16 -6 MarbleDataFacade.cpp
M +1 -31 PlacemarkManager.cpp
A kbihash_p.h [License: LGPL (v2+)]
A kdescendantsproxymodel.cpp [License: LGPL (v2+)]
A kdescendantsproxymodel.h [License: LGPL (v2+)]
--- trunk/KDE/kdeedu/marble/src/lib/CMakeLists.txt #1214584:1214585
@@ -79,6 +79,7 @@
MarbleWidgetPopupMenu.cpp
MarblePlacemarkModel.cpp
GeoDataTreeModel.cpp
+ kdescendantsproxymodel.cpp
MarbleDataFacade.cpp
MarbleDebug.cpp
TextureTile.cpp
--- trunk/KDE/kdeedu/marble/src/lib/MarbleDataFacade.cpp #1214584:1214585
@@ -16,12 +16,12 @@
#include <QtCore/QFile>
#include <QtCore/QString>
#include <QtCore/QAbstractItemModel>
+#include <QtGui/QSortFilterProxyModel>
#include "global.h"
#include "MarbleClock.h"
#include "MarbleDebug.h"
#include "MarbleModel.h"
-#include "MarblePlacemarkModel.h"
#include "Planet.h"
#include "FileViewModel.h"
@@ -30,9 +30,11 @@
#include "GeoDataParser.h"
#include "PositionTracking.h"
+#include "GeoDataTypes.h"
#include "GeoSceneDocument.h"
#include "GeoSceneHead.h"
+#include "kdescendantsproxymodel.h"
#include "routing/RoutingManager.h"
namespace Marble
@@ -44,22 +46,30 @@
MarbleDataFacadePrivate( MarbleModel *model )
: m_model( model ),
m_fileviewmodel( new FileViewModel() ),
- m_placemarkmodel( new MarblePlacemarkModel ),
- m_treemodel( new GeoDataTreeModel)
+ m_treemodel( new GeoDataTreeModel),
+ m_descendantproxy( new KDescendantsProxyModel ),
+ m_sortproxy( new QSortFilterProxyModel )
{
+ m_descendantproxy->setSourceModel( m_treemodel );
+
+ m_sortproxy->setFilterRegExp( QRegExp( GeoDataTypes::GeoDataPlacemarkType ) );
+ m_sortproxy->setFilterKeyColumn( 1 );
+ m_sortproxy->setSourceModel( m_descendantproxy );
}
~MarbleDataFacadePrivate()
{
delete m_fileviewmodel;
- delete m_placemarkmodel;
delete m_treemodel;
+ delete m_descendantproxy;
+ delete m_sortproxy;
}
MarbleModel *m_model;
FileViewModel *m_fileviewmodel;
- MarblePlacemarkModel *m_placemarkmodel;
GeoDataTreeModel *m_treemodel;
+ KDescendantsProxyModel *m_descendantproxy;
+ QSortFilterProxyModel *m_sortproxy;
};
@@ -106,7 +116,7 @@
QAbstractItemModel* MarbleDataFacade::placemarkModel()
{
- return d->m_placemarkmodel;
+ return d->m_sortproxy;
}
FileViewModel* MarbleDataFacade::fileViewModel() const
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkManager.cpp #1214584:1214585
@@ -62,15 +62,9 @@
delete d;
}
-MarblePlacemarkModel* PlacemarkManager::model() const
-{
- return static_cast<MarblePlacemarkModel*>(d->m_datafacade->placemarkModel());
-}
-
void PlacemarkManager::setDataFacade( MarbleDataFacade *facade )
{
d->m_datafacade = facade;
- model()->setPlacemarkContainer(&d->m_placemarkContainer);
}
void PlacemarkManager::setFileManager( FileManager *fileManager )
@@ -94,38 +88,14 @@
{
createFilterProperties( result );
setupStyle( document, result );
- int start = d->m_placemarkContainer.size();
- d->m_placemarkContainer << result;
- d->m_sizeForDocument.resize(index+1);
- d->m_sizeForDocument[index] = result.size();
- mDebug() << "PlacemarkManager::addGeoDataDocument:"
- << document->fileName() << " size " << result.size();
- model()->addPlacemarks( start, result.size() );
}
}
}
-void PlacemarkManager::removeGeoDataDocument( int index )
+void PlacemarkManager::removeGeoDataDocument( int /*index*/ )
{
- GeoDataDocument *document = d->m_fileManager->at(index);
- if (document)
- {
- int start = 0;
- for ( int i = 0; i < index; ++i )
- {
- start += d->m_sizeForDocument[i];
}
- int size = d->m_sizeForDocument[index];
- d->m_placemarkContainer.remove(start, size);
- if (d->m_sizeForDocument.size() > index)
- d->m_sizeForDocument.remove(index);
- mDebug() << "PlacemarkManager::removeGeoDataDocument:"
- << document->fileName() << " size " << size;
- model()->removePlacemarks(
- document->fileName(), start, size );
- }
-}
QVector<GeoDataPlacemark*> PlacemarkManager::recurseContainer(GeoDataContainer *container)
{
More information about the Marble-commits
mailing list