[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/marble/src/plugins/render/panoramio
From:       Bastian Holst <bastianholst () gmx ! de>
Date:       2009-04-27 19:55:10
Message-ID: 1240862110.229982.30117.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 960035 by bholst:

Marbles AbstractDataPluginWidgets don't get removed anymore when moving the map until \
you zoom out or the widgets get out of the viewport.


 M  +1 -1      AbstractDataPlugin.cpp  
 M  +38 -1     AbstractDataPluginModel.cpp  
 M  +14 -0     AbstractDataPluginWidget.cpp  
 M  +7 -0      AbstractDataPluginWidget.h  


--- trunk/KDE/kdeedu/marble/src/plugins/render/panoramio/AbstractDataPlugin.cpp \
#960034:960035 @@ -63,7 +63,7 @@
     painter->save();
     
     // Paint the most important widget at last
-    for( int i = widgets.size() - 1; i >= 0; i-- ) {
+    for( int i = widgets.size() - 1; i >= 0; --i ) {
         widgets.at( i )->render( painter, viewport, renderPos, layer );
     }
     
--- trunk/KDE/kdeedu/marble/src/plugins/render/panoramio/AbstractDataPluginModel.cpp \
#960034:960035 @@ -65,6 +65,7 @@
     qint32 m_downloadedNumber;
     QList<AbstractDataPluginWidget*> m_widgetSet;
     QHash<QString, AbstractDataPluginWidget*> m_downloadingWidgets;
+    QList<AbstractDataPluginWidget*> m_displayedWidgets;
     QTimer *m_downloadTimer;
     
     CacheStoragePolicy *m_storagePolicy;
@@ -102,6 +103,33 @@
     
     QList<AbstractDataPluginWidget*>::iterator i;
     
+    // Widgets that are already shown have the highest priority
+    for ( i = d->m_displayedWidgets.begin();
+          i != d->m_displayedWidgets.end() && list.size() < number;
+          ++i )
+    {
+        // Don't try to access an object that doesn't exist
+        if( *i == 0 ) {
+            continue;
+        }
+    
+        // Only show widgets that are initialized
+        if( !(*i)->initialized() ) {
+            continue;
+        }
+        
+        if( !currentBox->contains( (*i)->coordinates() ) ) {
+            continue;
+        }
+        
+        // If the widget was added initially at a nearer position, they don't have \
priority, +        // because we zoomed out since then.
+        if( (*i)->addedAngularResolution() >= viewport->angularResolution() ) {
+            list.append( *i );
+        }
+    }
+        
+    
     for ( i = d->m_widgetSet.begin(); i != d->m_widgetSet.end() && list.size() < \
number; ++i ) {  // Don't try to access an object that doesn't exist
         if( *i == 0 ) {
@@ -114,8 +142,16 @@
         }
         
         // If the widget is on the viewport, we want to return it
-        if( currentBox->contains( (*i)->coordinates() ) ) {
+        if( currentBox->contains( (*i)->coordinates() )
+            && !list.contains( *i ) )
+        {
             list.append( *i );
+            
+            // We want to save the angular resolution of the first time the widget \
got added. +            // If it is in the list of displayedWidgets, it was added \
before +            if( !d->m_displayedWidgets.contains( *i ) ) {
+                (*i)->setAddedAngularResolution( viewport->angularResolution() );
+            }
         }
         // FIXME: We have to do something if the widget that is not on the viewport.
     }
@@ -126,6 +162,7 @@
         d->m_lastNumber = number;
     }
     
+    d->m_displayedWidgets = list;
     return list;
 }
 
--- trunk/KDE/kdeedu/marble/src/plugins/render/panoramio/AbstractDataPluginWidget.cpp \
#960034:960035 @@ -15,8 +15,14 @@
 
 class AbstractDataPluginWidgetPrivate {
  public:
+    AbstractDataPluginWidgetPrivate()
+        : m_addedAngularResolution( 0 )
+    {
+    };
+    
     QString m_id;
     GeoDataCoordinates m_coordinates;
+    qreal m_addedAngularResolution;
 };
 
 AbstractDataPluginWidget::AbstractDataPluginWidget( QObject *parent )
@@ -44,6 +50,14 @@
     d->m_id = id;
 }
 
+qreal AbstractDataPluginWidget::addedAngularResolution() {
+    return d->m_addedAngularResolution;
+}
+
+void AbstractDataPluginWidget::setAddedAngularResolution( qreal resolution ) {
+    d->m_addedAngularResolution = resolution;
+}
+
 } // Marble namespace
 
 #include "AbstractDataPluginWidget.moc"
--- trunk/KDE/kdeedu/marble/src/plugins/render/panoramio/AbstractDataPluginWidget.h \
#960034:960035 @@ -38,6 +38,13 @@
     QString id();
     void setId( QString id );
     
+    /**
+      * Returnung the angular resolution of the viewport when the widget was added \
to it the last +      * time.
+      */
+    qreal addedAngularResolution();
+    void setAddedAngularResolution( qreal resolution );
+    
     virtual QString widgetType() const = 0;
      
     virtual bool initialized() = 0;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic