[Marble-commits] KDE/kdeedu/marble/src

Andrew Manson g.real.ate at gmail.com
Fri Jul 17 16:56:08 CEST 2009


SVN commit 998389 by mansona:

Appending the action groups concept to the RenderPlugin API and half moving the 
OsmAnnotation plugin implementation to this concept. 




 M  +1 -1      lib/GeoGraphicsItem.h  
 M  +10 -0     lib/RenderPlugin.cpp  
 M  +25 -0     lib/RenderPlugin.h  
 M  +50 -12    plugins/render/osmannotate/OsmAnnotatePlugin.cpp  
 M  +13 -8     plugins/render/osmannotate/OsmAnnotatePlugin.h  
 M  +1 -1      plugins/render/osmannotate/PlacemarkTextAnnotation.cpp  
 M  +1 -1      plugins/render/osmannotate/osm/OsmNodeGraphicsItem.cpp  


--- trunk/KDE/kdeedu/marble/src/lib/GeoGraphicsItem.h #998388:998389
@@ -95,7 +95,7 @@
 
 //Declares the operator|() for flags but breaks other enum comparisons related to 
 //GeoGraphicsItem
-//FIXME ... is this nessesary?
+//FIXME ... is this necessary?
 //Q_DECLARE_OPERATORS_FOR_FLAGS(GeoGraphicsItem::GeoGraphicsItemFlags)
 
 } // Namespace Marble
--- trunk/KDE/kdeedu/marble/src/lib/RenderPlugin.cpp #998388:998389
@@ -86,6 +86,16 @@
     return d->m_action;
 }
 
+QList<QActionGroup*>* RenderPlugin::actions() const
+{
+    return 0;
+}
+
+QList<QActionGroup*>* RenderPlugin::toolbarActions() const
+{
+    return 0;
+}
+
 QStandardItem* RenderPlugin::item() const {
     d->m_item->setIcon( icon() );
     d->m_item->setText( name() );
--- trunk/KDE/kdeedu/marble/src/lib/RenderPlugin.h #998388:998389
@@ -23,6 +23,7 @@
 
 
 class QAction;
+class QActionGroup;
 class QStandardItem;
 
 namespace Marble
@@ -60,6 +61,24 @@
     void  setDataFacade( MarbleDataFacade* );
 
     QAction       *action() const;
+    /**
+     *This method is used by the main window to get all of the actions that this
+     *plugin defines. There is no guarentee where the main window will place the
+     *actions but it will generally be in a Menu. The returned QList should
+     *also contain all of the actions returned by @see toolbarActions().
+     *@return A QList of grouped actions
+     */
+    virtual QList<QActionGroup*>*   actions() const;
+
+    /**
+     *This method returns a subset of the actions returned by @see actions() which
+     *are intended to be placed in a more prominant place such as a toolbar above
+     *the Marble Widget. You are not guaranteed that they will be in an actual
+     *toobar but they will be visable and discoverable
+     *@return A QList of grouped toolbar actions
+     */
+    virtual QList<QActionGroup*>*   toolbarActions() const;
+    
     QStandardItem *item()   const;
 
     void applyItemState();
@@ -106,6 +125,12 @@
      */
     void settingsChanged( QString nameId );
 
+    /**
+     * This signal is emitted if the actions that the plugin supports change in
+     * any way
+     */
+    void actionGroupsChanged();
+
  protected:
     bool eventFilter( QObject *, QEvent * );
 
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.cpp #998388:998389
@@ -97,6 +97,12 @@
     m_itemModel = 0;
     m_addingPlacemark = false;
     m_drawingPolygon = false;
+
+    m_actions = 0;
+    m_toolbarActions = 0;
+
+    connect( this, SIGNAL(actionGroupsChanged()),
+             this, SLOT(registerActions() ) );
 }
 
 bool OsmAnnotatePlugin::isInitialized () const
@@ -104,18 +110,23 @@
     return true;
 }
 
+QList<QActionGroup*>* OsmAnnotatePlugin::actions() const
+{
+    return m_actions;
+}
+
+QList<QActionGroup*>* OsmAnnotatePlugin::toolbarActions() const
+{
+    return m_toolbarActions;
+}
+
 bool OsmAnnotatePlugin::render( GeoPainter *painter, ViewportParams *viewport, const QString& renderPos, GeoSceneLayer * layer )
 {
     if( !widgetInitalised ) {
         MarbleWidget* marbleWidget = (MarbleWidget*) painter->device();
-        QList<QActionGroup*> actionGroups = setupActions( marbleWidget );
+        m_marbleWidget = marbleWidget;
+        setupActions( marbleWidget );
 
-        QListIterator<QActionGroup*> it(actionGroups);
-
-        while( it.hasNext() ) {
-            marbleWidget->registerActions( it.next() );
-        }
-
         connect(this, SIGNAL(redraw()),
                 marbleWidget, SLOT(repaint()) );
 
@@ -174,6 +185,16 @@
     }
 }
 
