[Kde-bindings] [marble] src/lib: LegendWidget: depend on MarbleModel rather than on MarbleWidget
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Mon Nov 21 14:23:50 UTC 2011
Git commit 56bfc0f61614eedfc85fdc5640367d4341132754 by Bernhard Beschow.
Committed on 21/11/2011 at 13:14.
Pushed by beschow into branch 'master'.
LegendWidget: depend on MarbleModel rather than on MarbleWidget
CCMAIL: kde-bindings at kde.org
M +4 -4 src/lib/LegendWidget.cpp
M +5 -2 src/lib/LegendWidget.h
M +4 -1 src/lib/MarbleControlBox.cpp
M +14 -19 src/lib/MarbleLegendBrowser.cpp
M +2 -2 src/lib/MarbleLegendBrowser.h
http://commits.kde.org/marble/56bfc0f61614eedfc85fdc5640367d4341132754
diff --git a/src/lib/LegendWidget.cpp b/src/lib/LegendWidget.cpp
index 2c966db..b713cff 100644
--- a/src/lib/LegendWidget.cpp
+++ b/src/lib/LegendWidget.cpp
@@ -12,7 +12,7 @@
#include "LegendWidget.h"
// Marble
-#include "MarbleWidget.h"
+#include "MarbleModel.h"
using namespace Marble;
// Ui
@@ -39,14 +39,14 @@ LegendWidget::~LegendWidget()
delete d;
}
-void LegendWidget::setMarbleWidget( MarbleWidget *widget )
+void LegendWidget::setMarbleModel( MarbleModel *model )
{
// Initialize the MarbleLegendBrowser
- d->m_legendUi.marbleLegendBrowser->setMarbleWidget( widget );
+ d->m_legendUi.marbleLegendBrowser->setMarbleModel( model );
// connect signals for the Legend
connect( d->m_legendUi.marbleLegendBrowser, SIGNAL( toggledShowProperty( QString, bool ) ),
- widget, SLOT( setPropertyValue( QString, bool ) ) );
+ this, SIGNAL( propertyValueChanged( const QString &, bool ) ) );
}
}
diff --git a/src/lib/LegendWidget.h b/src/lib/LegendWidget.h
index acf927f..0523a0e 100644
--- a/src/lib/LegendWidget.h
+++ b/src/lib/LegendWidget.h
@@ -22,7 +22,7 @@ namespace Marble
class LegendWidgetPrivate;
-class MarbleWidget;
+class MarbleModel;
class MARBLE_EXPORT LegendWidget : public QWidget
{
@@ -36,7 +36,10 @@ class MARBLE_EXPORT LegendWidget : public QWidget
* @brief Set a MarbleWidget associated to this widget.
* @param widget the MarbleWidget to be set.
*/
- void setMarbleWidget( MarbleWidget *widget );
+ void setMarbleModel( MarbleModel *model );
+
+ Q_SIGNALS:
+ void propertyValueChanged( const QString &propertyName, bool value );
private:
Q_DISABLE_COPY( LegendWidget )
diff --git a/src/lib/MarbleControlBox.cpp b/src/lib/MarbleControlBox.cpp
index b03a14d..ccb0316 100644
--- a/src/lib/MarbleControlBox.cpp
+++ b/src/lib/MarbleControlBox.cpp
@@ -121,7 +121,7 @@ void MarbleControlBox::setMarbleWidget(MarbleWidget *widget)
d->m_fileViewWidget->setFileViewModel( widget->model()->fileViewModel() );
d->m_fileViewWidget->setTreeModel( widget->model()->treeModel() );
- d->m_legendWidget->setMarbleWidget( widget );
+ d->m_legendWidget->setMarbleModel( widget->model() );
d->m_navigationWidget->setMarbleWidget( widget );
d->m_mapViewWidget->setMarbleWidget( widget );
d->m_currentLocationWidget->setMarbleWidget( widget );
@@ -131,6 +131,9 @@ void MarbleControlBox::setMarbleWidget(MarbleWidget *widget)
connect( d->m_fileViewWidget, SIGNAL( centerOn( const GeoDataLatLonBox &, bool ) ),
widget, SLOT( centerOn( const GeoDataLatLonBox &, bool ) ) );
+ connect( d->m_legendWidget, SIGNAL( propertyValueChanged( const QString &, bool ) ),
+ widget, SLOT( setPropertyValue( const QString &, bool ) ) );
+
connect( d->m_widget, SIGNAL( themeChanged( QString ) ),
this, SLOT( selectTheme( QString ) ) );
}
diff --git a/src/lib/MarbleLegendBrowser.cpp b/src/lib/MarbleLegendBrowser.cpp
index 2145ffb..4a25095 100644
--- a/src/lib/MarbleLegendBrowser.cpp
+++ b/src/lib/MarbleLegendBrowser.cpp
@@ -33,7 +33,6 @@
#include "GeoSceneItem.h"
#include "GeoSceneProperty.h"
#include "GeoSceneSettings.h"
-#include "MarbleWidget.h"
#include "MarbleModel.h"
#include "MarbleDebug.h"
@@ -45,7 +44,7 @@ namespace Marble
class MarbleLegendBrowserPrivate
{
public:
- MarbleWidget *m_marbleWidget;
+ MarbleModel *m_marbleModel;
QMap<QString, bool> m_checkBoxMap;
QMap<QString, QPixmap> m_symbolMap;
bool m_isLegendLoaded;
@@ -60,7 +59,7 @@ MarbleLegendBrowser::MarbleLegendBrowser( QWidget *parent )
d( new MarbleLegendBrowserPrivate )
{
d->m_isLegendLoaded = false;
- d->m_marbleWidget = 0;
+ d->m_marbleModel = 0;
// Disable changing layout due to the ScrollBarPolicy:
setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
@@ -79,13 +78,13 @@ MarbleLegendBrowser::~MarbleLegendBrowser()
delete d;
}
-void MarbleLegendBrowser::setMarbleWidget( MarbleWidget *marbleWidget )
+void MarbleLegendBrowser::setMarbleModel( MarbleModel *marbleModel )
{
// We need this to be able to get to the MapTheme.
- d->m_marbleWidget = marbleWidget;
+ d->m_marbleModel = marbleModel;
- if ( d->m_marbleWidget ) {
- connect ( d->m_marbleWidget, SIGNAL( themeChanged( QString ) ),
+ if ( d->m_marbleModel ) {
+ connect ( d->m_marbleModel, SIGNAL( themeChanged( QString ) ),
this, SLOT( initTheme() ) );
}
}
@@ -95,11 +94,9 @@ void MarbleLegendBrowser::initTheme()
mDebug() << "initTheme";
// Check for a theme specific legend.html first
- if ( d->m_marbleWidget != 0
- && d->m_marbleWidget->model() != 0
- && d->m_marbleWidget->model()->mapTheme() != 0 )
+ if ( d->m_marbleModel != 0 && d->m_marbleModel->mapTheme() != 0 )
{
- GeoSceneDocument *currentMapTheme = d->m_marbleWidget->model()->mapTheme();
+ GeoSceneDocument *currentMapTheme = d->m_marbleModel->mapTheme();
QVector<GeoSceneProperty*> allProperties = currentMapTheme->settings()->allProperties();
@@ -136,11 +133,9 @@ void MarbleLegendBrowser::loadLegend()
QString finalHtml;
// Check for a theme specific legend.html first
- if ( d->m_marbleWidget != 0
- && d->m_marbleWidget->model() != 0
- && d->m_marbleWidget->model()->mapTheme() != 0 )
+ if ( d->m_marbleModel != 0 && d->m_marbleModel->mapTheme() != 0 )
{
- GeoSceneDocument *currentMapTheme = d->m_marbleWidget->model()->mapTheme();
+ GeoSceneDocument *currentMapTheme = d->m_marbleModel->mapTheme();
QString customLegendPath = MarbleDirs::path( "maps/" +
currentMapTheme->head()->target() + '/' +
@@ -174,8 +169,8 @@ void MarbleLegendBrowser::loadLegend()
d->m_isLegendLoaded = true;
qDebug("loadLegend: Time elapsed: %d ms", t.elapsed());
- if ( d->m_marbleWidget ) {
- d->m_marbleWidget->model()->setLegend( document() );
+ if ( d->m_marbleModel ) {
+ d->m_marbleModel->setLegend( document() );
}
}
@@ -231,10 +226,10 @@ QString MarbleLegendBrowser::generateSectionsHtml()
QString customLegendString;
- if ( d->m_marbleWidget == 0 || d->m_marbleWidget->model() == 0 || d->m_marbleWidget->model()->mapTheme() == 0 )
+ if ( d->m_marbleModel == 0 || d->m_marbleModel->mapTheme() == 0 )
return QString();
- GeoSceneDocument *currentMapTheme = d->m_marbleWidget->model()->mapTheme();
+ GeoSceneDocument *currentMapTheme = d->m_marbleModel->mapTheme();
QVector<GeoSceneSection*> sections = currentMapTheme->legend()->sections();
diff --git a/src/lib/MarbleLegendBrowser.h b/src/lib/MarbleLegendBrowser.h
index 97534ec..c526ff8 100644
--- a/src/lib/MarbleLegendBrowser.h
+++ b/src/lib/MarbleLegendBrowser.h
@@ -28,7 +28,7 @@ class QUrl;
namespace Marble
{
-class MarbleWidget;
+class MarbleModel;
class MarbleLegendBrowserPrivate;
class MARBLE_EXPORT MarbleLegendBrowser : public QTextBrowser
@@ -39,7 +39,7 @@ class MARBLE_EXPORT MarbleLegendBrowser : public QTextBrowser
explicit MarbleLegendBrowser( QWidget* parent );
~MarbleLegendBrowser();
- void setMarbleWidget( MarbleWidget *marbleWidget );
+ void setMarbleModel( MarbleModel *marbleModel );
public Q_SLOTS:
void setCheckedProperty( const QString& name, bool checked );
More information about the Kde-bindings
mailing list