[Marble-commits] KDE/kdeedu/marble
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Tue Oct 12 11:45:52 CEST 2010
SVN commit 1185076 by beschow:
handle dirty-flag within MarbleMap which makes its usage simpler
* remove or make private Marble{Map, Widget}::{needsUpdate(), setNeedsUpdate(), updateChangedMap()}
RB: 5534
M +6 -0 docs/release_notes/APIChanges-0.11.txt
M +1 -1 src/QtMainWindow.cpp
M +21 -26 src/lib/MarbleMap.cpp
M +6 -15 src/lib/MarbleMap.h
M +10 -0 src/lib/MarbleMap_p.h
M +12 -36 src/lib/MarbleWidget.cpp
M +0 -14 src/lib/MarbleWidget.h
M +0 -16 src/lib/MarbleWidgetInputHandler.cpp
M +0 -6 src/lib/NavigationWidget.cpp
M +1 -1 src/marble_part.cpp
M +2 -5 src/plasmoid/worldclock.cpp
M +0 -5 src/plugins/render/navigation/NavigationFloatItem.cpp
--- trunk/KDE/kdeedu/marble/docs/release_notes/APIChanges-0.11.txt #1185075:1185076
@@ -44,3 +44,9 @@
* Remove Marble{Map, Widget}::{north,south}PolePosition().
Use Marble{Map, Widget}::screenCoordinates( 0.0, poleLat, ... ) instead, where poleLat is +90 for the north pole and -90 for the south pole.
Feel free to request constants like Marble::NorthPole and Marble::SouthPole if you use the screen coordinates of the poles in your application.
+
+2010-10-05 Bernhard Beschow <bbeschow at cs.tu-berlin.de>
+
+* Remove or make private Marble{Map, Widget}::{needsUpdate(), setNeedsUpdate(), updateChangedMap()}.
+ There is no need to call these methods any more since they are invoked internally when needed.
+ It should be safe to remove any code that calls these methods from outside MarbleMap/MarbleWidget.
--- trunk/KDE/kdeedu/marble/src/QtMainWindow.cpp #1185075:1185076
@@ -1043,7 +1043,7 @@
m_controlView->marbleWidget()->setProxy( m_configDialog->proxyUrl(), m_configDialog->proxyPort(), m_configDialog->user(), m_configDialog->password() );
*/
- m_controlView->marbleWidget()->updateChangedMap();
+ m_controlView->marbleWidget()->update();
}
void MainWindow::showDownloadRegionDialog()
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.cpp #1185075:1185076
@@ -75,7 +75,7 @@
m_parent->connect( m_model, SIGNAL( themeChanged( QString ) ),
m_parent, SIGNAL( themeChanged( QString ) ) );
m_parent->connect( m_model, SIGNAL( modelChanged() ),
- m_parent, SLOT( updateChangedMap() ) );
+ m_parent, SLOT( setNeedsUpdate() ) );
m_justModified = false;
m_dirtyAtmosphere = false;
@@ -210,7 +210,7 @@
}
m_model->paintGlobe( &painter, &m_viewParams,
- m_parent->needsUpdate() || m_viewParams.canvasImage()->isNull(),
+ needsUpdate() || m_viewParams.canvasImage()->isNull(),
dirtyRect );
// FIXME: this is ugly, add method updatePlanetAxis() to ViewParams
m_viewParams.setPlanetAxisUpdated( m_viewParams.planetAxis() );
@@ -322,6 +322,8 @@
void MarbleMap::setMapQuality( MapQuality quality )
{
d->m_viewParams.setMapQuality( quality );
+ // Update texture map during the repaint that follows:
+ d->setNeedsUpdate();
}
MapQuality MarbleMap::mapQuality() const
@@ -378,9 +380,7 @@
{
d->m_viewParams.setRadius( radius );
- if ( !mapCoversViewport() ) {
- setNeedsUpdate();
- }
+ d->setNeedsUpdate();
d->m_logzoom = d->zoom( radius );
emit zoomChanged( d->m_logzoom );
@@ -389,16 +389,16 @@
}
-bool MarbleMap::needsUpdate() const
+bool MarbleMapPrivate::needsUpdate() const
{
- return ( d->m_justModified
- || d->m_viewParams.radius() != d->m_viewParams.radiusUpdated()
- || !( d->m_viewParams.planetAxis() == d->m_viewParams.planetAxisUpdated() ) );
+ return ( m_justModified
+ || m_viewParams.radius() != m_viewParams.radiusUpdated()
+ || !( m_viewParams.planetAxis() == m_viewParams.planetAxisUpdated() ) );
}
-void MarbleMap::setNeedsUpdate()
+void MarbleMapPrivate::setNeedsUpdate()
{
- d->m_justModified = true;
+ m_justModified = true;
}
@@ -759,7 +759,7 @@
d->m_model->setupTextureMapper( projection );
// Update texture map during the repaint that follows:
- setNeedsUpdate();
+ d->setNeedsUpdate();
emit visibleLatLonAltBoxChanged( d->m_viewParams.viewport()->viewLatLonAltBox() );
}
@@ -829,16 +829,17 @@
d->m_dirtyAtmosphere=true;
centerSun();
+ }
// Update texture map during the repaint that follows:
- setNeedsUpdate();
+ d->setNeedsUpdate();
}
-}
void MarbleMap::setPropertyValue( const QString& name, bool value )
{
mDebug() << "In MarbleMap the property " << name << "was set to " << value;
d->m_viewParams.setPropertyValue( name, value );
+ d->setNeedsUpdate();
}
void MarbleMap::setShowOverviewMap( bool visible )
@@ -883,7 +884,7 @@
void MarbleMap::setShowClouds( bool visible )
{
d->m_viewParams.setShowClouds( visible );
- setNeedsUpdate();
+ d->setNeedsUpdate();
}
void MarbleMap::setShowTileId( bool visible )
@@ -920,21 +921,21 @@
{
setPropertyValue( "relief", visible );
// Update texture map during the repaint that follows:
- setNeedsUpdate();
+ d->setNeedsUpdate();
}
void MarbleMap::setShowElevationModel( bool visible )
{
d->m_viewParams.setShowElevationModel( visible );
// Update texture map during the repaint that follows:
- setNeedsUpdate();
+ d->setNeedsUpdate();
}
void MarbleMap::setShowIceLayer( bool visible )
{
setPropertyValue( "ice", visible );
// Update texture map during the repaint that follows:
- setNeedsUpdate();
+ d->setNeedsUpdate();
}
void MarbleMap::setShowBorders( bool visible )
@@ -951,7 +952,7 @@
{
setPropertyValue( "lakes", visible );
// Update texture map during the repaint that follows:
- setNeedsUpdate();
+ d->setNeedsUpdate();
}
void MarbleMap::setShowFrameRate( bool visible )
@@ -1007,12 +1008,6 @@
d->m_model->setVolatileTileCacheLimit( kilobytes );
}
-void MarbleMap::updateChangedMap()
-{
- // Update texture map during the repaint that follows:
- setNeedsUpdate();
-}
-
QString MarbleMap::distanceString() const
{
qreal dist = distance();
@@ -1074,7 +1069,7 @@
mDebug() << "MarbleMap: Updating the sun shading map...";
d->m_model->update();
- setNeedsUpdate();
+ d->setNeedsUpdate();
//mDebug() << "Finished updating the sun shading map";
}
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.h #1185075:1185076
@@ -179,16 +179,6 @@
int maximumZoom() const;
/**
- * @brief return if the map needs to be updated.
- */
- bool needsUpdate() const;
-
- /**
- * @brief Mark the map as needing an update.
- */
- void setNeedsUpdate();
-
- /**
* @brief Get the screen coordinates corresponding to geographical coordinates in the map.
* @param lon the lon coordinate of the requested pixel position
* @param lat the lat coordinate of the requested pixel position
@@ -707,11 +697,6 @@
*/
void setVolatileTileCacheLimit( quint64 kiloBytes );
- /**
- * @brief Update the map because the model changed.
- */
- void updateChangedMap();
-
bool mapCoversViewport();
AngleUnit defaultAngleUnit() const;
@@ -773,6 +758,12 @@
virtual void customPaint( GeoPainter *painter );
private:
+ /**
+ * @brief Request a full repaint of the map during next update.
+ */
+ Q_PRIVATE_SLOT( d, void setNeedsUpdate() )
+
+ private:
Q_DISABLE_COPY( MarbleMap )
MarbleMapPrivate * const d;
};
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap_p.h #1185075:1185076
@@ -50,6 +50,16 @@
void paintOverlay( GeoPainter &painter, QRect &dirtyRect);
void paintFps( GeoPainter &painter, QRect &dirtyRect, qreal fps);
+ /**
+ * @brief return if the map needs to be updated.
+ */
+ bool needsUpdate() const;
+
+ /**
+ * @brief Mark the map as needing an update.
+ */
+ void setNeedsUpdate();
+
MarbleMap *m_parent;
// The model we are showing.
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.cpp #1185075:1185076
@@ -188,8 +188,6 @@
// show this in the view, i.e. here.
m_widget->connect( m_model, SIGNAL( themeChanged( QString ) ),
m_widget, SIGNAL( themeChanged( QString ) ) );
- m_widget->connect( m_model, SIGNAL( modelChanged() ),
- m_widget, SLOT( updateChangedMap() ) );
// Repaint scheduling
m_widget->connect( m_map, SIGNAL( repaintNeeded( QRegion ) ),
@@ -340,17 +338,6 @@
}
-bool MarbleWidget::needsUpdate() const
-{
- return d->m_map->needsUpdate();
-}
-
-void MarbleWidget::setNeedsUpdate()
-{
- d->m_map->setNeedsUpdate();
-}
-
-
QAbstractItemModel *MarbleWidget::placemarkModel() const
{
return d->m_map->placemarkModel();
@@ -837,9 +824,6 @@
d->m_map->setMapThemeId( mapThemeId );
- // Update texture map during the repaint that follows:
- setNeedsUpdate();
-
// Now we want a full repaint as the atmosphere might differ
setAttribute( Qt::WA_NoSystemBackground,
false );
@@ -859,8 +843,6 @@
mDebug() << "In MarbleWidget the property " << name << "was set to " << value;
d->m_map->setPropertyValue( name, value );
- // Update texture map during the repaint that follows:
- setNeedsUpdate();
repaint();
}
@@ -1056,13 +1038,6 @@
dlg.exec();
}
-void MarbleWidget::updateChangedMap()
-{
- // Update texture map during the repaint that follows:
- setNeedsUpdate();
- update();
-}
-
void MarbleWidget::scheduleRepaint( const QRegion& dirtyRegion )
{
Q_UNUSED( dirtyRegion );
@@ -1080,14 +1055,16 @@
return d->m_animationQuality;
}
-void MarbleWidget::setMapQuality( MapQuality mapQuality, ViewContext changedViewContext )
+void MarbleWidget::setMapQuality( MapQuality quality, ViewContext changedViewContext )
{
+ const MapQuality oldQuality = mapQuality( viewContext() );
+
// FIXME: Rewrite as a switch
if ( changedViewContext == Still ) {
- d->m_stillQuality = mapQuality;
+ d->m_stillQuality = quality;
}
else if ( changedViewContext == Animation ) {
- d->m_animationQuality = mapQuality;
+ d->m_animationQuality = quality;
}
if ( viewContext() == Still ) {
@@ -1097,6 +1074,9 @@
{
map()->setMapQuality( d->m_animationQuality );
}
+
+ if ( mapQuality( viewContext() ) != oldQuality )
+ d->repaint();
}
ViewContext MarbleWidget::viewContext() const
@@ -1112,6 +1092,9 @@
map()->setMapQuality( d->m_stillQuality );
if ( viewContext == Animation )
map()->setMapQuality( d->m_animationQuality );
+
+ if ( mapQuality( viewContext ) != mapQuality( Animation ) )
+ d->repaint();
}
bool MarbleWidget::animationsEnabled() const
@@ -1183,13 +1166,7 @@
void MarbleWidget::updateSun()
{
- // Update the sun shading.
- //SunLocator *sunLocator = d->m_model->sunLocator();
-
- mDebug() << "MarbleWidget: Updating the sun shading map...";
- d->m_model->update();
- setNeedsUpdate();
- //mDebug() << "Finished updating the sun shading map";
+ d->m_map->updateSun();
}
void MarbleWidget::centerSun()
@@ -1317,7 +1294,6 @@
void MarbleWidget::startStillMode()
{
setViewContext( Marble::Still );
- setNeedsUpdate();
d->repaint();
}
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.h #1185075:1185076
@@ -246,15 +246,6 @@
int maximumZoom() const;
/**
- * @brief Return if the widget needs to be updated.
- */
- bool needsUpdate() const;
- /**
- * @brief Mark the widget as needing an update.
- */
- void setNeedsUpdate();
-
- /**
* @brief Get the screen coordinates corresponding to geographical coordinates in the widget.
* @param lon the lon coordinate of the requested pixel position
* @param lat the lat coordinate of the requested pixel position
@@ -908,11 +899,6 @@
void creatingTilesStart( TileCreator *creator, const QString& name, const QString& description );
/**
- * @brief Update the widget because the model changed.
- */
- void updateChangedMap();
-
- /**
* Schedule repaint
*/
void scheduleRepaint( const QRegion& dirtyRegion );
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidgetInputHandler.cpp #1185075:1185076
@@ -326,12 +326,6 @@
// Redraw the map with the quality set for Still (if necessary).
d->m_widget->setViewContext( Still );
- if ( d->m_widget->mapQuality( Still )
- != d->m_widget->mapQuality( Animation ) )
- {
- d->m_widget->updateChangedMap();
- }
-
d->m_widget->viewport()->resetFocusPoint();
d->m_wheelZoomTargetDistance = 0.0;
}
@@ -574,11 +568,6 @@
emit mouseClickScreenPosition( d->m_leftPressedX, d->m_leftPressedY );
MarbleWidgetInputHandler::d->m_widget->setViewContext( Still );
- if ( MarbleWidgetInputHandler::d->m_widget->mapQuality( Still )
- != MarbleWidgetInputHandler::d->m_widget->mapQuality( Animation ) )
- {
- MarbleWidgetInputHandler::d->m_widget->updateChangedMap();
- }
d->m_leftPressed = false;
}
@@ -588,12 +577,7 @@
d->m_midPressed = false;
MarbleWidgetInputHandler::d->m_widget->setViewContext( Still );
- if ( MarbleWidgetInputHandler::d->m_widget->mapQuality( Still )
- != MarbleWidgetInputHandler::d->m_widget->mapQuality( Animation ) )
- {
- MarbleWidgetInputHandler::d->m_widget->updateChangedMap();
}
- }
if ( e->type() == QEvent::MouseButtonRelease
&& event->button() == Qt::RightButton) {
--- trunk/KDE/kdeedu/marble/src/lib/NavigationWidget.cpp #1185075:1185076
@@ -246,13 +246,7 @@
return;
d->m_widget->setViewContext( Still );
-
- if ( d->m_widget->mapQuality( Still )
- != d->m_widget->mapQuality( Animation ) )
- {
- d->m_widget->updateChangedMap();
}
-}
void NavigationWidget::resizeEvent ( QResizeEvent * )
{
--- trunk/KDE/kdeedu/marble/src/marble_part.cpp #1185075:1185076
@@ -1340,7 +1340,7 @@
QNetworkProxy::setApplicationProxy(proxy);
- m_controlView->marbleWidget()->updateChangedMap();
+ m_controlView->marbleWidget()->update();
// Show message box
if ( m_initialGraphicsSystem != graphicsSystem
--- trunk/KDE/kdeedu/marble/src/plasmoid/worldclock.cpp #1185075:1185076
@@ -104,7 +104,6 @@
m_sun->update();
m_map->updateSun();
- m_map->setNeedsUpdate();
m_customTz = cg.readEntry("customtz", false );
m_locationkey = KSystemTimeZones::local().name();
@@ -182,7 +181,6 @@
m_map->setSize(width, height);
m_map->setRadius( radius );
- m_map->setNeedsUpdate();
update();
if(changeAspect) {
QRectF curGeo = geometry();
@@ -202,7 +200,6 @@
//kDebug() << "Adjusted Time = " << m_time;
m_sun->update();
m_map->updateSun();
- m_map->setNeedsUpdate();
update();
}
@@ -475,7 +472,7 @@
case 1:
//kDebug() << "case 1, setting proj to mercator";
m_map->setProjection(Mercator);
- m_map->setNeedsUpdate(); update();
+ update();
resizeMap(true);
cg.writeEntry("projection", static_cast<int>(Mercator));
break;
@@ -483,7 +480,7 @@
default:
//kDebug() << "case default, setting proj to Equirectangular";
m_map->setProjection(Equirectangular);
- m_map->setNeedsUpdate(); update();
+ update();
resizeMap(true);
cg.writeEntry("projection", static_cast<int>(Equirectangular));
break;
--- trunk/KDE/kdeedu/marble/src/plugins/render/navigation/NavigationFloatItem.cpp #1185075:1185076
@@ -259,12 +259,7 @@
}
m_marbleWidget->setViewContext( Still );
-
- if ( m_marbleWidget->mapQuality( Still )
- != m_marbleWidget->mapQuality( Animation ) ) {
- m_marbleWidget->updateChangedMap();
}
-}
void NavigationFloatItem::updateButtons( int zoomValue )
{
More information about the Marble-commits
mailing list