[Marble-commits] KDE/kdeedu/marble/src/lib
Bastian Holst
bastianholst at gmx.de
Thu Aug 6 14:56:34 CEST 2009
SVN commit 1007891 by bholst:
Marble Online Services now update the view automatically.
M +12 -0 AbstractDataPlugin.cpp
M +3 -0 AbstractDataPlugin.h
M +8 -0 AbstractDataPluginModel.cpp
M +3 -0 AbstractDataPluginModel.h
M +2 -0 LayerManager.cpp
M +9 -1 LayerManager.h
M +3 -0 MarbleMap.cpp
M +7 -0 MarbleMap.h
M +2 -0 MarbleModel.cpp
M +7 -0 MarbleModel.h
M +24 -1 MarbleWidget.cpp
M +5 -0 MarbleWidget.h
M +7 -0 RenderPlugin.h
--- trunk/KDE/kdeedu/marble/src/lib/AbstractDataPlugin.cpp #1007890:1007891
@@ -22,6 +22,7 @@
#include <QtCore/QDebug>
#include <QtCore/QEvent>
#include <QtGui/QMouseEvent>
+#include <QtGui/QRegion>
namespace Marble
{
@@ -108,7 +109,13 @@
void AbstractDataPlugin::setModel( AbstractDataPluginModel* model )
{
+ if ( d->m_model ) {
+ disconnect( d->m_model, SIGNAL( itemsUpdated() ), this, SLOT( requestRepaint() ) );
+ delete d->m_model;
+ }
d->m_model = model;
+
+ connect( d->m_model, SIGNAL( itemsUpdated() ), this, SLOT( requestRepaint() ) );
}
QString AbstractDataPlugin::nameId() const
@@ -146,6 +153,11 @@
}
}
+void AbstractDataPlugin::requestRepaint()
+{
+ emit repaintNeeded( QRegion() );
+}
+
} // namespace Marble
#include "AbstractDataPlugin.moc"
--- trunk/KDE/kdeedu/marble/src/lib/AbstractDataPlugin.h #1007890:1007891
@@ -114,6 +114,9 @@
*/
QList<AbstractDataPluginItem *> whichItemAt( const QPoint& curpos );
+ private Q_SLOTS:
+ void requestRepaint();
+
Q_SIGNALS:
void changedNumberOfItems( quint32 number );
--- trunk/KDE/kdeedu/marble/src/lib/AbstractDataPluginModel.cpp #1007890:1007891
@@ -303,6 +303,10 @@
d->m_itemSet.insert( i, item );
connect( item, SIGNAL( destroyed( QObject* ) ), this, SLOT( removeItem( QObject* ) ) );
+
+ if ( item->initialized() ) {
+ emit itemsUpdated();
+ }
}
QString AbstractDataPluginModel::name() const
@@ -449,6 +453,10 @@
fileType );
d->m_downloadingItems.erase( i );
+
+ if ( (*i)->initialized() ) {
+ emit itemsUpdated();
+ }
}
}
}
--- trunk/KDE/kdeedu/marble/src/lib/AbstractDataPluginModel.h #1007890:1007891
@@ -171,6 +171,9 @@
* @brief Removes the item from the list.
*/
void removeItem( QObject *item );
+
+ Q_SIGNALS:
+ void itemsUpdated();
private:
AbstractDataPluginModelPrivate * const d;
--- trunk/KDE/kdeedu/marble/src/lib/LayerManager.cpp #1007890:1007891
@@ -61,6 +61,8 @@
foreach( RenderPlugin * renderPlugin, d->m_renderPlugins ) {
connect( renderPlugin, SIGNAL( settingsChanged( QString ) ),
this, SIGNAL( pluginSettingsChanged() ) );
+ connect( renderPlugin, SIGNAL( repaintNeeded( QRegion ) ),
+ this, SIGNAL( repaintNeeded( QRegion ) ) );
AbstractFloatItem * const floatItem =
qobject_cast<AbstractFloatItem *>( renderPlugin );
--- trunk/KDE/kdeedu/marble/src/lib/LayerManager.h #1007890:1007891
@@ -21,6 +21,7 @@
#include "marble_export.h"
class QPoint;
+class QRegion;
namespace Marble
{
@@ -82,10 +83,17 @@
void floatItemsChanged();
/**
- * This signal is emit when the settings of a plugin changed.
+ * This signal is emitted when the settings of a plugin changed.
*/
void pluginSettingsChanged();
+ /**
+ * This signal is emitted when the repaint of the view was requested by a plugin.
+ * If available with the @p dirtyRegion which is the region the view will change in.
+ * If dirtyRegion.isEmpty() returns true, the whole viewport has to be repainted.
+ */
+ void repaintNeeded( QRegion dirtyRegion );
+
public Q_SLOTS:
void loadLayers();
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.cpp #1007890:1007891
@@ -112,6 +112,9 @@
m_parent->connect( m_model->sunLocator(), SIGNAL( centerSun() ),
m_parent, SLOT( centerSun() ) );
+ m_parent->connect( m_model, SIGNAL( repaintNeeded( QRegion ) ),
+ m_parent, SIGNAL( repaintNeeded( QRegion ) ) );
+
// A new instance of FileStorageWatcher.
// The thread will be started at setting persistent tile cache size.
m_storageWatcher = new FileStorageWatcher( MarbleDirs::localPath(), m_parent );
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.h #1007890:1007891
@@ -791,6 +791,13 @@
void framesPerSecond( qreal fps );
+ /**
+ * This signal is emitted when the repaint of the view was requested.
+ * If available with the @p dirtyRegion which is the region the view will change in.
+ * If dirtyRegion.isEmpty() returns true, the whole viewport has to be repainted.
+ */
+ void repaintNeeded( QRegion dirtyRegion );
+
protected:
/**
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1007890:1007891
@@ -209,6 +209,8 @@
connect ( d->m_layerManager, SIGNAL( pluginSettingsChanged() ),
this, SIGNAL( pluginSettingsChanged() ) );
+ connect ( d->m_layerManager, SIGNAL( repaintNeeded( QRegion ) ),
+ this, SIGNAL( repaintNeeded( QRegion ) ) );
d->m_timer = new QTimer( this );
d->m_timer->start( 200 );
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.h #1007890:1007891
@@ -350,6 +350,13 @@
*/
void pluginSettingsChanged();
+ /**
+ * This signal is emitted when the repaint of the view was requested.
+ * If available with the @p dirtyRegion which is the region the view will change in.
+ * If dirtyRegion.isEmpty() returns true, the whole viewport has to be repainted.
+ */
+ void repaintNeeded( QRegion dirtyRegion );
+
private:
Q_DISABLE_COPY( MarbleModel )
MarbleModelPrivate * const d;
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.cpp #1007890:1007891
@@ -64,7 +64,9 @@
# endif
#endif
+const int REPAINT_SCHEDULING_INTERVAL = 1000;
+
class MarbleWidgetPrivate
{
public:
@@ -81,7 +83,8 @@
m_proxyHost(),
m_proxyPort( 0 ),
m_user(),
- m_password()
+ m_password(),
+ m_repaintTimer()
{
}
@@ -117,6 +120,9 @@
qint16 m_proxyPort;
QString m_user;
QString m_password;
+
+ // For scheduling repaints
+ QTimer m_repaintTimer;
};
@@ -173,6 +179,14 @@
m_widget->connect( m_model, SIGNAL( modelChanged() ),
m_widget, SLOT( updateChangedMap() ) );
+ // Repaint scheduling
+ m_widget->connect( m_map, SIGNAL( repaintNeeded( QRegion ) ),
+ m_widget, SLOT( scheduleRepaint( QRegion ) ) );
+ m_repaintTimer.setSingleShot( true );
+ m_repaintTimer.setInterval( REPAINT_SCHEDULING_INTERVAL );
+ m_widget->connect( &m_repaintTimer, SIGNAL( timeout() ),
+ m_widget, SLOT( update() ) );
+
// When some fundamental things change in the map, we got to show
// this in the view, i.e. here.
m_widget->connect( m_map, SIGNAL( zoomChanged( int ) ),
@@ -812,6 +826,8 @@
void MarbleWidget::paintEvent(QPaintEvent *evt)
{
+ // Stop repaint timer if it is already running
+ d->m_repaintTimer.stop();
QTime t;
t.start();
@@ -1122,6 +1138,13 @@
update();
}
+void MarbleWidget::scheduleRepaint( QRegion dirtyRegion )
+{
+ if ( !d->m_repaintTimer.isActive() ) {
+ d->m_repaintTimer.start();
+ }
+}
+
MapQuality MarbleWidget::mapQuality( ViewContext viewContext )
{
if ( viewContext == Still )
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.h #1007890:1007891
@@ -917,6 +917,11 @@
void updateChangedMap();
/**
+ * Schedule repaint
+ */
+ void scheduleRepaint( QRegion dirtyRegion );
+
+ /**
* @brief Set the map quality depending on the view context
*/
void setMapQuality( Marble::MapQuality, Marble::ViewContext = Marble::Still );
--- trunk/KDE/kdeedu/marble/src/lib/RenderPlugin.h #1007890:1007891
@@ -131,6 +131,13 @@
*/
void actionGroupsChanged();
+ /**
+ * This signal is emitted if an update of the view is needed. If available with the
+ * @p dirtyRegion which is the region the view will change in. If dirtyRegion.isEmpty() returns
+ * true, the whole viewport has to be repainted.
+ */
+ void repaintNeeded( QRegion dirtyRegion );
+
protected:
bool eventFilter( QObject *, QEvent * );
More information about the Marble-commits
mailing list