From f46cdf38c16cc53f0d3542d47daa8b3d4d55e39a Mon Sep 17 00:00:00 2001 From: gsherman Date: Fri, 6 Feb 2004 07:04:05 +0000 Subject: [PATCH] added interface for positioning menu items from plugins git-svn-id: http://svn.osgeo.org/qgis/trunk@711 c8812cc2-4d05-0410-92ff-de0c093fc19c --- plugins/Makefile.am | 2 +- plugins/geoprocessing/qgspggeoprocessing.cpp | 5 +++-- plugins/spit/qgsspitplugin.cpp | 3 ++- src/qgisiface.cpp | 9 +++++++++ src/qgisiface.h | 2 ++ src/qgisinterface.h | 3 +++ 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 2a260a92169..d2588afe943 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -1 +1 @@ -SUBDIRS = example maplayer spit geoprocessing +SUBDIRS = spit geoprocessing diff --git a/plugins/geoprocessing/qgspggeoprocessing.cpp b/plugins/geoprocessing/qgspggeoprocessing.cpp index d9133b5a07b..c33c85c47d0 100644 --- a/plugins/geoprocessing/qgspggeoprocessing.cpp +++ b/plugins/geoprocessing/qgspggeoprocessing.cpp @@ -99,7 +99,8 @@ void QgsPgGeoprocessing::initGui() menu = ((QMainWindow *) qgisMainWindow)->menuBar(); - menuId = menu->insertItem("&Geoprocessing", pluginMenu); + // menuId = menu->insertItem("&Geoprocessing", pluginMenu); + menuId = qI->addMenu("&Geoprocessing", pluginMenu); // Create the action for tool QAction *bufferAction = new QAction("Buffer features", QIconSet(icon_buffer), "&Buffer", 0, this, "buffer"); @@ -251,7 +252,7 @@ void QgsPgGeoprocessing::buffer() // add the geometry column //, , , , , sql = QString("select addgeometrycolumn('%1','%2','%3',%4,'%5',%6)") - .arg(dbname) + .arg(bb->schema()) .arg(bb->bufferLayerName()) .arg(bb->geometryColumn()) .arg(bb->srid()) diff --git a/plugins/spit/qgsspitplugin.cpp b/plugins/spit/qgsspitplugin.cpp index 0173bc733eb..9c89f4dbebc 100644 --- a/plugins/spit/qgsspitplugin.cpp +++ b/plugins/spit/qgsspitplugin.cpp @@ -92,7 +92,8 @@ void QgsSpitPlugin::initGui() menu = ((QMainWindow *) qgisMainWindow)->menuBar(); - menuId = menu->insertItem("&Spit", pluginMenu); + //menuId = menu->insertItem("&Spit", pluginMenu); + menuId = qI->addMenu("&Spit", pluginMenu); // Create the action for tool QAction *spitAction = new QAction("Import Shapefiles to PostgreSQL", QIconSet(icon_spit), "&SPIT", 0, this, "spit"); diff --git a/src/qgisiface.cpp b/src/qgisiface.cpp index d5d308a7caf..5d212499167 100644 --- a/src/qgisiface.cpp +++ b/src/qgisiface.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "qgisinterface.h" #include "qgisapp.h" #include "qgsmaplayer.h" @@ -35,3 +36,11 @@ QString QgisIface::activeLayerSource(){ return qgis->activeLayerSource(); } +int QgisIface::addMenu(QString menuText, QPopupMenu *menu){ + QMenuBar *mainMenu = qgis->menuBar(); + // get the index of the help menu + #ifdef DEBUG + std::cout << "Menu item count is : " << mainMenu->count() << std::endl; + #endif + return mainMenu->insertItem(menuText, menu,-1, mainMenu->count() -1); +} diff --git a/src/qgisiface.h b/src/qgisiface.h index 09d541a59b2..ff10f07acbe 100644 --- a/src/qgisiface.h +++ b/src/qgisiface.h @@ -31,6 +31,8 @@ class QgisIface : public QgisInterface{ QgsMapLayer *activeLayer(); //! Get source of the active layer QString activeLayerSource(); + //! Add a menu to the main menu bar of the application, positioned to the left of Help + int addMenu(QString menuText, QPopupMenu *menu); //! Get an integer from the QgisApp object. This is a test function with no real utility int getInt(); private: diff --git a/src/qgisinterface.h b/src/qgisinterface.h index 275a564b0f3..52d30d6d345 100644 --- a/src/qgisinterface.h +++ b/src/qgisinterface.h @@ -7,6 +7,7 @@ #include class QgisApp; class QgsMapLayer; +class QPopupMenu; // interface class for plugins class QgisInterface : public QWidget{ @@ -23,6 +24,8 @@ public: virtual void addVectorLayer(QString vectorLayerPath, QString baseName, QString providerKey)=0; //! Get pointer to the active layer (layer selected in the legend) virtual QgsMapLayer *activeLayer()=0; + //! add a menu item to the main menu, postioned to the left of the Help menu + virtual int addMenu(QString menuText, QPopupMenu *menu) =0; private: //QgisApp *qgis; };