[Marble-commits] KDE/kdeedu/marble/src
Jens-Michael Hoffmann
jensmh at gmx.de
Thu Aug 13 20:57:22 CEST 2009
SVN commit 1011005 by jmhoffmann:
Add redisplay/reload feature (like F5 in web browser).
M +6 -0 lib/MarbleMap.cpp
M +8 -0 lib/MarbleMap.h
M +29 -1 lib/MarbleModel.cpp
M +5 -0 lib/MarbleModel.h
M +13 -2 lib/TileLoader.cpp
M +10 -0 lib/TileLoader.h
M +7 -0 marble_part.cpp
M +1 -0 marble_part.h
M +1 -0 marble_part.rc
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.cpp #1011004:1011005
@@ -8,6 +8,7 @@
// Copyright 2006-2009 Torsten Rahn <tackat at kde.org>"
// Copyright 2007 Inge Wallin <ingwa at kde.org>"
// Copyright 2008 Carlos Licea <carlos.licea at kdemail.net>
+// Copyright 2009 Jens-Michael Hoffmann <jensmh at gmx.de>
//
@@ -596,6 +597,11 @@
return screenshotPixmap;
}
+void MarbleMap::reload() const
+{
+ d->m_model->reloadMap();
+}
+
bool MarbleMap::propertyValue( const QString& name ) const
{
bool value;
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.h #1011004:1011005
@@ -7,6 +7,7 @@
//
// Copyright 2006-2008 Torsten Rahn <tackat at kde.org>"
// Copyright 2007 Inge Wallin <ingwa at kde.org>"
+// Copyright 2009 Jens-Michael Hoffmann <jensmh at gmx.de>
//
@@ -275,6 +276,13 @@
QPixmap mapScreenShot();
/**
+ * @brief Reload the currently displayed map by reloading texture tiles
+ * from the internet. In the future this should be extended to all
+ * kinds of data which is used in the map.
+ */
+ void reload() const;
+
+ /**
* @brief Return the property value by name.
* @return The property value (usually: visibility).
*/
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1011004:1011005
@@ -7,7 +7,7 @@
//
// Copyright 2006-2007 Torsten Rahn <tackat at kde.org>"
// Copyright 2007 Inge Wallin <ingwa at kde.org>"
-// Copyright 2008 Jens-Michael Hoffmann <jensmh at gmx.de>
+// Copyright 2008,2009 Jens-Michael Hoffmann <jensmh at gmx.de>
// Copyright 2008-2009 Patrick Spendrin <ps_ml at gmx.de>
//
@@ -67,6 +67,7 @@
#include "TileCreator.h"
#include "TileCreatorDialog.h"
#include "TileLoader.h"
+#include "TileLoaderHelper.h"
#include "VectorComposer.h"
#include "ViewParams.h"
#include "ViewportParams.h"
@@ -146,6 +147,8 @@
d( new MarbleModelPrivate( this ) )
{
MarbleModelPrivate::refCounter.ref();
+ connect( this, SIGNAL( downloadTile( QUrl, QString, QString )),
+ d->m_downloadManager, SLOT( addJob( QUrl, QString, QString )));
d->m_dataFacade = new MarbleDataFacade( this );
d->m_tileLoader = new TileLoader( d->m_downloadManager, this );
@@ -889,6 +892,31 @@
return d->m_texmapper->tileZoomLevel();
}
+void MarbleModel::reloadMap() const
+{
+ if ( !d->m_mapTheme->map()->hasTextureLayers() )
+ return;
+
+ const QString themeId = d->m_mapTheme->head()->theme();
+ GeoSceneLayer * const layer = static_cast<GeoSceneLayer*>( d->m_mapTheme->map()->
+ layer( themeId ));
+ Q_ASSERT( layer );
+ GeoSceneTexture * const texture = static_cast<GeoSceneTexture*>( layer->groundDataset() );
+ Q_ASSERT( texture );
+
+ Q_ASSERT( d->m_tileLoader );
+ QList<TileId> displayed = d->m_tileLoader->tilesOnDisplay();
+ QList<TileId>::const_iterator pos = displayed.constBegin();
+ QList<TileId>::const_iterator const end = displayed.constEnd();
+ for (; pos != end; ++pos ) {
+ TileId const & id = *pos;
+ QUrl sourceUrl = TileLoaderHelper::downloadUrl( texture, id.zoomLevel(), id.x(), id.y() );
+ QString destFileName = TileLoaderHelper::relativeTileFileName( texture, id.zoomLevel(),
+ id.x(), id.y() );
+ emit downloadTile( sourceUrl, destFileName, id.toString() );
+ }
}
+}
+
#include "MarbleModel.moc"
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.h #1011004:1011005
@@ -295,6 +295,8 @@
*/
int tileZoomLevel() const;
+ void reloadMap() const;
+
public Q_SLOTS:
void clearVolatileTileCache();
/**
@@ -357,6 +359,9 @@
*/
void repaintNeeded( QRegion dirtyRegion );
+ void downloadTile( const QUrl& sourceUrl, const QString& destinationFileName,
+ const QString& id ) const;
+
private:
Q_DISABLE_COPY( MarbleModel )
MarbleModelPrivate * const d;
--- trunk/KDE/kdeedu/marble/src/lib/TileLoader.cpp #1011004:1011005
@@ -3,7 +3,7 @@
*
* Copyright 2005-2007 Torsten Rahn <tackat at kde.org>"
* Copyright 2007 Inge Wallin <ingwa at kde.org>"
- * Copyright 2008 Jens-Michael Hoffmann <jensmh at gmx.de>
+ * Copyright 2008,2009 Jens-Michael Hoffmann <jensmh at gmx.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -31,7 +31,6 @@
#include "DatasetProvider.h"
#include "TextureTile.h"
#include "MarbleDirs.h"
-#include "TileId.h"
#include "MarbleModel.h"
#include "TileLoaderHelper.h"
@@ -274,6 +273,18 @@
return d->m_tileCache.maxCost() / 1024;
}
+QList<TileId> TileLoader::tilesOnDisplay() const
+{
+ QList<TileId> result;
+ QHash<TileId, TextureTile*>::const_iterator pos = d->m_tileHash.constBegin();
+ QHash<TileId, TextureTile*>::const_iterator const end = d->m_tileHash.constEnd();
+ for (; pos != end; ++pos ) {
+ if ( pos.value()->used() ) {
+ result.append( pos.key() );
+ }
+ }
+ return result;
+}
int TileLoader::maxPartialTileLevel( GeoSceneLayer * layer )
{
--- trunk/KDE/kdeedu/marble/src/lib/TileLoader.h #1011004:1011005
@@ -3,6 +3,7 @@
*
* Copyright 2005-2007 Torsten Rahn <tackat at kde.org>"
* Copyright 2007 Inge Wallin <ingwa at kde.org>"
+ * Copyright 2009 Jens-Michael Hoffmann <jensmh at gmx.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -25,6 +26,8 @@
#include <QtCore/QObject>
+#include "TileId.h"
+
class QString;
namespace Marble
@@ -141,6 +144,13 @@
quint64 volatileCacheLimit() const;
/**
+ * @brief Returns a list of TileIds of the tiles which are currently
+ * displayed. This is used for example for the map reload
+ * functionality.
+ */
+ QList<TileId> tilesOnDisplay() const;
+
+ /**
* Returns the highest level in which some tiles are available for the given @p
* texture layer.
*/
--- trunk/KDE/kdeedu/marble/src/marble_part.cpp #1011004:1011005
@@ -674,6 +674,8 @@
connect( m_controlSunAction, SIGNAL( triggered( bool ) ),
this, SLOT( controlSun() ) );
+ KStandardAction::redisplay( this, SLOT( reload() ), actionCollection() );
+
// Action: Lock float items
m_lockFloatItemsAct = new KAction ( this );
actionCollection()->addAction( "options_lock_floatitems",
@@ -1115,6 +1117,11 @@
m_previousGraphicsSystem = graphicsSystem;
}
+void MarblePart::reload()
+{
+ m_controlView->marbleWidget()->map()->reload();
+}
+
void MarblePart::showPluginAboutDialog( QString nameId ) {
QList<RenderPlugin *> renderItemList = m_controlView->marbleWidget()->renderPlugins();
--- trunk/KDE/kdeedu/marble/src/marble_part.h #1011004:1011005
@@ -120,6 +120,7 @@
void retrievePluginState();
void slotUpdateSettings();
+ void reload();
/**
* Shows the about dialog for the plugin with the corresponding @p nameId.
--- trunk/KDE/kdeedu/marble/src/marble_part.rc #1011004:1011005
@@ -34,6 +34,7 @@
<Action name="show_atmosphere"/>
<Separator/>
<Action name="control_sun"/>
+ <Action name="view_redisplay"/>
</Menu>
<Menu name="settings" noMerge="1"><text>&Settings</text>
<Merge name="StandardToolBarMenuHandler" />
More information about the Marble-commits
mailing list