[Marble-commits] KDE/kdeedu/marble/src/lib
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Sun Nov 7 10:43:36 CET 2010
SVN commit 1193821 by beschow:
pass the placemark and selection model to PlacemarkLayout via its constructor rather than via its update method
M +14 -19 MarbleModel.cpp
M +11 -13 PlacemarkLayout.cpp
M +6 -4 PlacemarkLayout.h
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1193820:1193821
@@ -106,9 +106,11 @@
m_fileManager( 0 ),
m_placemarkmanager( 0 ),
m_placemarkLayout( 0 ),
+ m_popSortModel( parent ),
m_clock( 0 ),
m_sunLocator( 0 ),
m_layerDecorator( 0 ),
+ m_placemarkselectionmodel( &m_popSortModel ),
m_positionTracking( 0 ),
m_planet( 0 ),
m_bookmarkManager( 0 ),
@@ -158,7 +160,7 @@
FileManager *m_fileManager;
PlacemarkManager *m_placemarkmanager;
PlacemarkLayout *m_placemarkLayout;
- QSortFilterProxyModel *m_popSortModel;
+ QSortFilterProxyModel m_popSortModel;
GeometryLayer *m_geometryLayer;
AtmosphereLayer m_atmosphereLayer;
FogLayer m_fogLayer;
@@ -169,7 +171,7 @@
MergedLayerDecorator *m_layerDecorator;
// Selection handling
- QItemSelectionModel *m_placemarkselectionmodel;
+ QItemSelectionModel m_placemarkselectionmodel;
//Gps Stuff
PositionTracking *m_positionTracking;
@@ -235,21 +237,17 @@
d->m_measureTool = new MeasureTool( this );
- d->m_popSortModel = new QSortFilterProxyModel( this );
-
- d->m_popSortModel->setSourceModel( d->m_dataFacade->placemarkModel() );
+ 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 );
+ d->m_popSortModel.setDynamicSortFilter( true );
+ d->m_popSortModel.setSortRole( MarblePlacemarkModel::PopularityIndexRole );
+ d->m_popSortModel.sort( 0, Qt::DescendingOrder );
- d->m_placemarkselectionmodel = new QItemSelectionModel( d->m_popSortModel );
-
- d->m_placemarkLayout = new PlacemarkLayout( this );
- connect( d->m_placemarkselectionmodel, SIGNAL( selectionChanged( QItemSelection,
+ d->m_placemarkLayout = new PlacemarkLayout( &d->m_popSortModel, &d->m_placemarkselectionmodel, this );
+ connect( &d->m_placemarkselectionmodel, SIGNAL( selectionChanged( QItemSelection,
QItemSelection) ),
d->m_placemarkLayout, SLOT( requestStyleReset() ) );
- connect( d->m_popSortModel, SIGNAL( layoutChanged() ),
+ connect( &d->m_popSortModel, SIGNAL( layoutChanged() ),
d->m_placemarkLayout, SLOT( requestStyleReset() ) );
/*
@@ -302,7 +300,6 @@
delete d->m_bookmarkManager;
delete d->m_tileLoader; // disconnects from downloadManager in dtor
- delete d->m_popSortModel;
delete d->m_placemarkmanager;
delete d->m_fileManager;
delete d->m_mapTheme;
@@ -699,11 +696,9 @@
viewParams->propertyValue( "otherplaces", showOtherPlaces );
if ( ( showPlaces || showCities || showTerrain || showOtherPlaces )
- && d->m_popSortModel->rowCount() > 0 )
+ && d->m_popSortModel.rowCount() > 0 )
{
- d->m_placemarkLayout->paintPlaceFolder( painter, viewParams,
- d->m_popSortModel,
- d->m_placemarkselectionmodel );
+ d->m_placemarkLayout->paintPlaceFolder( painter, viewParams );
}
renderPositions.clear();
@@ -737,7 +732,7 @@
QItemSelectionModel *MarbleModel::placemarkSelectionModel() const
{
- return d->m_placemarkselectionmodel;
+ return &d->m_placemarkselectionmodel;
}
AbstractScanlineTextureMapper *MarbleModel::textureMapper() const
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkLayout.cpp #1193820:1193821
@@ -38,8 +38,12 @@
using namespace Marble;
-PlacemarkLayout::PlacemarkLayout( QObject* parent )
+PlacemarkLayout::PlacemarkLayout( const QAbstractItemModel *placemarkModel,
+ const QItemSelectionModel *selectionModel,
+ QObject* parent )
: QObject( parent ),
+ m_placemarkModel( placemarkModel ),
+ m_selectionModel( selectionModel ),
m_placemarkPainter( 0 ),
m_maxLabelHeight( 0 ),
m_styleResetRequested( true )
@@ -181,14 +185,8 @@
}
void PlacemarkLayout::paintPlaceFolder( QPainter *painter,
- ViewParams *viewParams,
- const QAbstractItemModel *model,
- const QItemSelectionModel *selectionModel )
+ ViewParams *viewParams )
{
- if( 0 == selectionModel )
- return;
- if( 0 == model )
- return;
// const int imgwidth = viewParams->canvasImage()->width();
const int imgheight = viewParams->canvasImage()->height();
@@ -197,7 +195,7 @@
m_styleResetRequested = false;
styleReset();
- m_maxLabelHeight = maxLabelHeight( model, selectionModel );
+ m_maxLabelHeight = maxLabelHeight( m_placemarkModel, m_selectionModel );
}
const int secnumber = imgheight / m_maxLabelHeight + 1;
@@ -234,7 +232,7 @@
* First handle the selected placemarks, as they have the highest priority.
*/
- const QModelIndexList selectedIndexes = selectionModel->selection().indexes();
+ const QModelIndexList selectedIndexes = m_selectionModel->selection().indexes();
for ( int i = 0; i < selectedIndexes.count(); ++i ) {
const QModelIndex index = selectedIndexes.at( i );
@@ -322,13 +320,13 @@
/**
* Now handle all other placemarks...
*/
- const QItemSelection selection = selectionModel->selection();
+ const QItemSelection selection = m_selectionModel->selection();
- const int rowCount = model->rowCount();
+ const int rowCount = m_placemarkModel->rowCount();
for ( int i = 0; i != rowCount; ++i )
{
- const QModelIndex& index = model->index( i, 0 );
+ const QModelIndex& index = m_placemarkModel->index( i, 0 );
if( !index.isValid() ) {
mDebug() << "invalid index!!!";
continue;
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkLayout.h #1193820:1193821
@@ -51,7 +51,9 @@
/**
* Creates a new place mark layout.
*/
- explicit PlacemarkLayout( QObject *parent = 0 );
+ explicit PlacemarkLayout( const QAbstractItemModel *placemarkModel,
+ const QItemSelectionModel *selectionModel,
+ QObject *parent = 0 );
/**
* Destroys the place mark painter.
@@ -68,9 +70,7 @@
* @param planetAxis The position of the planet axis.
* @param firstTime Whether the map is painted the first time.
*/
- void paintPlaceFolder( QPainter *painter, ViewParams *viewParams,
- const QAbstractItemModel *placemarkModel,
- const QItemSelectionModel *selectionModel );
+ void paintPlaceFolder( QPainter *painter, ViewParams *viewParams );
/**
* Returns a the maximum height of all possible labels.
@@ -106,6 +106,8 @@
private:
Q_DISABLE_COPY( PlacemarkLayout )
+ const QAbstractItemModel *const m_placemarkModel;
+ const QItemSelectionModel *const m_selectionModel;
PlacemarkPainter *m_placemarkPainter;
More information about the Marble-commits
mailing list