[Kde-bindings] [marble] src/lib: MapViewWidget: make some methods private and move into private class
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Mon Nov 21 14:23:50 UTC 2011
Git commit 04d391a57f272b24d48c0f524e31c6a29dfba4de by Bernhard Beschow.
Committed on 21/11/2011 at 13:52.
Pushed by beschow into branch 'master'.
MapViewWidget: make some methods private and move into private class
CCMAIL: kde-bindings at kde.org
M +29 -20 src/lib/MapViewWidget.cpp
M +5 -5 src/lib/MapViewWidget.h
M +0 -5 src/lib/MarbleControlBox.cpp
M +0 -2 src/lib/MarbleControlBox.h
http://commits.kde.org/marble/04d391a57f272b24d48c0f524e31c6a29dfba4de
diff --git a/src/lib/MapViewWidget.cpp b/src/lib/MapViewWidget.cpp
index 1b044f7..5167cc8 100644
--- a/src/lib/MapViewWidget.cpp
+++ b/src/lib/MapViewWidget.cpp
@@ -61,6 +61,15 @@ class MapViewWidgetPrivate {
m_parent, SLOT( updateMapThemeView() ) );
}
+ void updateCelestialModel();
+
+ void selectCurrentMapTheme( const QString& );
+
+ /// whenever a new map gets inserted, the following slot will adapt the ListView accordingly
+ void updateMapThemeView();
+
+ void projectionSelected( int projectionIndex );
+
MapViewWidget *m_parent;
Ui::MapViewWidget m_mapViewUi;
@@ -116,18 +125,18 @@ MapViewWidget::~MapViewWidget()
delete d;
}
-void MapViewWidget::updateCelestialModel()
+void MapViewWidgetPrivate::updateCelestialModel()
{
- int row = d->m_mapThemeModel->rowCount();
+ int row = m_mapThemeModel->rowCount();
for ( int i = 0; i < row; ++i )
{
- QString celestialBodyId = ( d->m_mapThemeModel->data( d->m_mapThemeModel->index( i, 1 ) ).toString() ).section( '/', 0, 0 );
+ QString celestialBodyId = ( m_mapThemeModel->data( m_mapThemeModel->index( i, 1 ) ).toString() ).section( '/', 0, 0 );
QString celestialBodyName = Planet::name( celestialBodyId );
- QList<QStandardItem*> matchingItems = d->m_celestialList->findItems ( celestialBodyId, Qt::MatchExactly, 1 );
+ QList<QStandardItem*> matchingItems = m_celestialList->findItems ( celestialBodyId, Qt::MatchExactly, 1 );
if ( matchingItems.isEmpty() ) {
- d->m_celestialList->appendRow( QList<QStandardItem*>()
+ m_celestialList->appendRow( QList<QStandardItem*>()
<< new QStandardItem( celestialBodyName )
<< new QStandardItem( celestialBodyId ) );
}
@@ -152,17 +161,17 @@ void MapViewWidget::setMarbleWidget( MarbleWidget *widget )
d->m_widget, SLOT( setMapThemeId( const QString& ) ) );
d->setMapThemeModel( widget->model()->mapThemeManager()->mapThemeModel() );
- updateMapThemeView();
+ d->updateMapThemeView();
}
-void MapViewWidget::updateMapThemeView()
+void MapViewWidgetPrivate::updateMapThemeView()
{
updateCelestialModel();
- if ( d->m_widget ) {
- QString mapThemeId = d->m_widget->mapThemeId();
+ if ( m_widget ) {
+ QString mapThemeId = m_widget->mapThemeId();
if ( !mapThemeId.isEmpty() )
- setMapThemeId( mapThemeId );
+ m_parent->setMapThemeId( mapThemeId );
}
}
@@ -218,22 +227,22 @@ void MapViewWidget::setProjection( Projection projection )
d->m_mapViewUi.projectionComboBox->setCurrentIndex( (int) projection );
}
-void MapViewWidget::selectCurrentMapTheme( const QString& celestialBodyId )
+void MapViewWidgetPrivate::selectCurrentMapTheme( const QString& celestialBodyId )
{
Q_UNUSED( celestialBodyId )
- d->setMapThemeModel( d->m_mapThemeModel );
+ setMapThemeModel( m_mapThemeModel );
bool foundMapTheme = false;
- QString currentMapThemeId = d->m_widget->mapThemeId();
+ QString currentMapThemeId = m_widget->mapThemeId();
- int row = d->m_mapSortProxy->rowCount();
+ int row = m_mapSortProxy->rowCount();
for ( int i = 0; i < row; ++i )
{
- QModelIndex index = d->m_mapSortProxy->index(i,1);
- QString itMapThemeId = d->m_mapSortProxy->data(index).toString();
+ QModelIndex index = m_mapSortProxy->index(i,1);
+ QString itMapThemeId = m_mapSortProxy->data(index).toString();
if ( currentMapThemeId == itMapThemeId )
{
foundMapTheme = true;
@@ -241,17 +250,17 @@ void MapViewWidget::selectCurrentMapTheme( const QString& celestialBodyId )
}
}
if ( !foundMapTheme ) {
- QModelIndex index = d->m_mapSortProxy->index(0,1);
- d->m_widget->setMapThemeId( d->m_mapSortProxy->data(index).toString());
+ QModelIndex index = m_mapSortProxy->index(0,1);
+ m_widget->setMapThemeId( m_mapSortProxy->data(index).toString());
}
updateMapThemeView();
}
// Relay a signal and convert the parameter from an int to a Projection.
-void MapViewWidget::projectionSelected( int projectionIndex )
+void MapViewWidgetPrivate::projectionSelected( int projectionIndex )
{
- emit projectionChanged( (Projection) projectionIndex );
+ emit m_parent->projectionChanged( (Projection) projectionIndex );
}
}
diff --git a/src/lib/MapViewWidget.h b/src/lib/MapViewWidget.h
index 21f6057..b7a1e8e 100644
--- a/src/lib/MapViewWidget.h
+++ b/src/lib/MapViewWidget.h
@@ -44,19 +44,18 @@ class MARBLE_EXPORT MapViewWidget : public QWidget
*/
void setMarbleWidget( MarbleWidget *widget );
- void updateCelestialModel();
-
public Q_SLOTS:
void setMapThemeId( const QString & );
void setProjection( Projection projection );
- void selectCurrentMapTheme( const QString& );
+ private:
+ Q_PRIVATE_SLOT( d, void selectCurrentMapTheme( const QString& ) )
/// whenever a new map gets inserted, the following slot will adapt the ListView accordingly
- void updateMapThemeView();
+ Q_PRIVATE_SLOT( d, void updateMapThemeView() )
- void projectionSelected( int projectionIndex );
+ Q_PRIVATE_SLOT( d, void projectionSelected( int projectionIndex ) )
Q_SIGNALS:
void mapThemeIdChanged( const QString& );
@@ -67,6 +66,7 @@ class MARBLE_EXPORT MapViewWidget : public QWidget
private:
Q_DISABLE_COPY( MapViewWidget )
+ friend class MapViewWidgetPrivate;
MapViewWidgetPrivate * const d;
};
diff --git a/src/lib/MarbleControlBox.cpp b/src/lib/MarbleControlBox.cpp
index ccb0316..1faaba5 100644
--- a/src/lib/MarbleControlBox.cpp
+++ b/src/lib/MarbleControlBox.cpp
@@ -229,11 +229,6 @@ void MarbleControlBox::setWorkOffline(bool offline)
d->m_widget->model()->setWorkOffline( offline );
}
-void MarbleControlBox::updateMapThemeView()
-{
- d->m_mapViewWidget->updateMapThemeView();
-}
-
CurrentLocationWidget * MarbleControlBox::currentLocationWidget()
{
return d->m_currentLocationWidget;
diff --git a/src/lib/MarbleControlBox.h b/src/lib/MarbleControlBox.h
index 57a9407..bbb0486 100644
--- a/src/lib/MarbleControlBox.h
+++ b/src/lib/MarbleControlBox.h
@@ -103,8 +103,6 @@ class MARBLE_EXPORT MarbleControlBox : public QToolBox
public Q_SLOTS:
void selectTheme( const QString & );
- void updateMapThemeView();
-
/**
* @brief Control whether the Navigation tab is shown.
* @param show boolean that controls if the Navigation tab is shown.
More information about the Kde-bindings
mailing list