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

Andrew Manson g.real.ate at gmail.com
Mon Jul 20 14:32:48 CEST 2009


SVN commit 999738 by mansona:

Now doing the plugin toolbar loading the correct way! Only works for 
QtOnly version as of yet. Research needed to convert the solution. 
Also removing all traces of the wrong way to build a Toolbar. 


 M  +48 -0     QtMainWindow.cpp  
 M  +7 -0      QtMainWindow.h  
 M  +0 -20     lib/MarbleWidget.cpp  
 M  +0 -11     lib/MarbleWidget.h  
 M  +2 -2      lib/RenderPlugin.cpp  
 M  +2 -2      lib/RenderPlugin.h  
 M  +2 -1      lib/geodata/graphicsitem/GeoLineStringGraphicsItem.h  
 M  +4 -22     plugins/render/osmannotate/OsmAnnotatePlugin.cpp  
 M  +2 -3      plugins/render/osmannotate/OsmAnnotatePlugin.h  


--- trunk/KDE/kdeedu/marble/src/QtMainWindow.cpp #999737:999738
@@ -24,6 +24,7 @@
 #include <QtGui/QIcon>
 #include <QtGui/QMenuBar>
 #include <QtGui/QStatusBar>
+#include <QtGui/QToolBar>
 #include <QtGui/QDesktopServices>
 #include <QtGui/QFileDialog>
 #include <QtGui/QMessageBox>
@@ -251,6 +252,13 @@
 
     connect( m_infoBoxesMenu, SIGNAL( aboutToShow() ), this, SLOT( createInfoBoxesMenu() ) ); 
     connect( m_onlineServicesMenu, SIGNAL( aboutToShow() ), this, SLOT( createOnlineServicesMenu() ) ); 
+
+//    FIXME: Discuss if this is the best place to put this
+    QList<RenderPlugin *>::const_iterator it = pluginList.constBegin();
+    for (; it != pluginList.constEnd(); ++it) {
+        connect( (*it), SIGNAL( actionGroupsChanged() ),
+                 this, SLOT( createPluginMenus() ) );
+    }
 }
 
 void MainWindow::createInfoBoxesMenu()
@@ -285,6 +293,46 @@
     }
 }
 