+void OsmAnnotatePlugin::registerActions()
+{
+    qDebug() << "Registering Actions!!!!!";
+    QListIterator<QActionGroup*> it(*m_toolbarActions);
+
+    while( it.hasNext() ) {
+        m_marbleWidget->registerActions( it.next() );
+    }
+}
+
 void OsmAnnotatePlugin::loadOsmFile()
 {
     QString filename;
@@ -312,9 +333,10 @@
     return false;
 }
 
-QList<QActionGroup*> OsmAnnotatePlugin::setupActions(MarbleWidget* widget)
+void OsmAnnotatePlugin::setupActions(MarbleWidget* widget)
 {
-    QList<QActionGroup*> result;
+    QList<QActionGroup*>* toolbarActions = new QList<QActionGroup*>();
+    QList<QActionGroup*>* actions = new QList<QActionGroup*>();
 
     QActionGroup* initial = new QActionGroup(0);
     initial->setExclusive( false );
@@ -368,9 +390,25 @@
     group->addAction( m_loadOsmFile );
     group->addAction( m_endSeparator );
 
-    result.append( initial );
-    result.append( group );
-    return result;
+    actions->append( initial );
+    actions->append( group );
+
+    toolbarActions->append( initial );
+    toolbarActions->append( group );
+
+    //delete the old groups if they exist
+    if( m_actions ) {
+        delete m_actions;
+    }
+
+    if( m_toolbarActions ) {
+        delete m_toolbarActions;
+    }
+
+    m_actions = actions;
+    m_toolbarActions = toolbarActions;
+
+    emit actionGroupsChanged();
 }
 
 }
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.h #998388:998389
@@ -62,14 +62,12 @@
 
     bool isInitialized () const;
 
+    virtual QList<QActionGroup*>* actions() const;
+    virtual QList<QActionGroup*>* toolbarActions() const;
 
-    //intended to be called from the outside the plugin to replace
-    //the "registerActions" calls.
-    //FIXME: need to guarentee marbleWiget has been initialised before this call
-    QList<QActionGroup*> actionGroups();
+    bool render( GeoPainter *painter, ViewportParams *viewport,
+                 const QString& renderPos, GeoSceneLayer * layer = 0 );
 
-    bool render( GeoPainter *painter, ViewportParams *viewport, const QString& renderPos, GeoSceneLayer * layer = 0 );
-
     bool    widgetInitalised;
 
 
@@ -80,11 +78,18 @@
 
     void setAddingPlacemark( bool );
     void setDrawingPolygon( bool );
- protected:
+
+    void registerActions();
+protected:
     bool eventFilter(QObject* watched, QEvent* event);
 private:
-    QList<QActionGroup*> setupActions(MarbleWidget* m);
+    void setupActions(MarbleWidget* m);
 
+    MarbleWidget* m_marbleWidget;
+
+    QList<QActionGroup*>    *m_actions;
+    QList<QActionGroup*>    *m_toolbarActions;
+
     //Intended to be replaced by an actual model system
     //FIXME: Merge the two models once TmpGraphicsItem is eliminated
     QList<TmpGraphicsItem*> model;
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/PlacemarkTextAnnotation.cpp #998388:998389
@@ -52,7 +52,7 @@
 {
     qreal degPix = viewport->angularResolution() * RAD2DEG;
 
-    painter->drawEllipse(coordinate(), screenBounding().width(), screenBounding().height(), true);
+//    painter->drawEllipse(coordinate(), screenBounding().width(), screenBounding().height(), true);
     //Would it not be useful to have a draw latlongbox?
 //    painter->drawRect(geoBounding());
     qreal north, south, east, west;
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmNodeGraphicsItem.cpp #998388:998389
@@ -31,7 +31,7 @@
     //stop points from blurring
     painter->setRenderHint( QPainter::Antialiasing, false );
     painter->setPen(m_pen);
-    painter->drawPoint( m_point );
+    painter->drawRect( m_point, 2, 2, false );
     painter->restore();
 
 }


More information about the Marble-commits mailing list