added interface for positioning menu items from plugins

git-svn-id: http://svn.osgeo.org/qgis/trunk@711 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
gsherman 2004-02-06 07:04:05 +00:00
parent 2124bf5a0f
commit f46cdf38c1
6 changed files with 20 additions and 4 deletions

View File

@ -1 +1 @@
SUBDIRS = example maplayer spit geoprocessing
SUBDIRS = spit geoprocessing

View File

@ -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
//<db_name>, <table_name>, <column_name>, <srid>, <type>, <dimension>
sql = QString("select addgeometrycolumn('%1','%2','%3',%4,'%5',%6)")
.arg(dbname)
.arg(bb->schema())
.arg(bb->bufferLayerName())
.arg(bb->geometryColumn())
.arg(bb->srid())

View File

@ -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");

View File

@ -1,5 +1,6 @@
#include <iostream>
#include <qstring.h>
#include <qmenubar.h>
#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);
}

View File

@ -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:

View File

@ -7,6 +7,7 @@
#include <qwidget.h>
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;
};