+void MainWindow::createPluginMenus()
+{
+    //Remove and delete toolbars if they exist
+    while( !m_pluginToolbars.isEmpty() ) {
+        QToolBar* tb = m_pluginToolbars.takeFirst();
+        this->removeToolBar(tb);
+        delete tb;
+    }
+
+    //remove and delete old menus if they exist
+    while(  !m_pluginMenus.isEmpty() ) {
+        QMenu* menu = m_pluginMenus.takeFirst();
+//        FIXME: this does not provide an easy way to remove a menu.
+//        Make a workaround
+//        this->menuBar()->removeAction();
+    }
+
+    QList<QActionGroup*> *tmp_toolbarActionGroups;
+    QList<RenderPlugin *> renderPluginList = m_controlView->marbleWidget()->renderPlugins();
+    QList<RenderPlugin *>::const_iterator i;
+
+    //Load the toolbars
+    for( i = renderPluginList.constBegin(); i != renderPluginList.constEnd(); ++i ) {
+        tmp_toolbarActionGroups = (*i)->toolbarActionGroups();
+
+        if ( tmp_toolbarActionGroups ) {
+            QToolBar* toolbar = new QToolBar(this);
+
+            foreach( QActionGroup* ag, *tmp_toolbarActionGroups ) {
+                toolbar->addActions( ag->actions() );
+            }
+
+            m_pluginToolbars.append( toolbar );
+            this->addToolBar( toolbar );
+        }
+    }
+
+//    FIXME: load the menus once the method has been settled on
+}
+
 void MainWindow::createStatusBar()
 {
     statusBar()->showMessage(tr("Ready"));
--- trunk/KDE/kdeedu/marble/src/QtMainWindow.h #999737:999738
@@ -81,6 +81,7 @@
     void  lockPosition( bool );
     void  createInfoBoxesMenu();
     void  createOnlineServicesMenu();
+    void  createPluginMenus();
 
  private:
     ControlView *m_controlView;
@@ -92,6 +93,12 @@
     QMenu *m_infoBoxesMenu;
     QMenu *m_onlineServicesMenu;
 
+    /// Store plugin toolbar pointers so that they can be removed/updated later
+    QList<QToolBar*> m_pluginToolbars;
+
+    /// Store plugin menus so that they can be removed/updated later
+    QList<QMenu*> m_pluginMenus;
+
     // File Menu
     QAction *m_exportMapAct;
     QAction *m_printAct;
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.cpp #999737:999738
@@ -24,7 +24,6 @@
 #include <QtGui/QPaintEvent>
 #include <QtGui/QRegion>
 #include <QtGui/QStyleOptionGraphicsItem>
-#include <QtGui/QToolBar>
 #include <QtGui/QMainWindow>
 #include <QtGui/QAction>
 #include <QtNetwork/QNetworkProxy>
@@ -78,7 +77,6 @@
           m_animationsEnabled( false ),
           m_inputhandler( 0 ),
           m_physics( new MarblePhysics( parent ) ),
-          m_mainToolbar(),
           m_proxyHost(),
           m_proxyPort( 0 ),
           m_user(),
@@ -112,8 +110,6 @@
     MarbleWidgetInputHandler  *m_inputhandler;
 
     MarblePhysics    *m_physics;
-    
-    QToolBar        *m_mainToolbar;
 
     //This stuff is NEVER used. Needs to be deleted
     QString          m_proxyHost;
@@ -130,10 +126,6 @@
 {
 //    setAttribute( Qt::WA_PaintOnScreen, true );
     d->construct();
-
-    if( parent && parent->parent() && parent->parent()->inherits( "QMainWindow" ) ) {
-        ((QMainWindow*) parent->parent())->addToolBar(d->m_mainToolbar);
-    }
 }
 
 
@@ -219,8 +211,6 @@
     m_widget->setInputHandler( new MarbleWidgetDefaultInputHandler );
     m_widget->setMouseTracking( m_widget );
 
-    m_mainToolbar = new QToolBar(0);
-
     m_widget->connect( m_model, SIGNAL( pluginSettingsChanged() ),
                        m_widget, SIGNAL( pluginSettingsChanged() ) );
 }
@@ -1292,16 +1282,6 @@
     return d->m_password;
 }
 
-void MarbleWidget::registerActions( QActionGroup* actions)
-{
-    d->m_mainToolbar->addActions( actions->actions() );
-}
-
-void MarbleWidget::removeAction( QAction *action )
-{
-    d->m_mainToolbar->removeAction( action );
-}
-
 QList<RenderPlugin *> MarbleWidget::renderPlugins() const
 {
     return d->m_model->renderPlugins();
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.h #999737:999738
@@ -475,17 +475,6 @@
     QString password() const;
 
     /**
-     * Regestering an action with the marble Widget activates it and places it in
-     * the main toolbar.
-     */
-    void registerActions( QActionGroup* actions );
-
-    /**
-     * Disables an action and removes it from the main toolbar.
-     */
-    void removeAction( QAction* action );
-
-    /**
      * @brief Returns a list of all RenderPlugins on the widget, this includes float items
      * @return the list of RenderPlugins
      */
--- trunk/KDE/kdeedu/marble/src/lib/RenderPlugin.cpp #999737:999738
@@ -86,12 +86,12 @@
     return d->m_action;
 }
 
-QList<QActionGroup*>* RenderPlugin::actions() const
+QList<QActionGroup*>* RenderPlugin::actionGroups() const
 {
     return 0;
 }
 
-QList<QActionGroup*>* RenderPlugin::toolbarActions() const
+QList<QActionGroup*>* RenderPlugin::toolbarActionGroups() const
 {
     return 0;
 }
