[Marble-commits] KDE/kdeedu/marble/src/lib
Thibaut Gridel
tgridel at free.fr
Sun Dec 26 14:55:23 CET 2010
SVN commit 1209328 by tgridel:
PlacemarkLayout: keep the sort proxy which is needed internally
M +5 -0 GeoDataTreeModel.cpp
M +2 -2 MarbleMap.cpp
M +1 -14 MarbleModel.cpp
M +0 -1 MarbleModel.h
M +13 -3 PlacemarkLayout.cpp
M +5 -4 PlacemarkLayout.h
--- trunk/KDE/kdeedu/marble/src/lib/GeoDataTreeModel.cpp #1209327:1209328
@@ -226,7 +226,12 @@
return QVariant(feature->style()->iconStyle().icon());
} else if ( role == MarblePlacemarkModel::ObjectPointerRole ) {
return qVariantFromValue( object );
+ } else if ( role == MarblePlacemarkModel::PopularityIndexRole ) {
+ GeoDataPlacemark *placemark = dynamic_cast<GeoDataPlacemark*>( object );
+ if ( placemark ) {
+ return QVariant( placemark->popularityIndex() );
}
+ }
return QVariant();
}
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.cpp #1209327:1209328
@@ -82,7 +82,7 @@
m_backgroundVisible( true ),
m_layerManager( model->dataFacade(), model->pluginManager(), parent ),
m_textureLayer( model->mapThemeManager(), model->downloadManager(), model->sunLocator() ),
- m_placemarkLayout( model->popSortModel(), model->placemarkSelectionModel(), parent ),
+ m_placemarkLayout( model->placemarkModel(), model->placemarkSelectionModel(), parent ),
m_measureTool( model ),
m_viewAngle( 110.0 )
{
@@ -104,7 +104,7 @@
QObject::connect( m_model->placemarkSelectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection) ),
&m_placemarkLayout, SLOT( requestStyleReset() ) );
- QObject::connect( m_model->popSortModel(), SIGNAL( layoutChanged() ),
+ QObject::connect( m_model->placemarkModel(), SIGNAL( layoutChanged() ),
&m_placemarkLayout, SLOT( requestStyleReset() ) );
// FIXME: more on the spot update names and API
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1209327:1209328
@@ -56,7 +56,6 @@
#include "FileManager.h"
#include "GeoDataTreeModel.h"
#include "PlacemarkManager.h"
-#include "PlacemarkPainter.h"
#include "Planet.h"
#include "PluginManager.h"
#include "StoragePolicy.h"
@@ -92,8 +91,7 @@
m_pluginManager ) ),
m_fileManager( 0 ),
m_placemarkmanager( 0 ),
- m_popSortModel( parent ),
- m_placemarkselectionmodel( &m_popSortModel ),
+ m_placemarkselectionmodel( 0 ),
m_positionTracking( 0 ),
m_bookmarkManager( 0 ),
m_routingManager( 0 ),
@@ -134,7 +132,6 @@
// Places on the map
FileManager *m_fileManager;
PlacemarkManager *m_placemarkmanager;
- QSortFilterProxyModel m_popSortModel;
// Selection handling
QItemSelectionModel m_placemarkselectionmodel;
@@ -179,11 +176,6 @@
d->m_placemarkmanager->setDataFacade(d->m_dataFacade);
d->m_placemarkmanager->setFileManager(d->m_fileManager);
- d->m_popSortModel.setSourceModel( d->m_dataFacade->placemarkModel() );
-// d->m_popSortModel->setSortLocaleAware( true );
- d->m_popSortModel.setDynamicSortFilter( true );
- d->m_popSortModel.setSortRole( MarblePlacemarkModel::PopularityIndexRole );
- d->m_popSortModel.sort( 0, Qt::DescendingOrder );
/*
* Create FileViewModel
@@ -384,11 +376,6 @@
return d->m_dataFacade->placemarkModel();
}
-QAbstractItemModel *MarbleModel::popSortModel() const
-{
- return &d->m_popSortModel;
-}
-
QItemSelectionModel *MarbleModel::placemarkSelectionModel() const
{
return &d->m_placemarkselectionmodel;
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.h #1209327:1209328
@@ -123,7 +123,6 @@
*/
QAbstractItemModel* treeModel() const;
QAbstractItemModel* placemarkModel() const;
- QAbstractItemModel* popSortModel() const;
QItemSelectionModel* placemarkSelectionModel() const;
/**
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkLayout.cpp #1209327:1209328
@@ -19,6 +19,7 @@
#include <QtGui/QFont>
#include <QtGui/QItemSelectionModel>
#include <QtGui/QPainter>
+#include <QtGui/QSortFilterProxyModel>
#include "GeoSceneDocument.h"
#include "GeoSceneMap.h"
@@ -38,16 +39,25 @@
using namespace Marble;
-PlacemarkLayout::PlacemarkLayout( const QAbstractItemModel *placemarkModel,
- const QItemSelectionModel *selectionModel,
+PlacemarkLayout::PlacemarkLayout( QAbstractItemModel *placemarkModel,
+ QItemSelectionModel *selectionModel,
QObject* parent )
: QObject( parent ),
- m_placemarkModel( placemarkModel ),
+ m_placemarkModel( new QSortFilterProxyModel ),
m_selectionModel( selectionModel ),
m_placemarkPainter( 0 ),
m_maxLabelHeight( 0 ),
m_styleResetRequested( true )
{
+ m_placemarkModel->setSourceModel( placemarkModel );
+ m_placemarkModel->setDynamicSortFilter( true );
+ m_placemarkModel->setSortRole( MarblePlacemarkModel::PopularityIndexRole );
+ m_placemarkModel->sort( 0, Qt::DescendingOrder );
+
+ connect( m_selectionModel, SIGNAL( selectionChanged( QItemSelection,
+ QItemSelection) ),
+ this, SLOT( requestStyleReset() ) );
+
// Old weightfilter array. Still here
// to be able to compare performance
/*
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkLayout.h #1209327:1209328
@@ -25,6 +25,7 @@
#include "GeoDataPlacemark.h" // In geodata/data/
class QAbstractItemModel;
+class QSortFilterProxyModel;
class QItemSelectionModel;
class QPainter;
class QPoint;
@@ -51,8 +52,8 @@
/**
* Creates a new place mark layout.
*/
- PlacemarkLayout( const QAbstractItemModel *placemarkModel,
- const QItemSelectionModel *selectionModel,
+ PlacemarkLayout( QAbstractItemModel *placemarkModel,
+ QItemSelectionModel *selectionModel,
QObject *parent = 0 );
/**
@@ -99,8 +100,8 @@
private:
Q_DISABLE_COPY( PlacemarkLayout )
- const QAbstractItemModel *const m_placemarkModel;
- const QItemSelectionModel *const m_selectionModel;
+ QSortFilterProxyModel *const m_placemarkModel;
+ QItemSelectionModel *const m_selectionModel;
PlacemarkPainter *m_placemarkPainter;
More information about the Marble-commits
mailing list