[Marble-commits] KDE/kdeedu/marble/src
Bastian Holst
bastianholst at gmx.de
Sun Oct 3 21:20:36 CEST 2010
SVN commit 1182202 by bholst:
It is now possible to use MapViewWidget easily without using ControlView
M +0 -3 ControlView.cpp
M +43 -25 lib/MapViewWidget.cpp
M +0 -2 lib/MapViewWidget.h
M +0 -5 lib/MarbleControlBox.cpp
M +0 -2 lib/MarbleControlBox.h
--- trunk/KDE/kdeedu/marble/src/ControlView.cpp #1182201:1182202
@@ -79,9 +79,6 @@
// TODO: Creating a second MapThemeManager may not be the best solution here.
// MarbleModel also holds one with a QFileSystemWatcher.
m_mapThemeManager = new MapThemeManager;
-
- m_control->setMapThemeModel( m_mapThemeManager->mapThemeModel() );
- m_control->updateMapThemeView();
}
ControlView::~ControlView()
--- trunk/KDE/kdeedu/marble/src/lib/MapViewWidget.cpp #1182201:1182202
@@ -16,6 +16,7 @@
// Marble
#include "MarbleWidget.h"
+#include "MapThemeManager.h"
#include "MapThemeSortFilterProxyModel.h"
#include "Planet.h"
#include "GeoSceneDocument.h"
@@ -33,9 +34,41 @@
class MapViewWidgetPrivate {
public:
+ MapViewWidgetPrivate( MapViewWidget *parent )
+ : m_parent( parent ),
+ m_mapThemeManager( 0 )
+ {
+ }
+
+ void setMapThemeModel( QStandardItemModel *mapThemeModel )
+ {
+ if ( mapThemeModel != m_mapThemeModel ) {
+ delete m_mapThemeModel;
+ }
+
+ m_mapThemeModel = mapThemeModel;
+ m_mapSortProxy->setSourceModel( m_mapThemeModel );
+ int currentIndex = m_mapViewUi.celestialBodyComboBox->currentIndex();
+ QStandardItem * selectedItem = m_celestialList->item( currentIndex, 1 );
+
+ if ( selectedItem ) {
+ QString selectedId;
+ selectedId = selectedItem->text();
+ m_mapSortProxy->setFilterRegExp( QRegExp( selectedId, Qt::CaseInsensitive,QRegExp::FixedString ) );
+ }
+
+ m_mapSortProxy->sort( 0 );
+ m_mapViewUi.marbleThemeSelectView->setModel( m_mapSortProxy );
+ QObject::connect( m_mapThemeModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ),
+ m_parent, SLOT( updateMapThemeView() ) );
+ }
+
+ MapViewWidget *m_parent;
+
Ui::MapViewWidget m_mapViewUi;
MarbleWidget *m_widget;
+ MapThemeManager *m_mapThemeManager;
QStandardItemModel *m_mapThemeModel;
MapThemeSortFilterProxyModel *m_mapSortProxy;
@@ -44,7 +77,7 @@
MapViewWidget::MapViewWidget( QWidget *parent, Qt::WindowFlags f )
: QWidget( parent, f ),
- d( new MapViewWidgetPrivate() )
+ d( new MapViewWidgetPrivate( this ) )
{
d->m_mapViewUi.setupUi( this );
@@ -79,29 +112,6 @@
delete d->m_celestialList;
}
-void MapViewWidget::setMapThemeModel( QStandardItemModel *mapThemeModel )
-{
- if ( mapThemeModel != d->m_mapThemeModel ) {
- delete d->m_mapThemeModel;
- }
-
- d->m_mapThemeModel = mapThemeModel;
- d->m_mapSortProxy->setSourceModel( d->m_mapThemeModel );
- int currentIndex = d->m_mapViewUi.celestialBodyComboBox->currentIndex();
- QStandardItem * selectedItem = d->m_celestialList->item( currentIndex, 1 );
-
- if ( selectedItem ) {
- QString selectedId;
- selectedId = selectedItem->text();
- d->m_mapSortProxy->setFilterRegExp( QRegExp( selectedId, Qt::CaseInsensitive,QRegExp::FixedString ) );
- }
-
- d->m_mapSortProxy->sort( 0 );
- d->m_mapViewUi.marbleThemeSelectView->setModel( d->m_mapSortProxy );
- connect( d->m_mapThemeModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ),
- this, SLOT( updateMapThemeView() ) );
-}
-
void MapViewWidget::updateCelestialModel()
{
int row = d->m_mapThemeModel->rowCount();
@@ -136,7 +146,15 @@
connect( this, SIGNAL( selectMapTheme( const QString& ) ),
d->m_widget, SLOT( setMapThemeId( const QString& ) ) );
+
+ // TODO: Creating a second MapThemeManager may not be the best solution here.
+ // MarbleModel also holds one with a QFileSystemWatcher.
+ if( !d->m_mapThemeManager ) {
+ d->m_mapThemeManager = new MapThemeManager();
+ d->setMapThemeModel( d->m_mapThemeManager->mapThemeModel() );
+ updateMapThemeView();
}
+}
void MapViewWidget::updateMapThemeView()
{
@@ -205,7 +223,7 @@
{
Q_UNUSED( celestialBodyId )
- setMapThemeModel( d->m_mapThemeModel );
+ d->setMapThemeModel( d->m_mapThemeModel );
bool foundMapTheme = false;
--- trunk/KDE/kdeedu/marble/src/lib/MapViewWidget.h #1182201:1182202
@@ -44,8 +44,6 @@
*/
void setMarbleWidget( MarbleWidget *widget );
- void setMapThemeModel( QStandardItemModel *mapThemeModel );
-
void updateCelestialModel();
public Q_SLOTS:
--- trunk/KDE/kdeedu/marble/src/lib/MarbleControlBox.cpp #1182201:1182202
@@ -224,11 +224,6 @@
}
}
-void MarbleControlBox::setMapThemeModel( QStandardItemModel *mapThemeModel )
-{
- d->m_mapViewWidget->setMapThemeModel( mapThemeModel );
-}
-
void MarbleControlBox::updateMapThemeView()
{
d->m_mapViewWidget->updateMapThemeView();
--- trunk/KDE/kdeedu/marble/src/lib/MarbleControlBox.h #1182201:1182202
@@ -95,8 +95,6 @@
*/
void setWorkOffline(bool offline);
- void setMapThemeModel( QStandardItemModel *mapThemeModel );
-
public Q_SLOTS:
void selectTheme( const QString & );
More information about the Marble-commits
mailing list