--- trunk/KDE/kdeedu/marble/src/lib/RenderPlugin.h #999737:999738
@@ -68,7 +68,7 @@
      *also contain all of the actions returned by @see toolbarActions().
      *@return A QList of grouped actions
      */
-    virtual QList<QActionGroup*>*   actions() const;
+    virtual QList<QActionGroup*>*   actionGroups() const;
 
     /**
      *This method returns a subset of the actions returned by @see actions() which
@@ -77,7 +77,7 @@
      *toobar but they will be visable and discoverable
      *@return A QList of grouped toolbar actions
      */
-    virtual QList<QActionGroup*>*   toolbarActions() const;
+    virtual QList<QActionGroup*>*   toolbarActionGroups() const;
     
     QStandardItem *item()   const;
 
--- trunk/KDE/kdeedu/marble/src/lib/geodata/graphicsitem/GeoLineStringGraphicsItem.h #999737:999738
@@ -13,11 +13,12 @@
 
 #include "GeoDataLineString.h"
 #include "GeoGraphicsItem.h"
+#include "marble_export.h"
 
 namespace Marble
 {
 
-class GeoLineStringGraphicsItem : public GeoGraphicsItem
+class MARBLE_EXPORT GeoLineStringGraphicsItem : public GeoGraphicsItem
 {
 public:
     GeoLineStringGraphicsItem();
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.cpp #999737:999738
@@ -100,9 +100,6 @@
 
     m_actions = 0;
     m_toolbarActions = 0;
-
-    connect( this, SIGNAL(actionGroupsChanged()),
-             this, SLOT(registerActions() ) );
 }
 
 bool OsmAnnotatePlugin::isInitialized () const
@@ -110,12 +107,12 @@
     return true;
 }
 
-QList<QActionGroup*>* OsmAnnotatePlugin::actions() const
+QList<QActionGroup*>* OsmAnnotatePlugin::actionGroups() const
 {
     return m_actions;
 }
 
-QList<QActionGroup*>* OsmAnnotatePlugin::toolbarActions() const
+QList<QActionGroup*>* OsmAnnotatePlugin::toolbarActionGroups() const
 {
     return m_toolbarActions;
 }
@@ -185,16 +182,6 @@
     }
 }
 
-void OsmAnnotatePlugin::registerActions()
-{
-    qDebug() << "Registering Actions!!!!!";
-    QListIterator<QActionGroup*> it(*m_toolbarActions);
-
-    while( it.hasNext() ) {
-        m_marbleWidget->registerActions( it.next() );
-    }
-}
-
 void OsmAnnotatePlugin::loadOsmFile()
 {
     QString filename;
@@ -397,14 +384,9 @@
     toolbarActions->append( group );
 
     //delete the old groups if they exist
-    if( m_actions ) {
-        delete m_actions;
-    }
+    delete m_actions;
+    delete m_toolbarActions;
 
-    if( m_toolbarActions ) {
-        delete m_toolbarActions;
-    }
-
     m_actions = actions;
     m_toolbarActions = toolbarActions;
 
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.h #999737:999738
@@ -62,8 +62,8 @@
 
     bool isInitialized () const;
 
-    virtual QList<QActionGroup*>* actions() const;
-    virtual QList<QActionGroup*>* toolbarActions() const;
+    virtual QList<QActionGroup*>* actionGroups() const;
+    virtual QList<QActionGroup*>* toolbarActionGroups() const;
 
     bool render( GeoPainter *painter, ViewportParams *viewport,
                  const QString& renderPos, GeoSceneLayer * layer = 0 );
@@ -79,7 +79,6 @@
     void setAddingPlacemark( bool );
     void setDrawingPolygon( bool );
 
-    void registerActions();
 protected:
     bool eventFilter(QObject* watched, QEvent* event);
 private:


More information about the Marble-commits mailing list