1
/***************************************************************************
3
Shapefile to PostgreSQL Import Tool plugin
6
copyright : (C) 2004 by Gary E.Sherman
7
email : sherman at mrcc.com
9
***************************************************************************/
11
/***************************************************************************
13
* This program is free software; you can redistribute it and/or modify *
14
* it under the terms of the GNU General Public License as published by *
15
* the Free Software Foundation; either version 2 of the License, or *
16
* (at your option) any later version. *
18
***************************************************************************/
19
/* $Id: qgsspitplugin.cpp,v 1.11.6.1 2004/12/03 17:17:36 gsherman Exp $ */
24
#include "../../src/qgisapp.h"
28
#include <qmessagebox.h>
29
#include <qpopupmenu.h>
30
#include <qlineedit.h>
32
#include <qapplication.h>
34
#include "qgsspitplugin.h"
36
// xpm for creating the toolbar icon
37
#include "spiticon.xpm"
40
#define QGISEXTERN extern "C" __declspec( dllexport )
42
#define QGISEXTERN extern "C"
45
static const char * const ident_ = "$Id: qgsspitplugin.cpp,v 1.11.6.1 2004/12/03 17:17:36 gsherman Exp $";
47
static const char * const name_ = "SPIT";
48
static const char * const description_ = "Shapefile to PostgreSQL/PostGIS Import Tool";
49
static const char * const version_ = "Version 0.1";
50
static const QgisPlugin::PLUGINTYPE type_ = QgisPlugin::UI;
55
* Constructor for the plugin. The plugin is passed a pointer to the main app
56
* and an interface object that provides access to exposed functions in QGIS.
57
* @param qgis Pointer to the QGIS main window
58
* @parma _qI Pointer to the QGIS interface object
60
QgsSpitPlugin::QgsSpitPlugin(QgisApp * qgis, QgisIface * _qI)
61
: qgisMainWindow(qgis),
63
QgisPlugin(name_, description_, version_, type_ )
67
QgsSpitPlugin::~QgsSpitPlugin()
73
* Initialize the GUI interface for the plugin
75
void QgsSpitPlugin::initGui()
77
// add a menu with 2 items
78
QPopupMenu *pluginMenu = new QPopupMenu(qgisMainWindow);
79
int menuId = pluginMenu->insertItem(QIconSet(spitIcon),
80
"&Import Shapefiles to PostgreSQL", this, SLOT(spit()));
81
pluginMenu->setWhatsThis(menuId,"Import shapefiles into a PostGIS-enabled PostgreSQL database. "
82
"The schema and field names can be customized on import");
83
// pluginMenu->insertItem("&Unload SPIT Plugin", this, SLOT(unload()));
85
menu = ((QMainWindow *) qgisMainWindow)->menuBar();
87
//menuId = menu->insertItem("&Spit", pluginMenu);
88
menuId = qI->addMenu("&Spit", pluginMenu);
89
// Create the action for tool
90
spitAction = new QAction("Import Shapefiles to PostgreSQL", QIconSet(spitIcon), "&SPIT",
92
spitAction->setWhatsThis("Import shapefiles into a PostGIS-enabled PostgreSQL database. "
93
"The schema and field names can be customized on import");
94
// Connect the action to the spit slot
95
connect(spitAction, SIGNAL(activated()), this, SLOT(spit()));
96
// Add the icon to the toolbar
97
qI->addToolBarIcon(spitAction);
101
// Slot called when the shapefile to postgres menu item is activated
102
void QgsSpitPlugin::spit()
104
QgsSpit *spitDlg = new QgsSpit();
109
// Unload the plugin by cleaning up the GUI
110
void QgsSpitPlugin::unload()
113
menu->removeItem(menuId);
114
qI->removeToolBarIcon(spitAction);
119
* Required extern functions needed for every plugin
120
* These functions can be called prior to creating an instance
121
* of the plugin class
123
// Class factory to return a new instance of the plugin class
124
QGISEXTERN QgisPlugin * classFactory(QgisApp * qgis, QgisIface * qI)
126
return new QgsSpitPlugin(qgis, qI);
129
// Return the name of the plugin
130
QGISEXTERN QString name()
135
// Return the description
136
QGISEXTERN QString description()
141
// Return the type (either UI or MapLayer plugin)
142
QGISEXTERN int type()
147
// Return the version
148
QGISEXTERN QString version()
155
QGISEXTERN void unload(QgisPlugin * p)