Added oracle spatial raster plugin provided by Ivan Lucena

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10566 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2009-04-15 14:18:30 +00:00
parent 7a1f8073f5
commit 2169249c15
12 changed files with 1361 additions and 0 deletions

View File

@ -3,6 +3,7 @@ SUBDIRS (copyright_label
interpolation
north_arrow
scale_bar
oracle_raster
)
IF (POSTGRES_FOUND)

View File

@ -0,0 +1,55 @@
########################################################
# Files
SET (ORACLE_SRCS
qgsoracle_plugin.cpp
qgsselectgeoraster_ui.cpp
qgsoracleconnect_ui.cpp
)
SET (ORACLE_UIS
qgsselectgeorasterbase.ui
qgsoracleconnectbase.ui
)
SET (ORACLE_MOC_HDRS
qgsoracle_plugin.h
qgsselectgeoraster_ui.h
qgsoracleconnect_ui.h
)
SET (ORACLE_RCCS oracleplugin.qrc)
########################################################
# Build
QT4_WRAP_UI (ORACLE_UIS_H ${ORACLE_UIS})
QT4_WRAP_CPP (ORACLE_MOC_SRCS ${ORACLE_MOC_HDRS})
QT4_ADD_RESOURCES(ORACLE_RCC_SRCS ${ORACLE_RCCS})
ADD_LIBRARY (oracleplugin MODULE ${ORACLE_SRCS} ${ORACLE_MOC_SRCS} ${ORACLE_RCC_SRCS} ${ORACLE_UIS_H})
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
${GDAL_INCLUDE_DIR}
../../core ../../core/raster ../../core/renderer ../../core/symbology
../../gui
..
)
TARGET_LINK_LIBRARIES(oracleplugin
qgis_core
qgis_gui
)
########################################################
# Install
INSTALL(TARGETS oracleplugin
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/oracleplugin/" >
<file>oracleplugin.png</file>
</qresource>
</RCC>

View File

@ -0,0 +1,153 @@
/***************************************************************************
oracleplugin.cpp Access Oracle Spatial Plugin
-------------------
begin : Oracle Spatial Plugin
copyright : (C) Ivan Lucena
email : ivan.lucena@pmldnet.com
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#include "qgsoracle_plugin.h"
#include "qgsselectgeoraster_ui.h"
static const char * const sIdent = "$Id: oracleplugin.cpp $";
static const QString sName = QObject::tr("Oracle Spatial GeoRaster");
static const QString sDescription = QObject::tr("Access Oracle Spatial GeoRaster");
static const QString sPluginVersion = QObject::tr("Version 0.1");
static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
//////////////////////////////////////////////////////////////////////
//
// THE FOLLOWING METHODS ARE MANDATORY FOR ALL PLUGINS
//
//////////////////////////////////////////////////////////////////////
/**
* Constructor for the plugin. The plugin is passed a pointer
* an interface object that provides access to exposed functions in QGIS.
* @param theQGisInterface - Pointer to the QGIS interface object
*/
QgsOraclePlugin::QgsOraclePlugin(QgisInterface * theQgisInterface) :
QgisPlugin(sName, sDescription, sPluginVersion, sPluginType),
mQGisIface(theQgisInterface)
{
}
QgsOraclePlugin::~QgsOraclePlugin()
{
}
/*
* Initialize the GUI interface for the plugin - this is only called once when the plugin is
* added to the plugin registry in the QGIS application.
*/
void QgsOraclePlugin::initGui()
{
// Create the action for tool
mQActionPointer = new QAction(QIcon(":/oracleplugin/oracleplugin.png"), tr("Select GeoRaster"), this);
// Set the what's this text
mQActionPointer->setWhatsThis(tr("Open a Oracle Spatial GeoRaster"));
// Connect the action to the run
connect(mQActionPointer, SIGNAL(triggered()), this, SLOT(run()));
// Add the icon to the toolbar
mQGisIface->addToolBarIcon(mQActionPointer);
mQGisIface->addPluginToMenu(tr("&Oracle Spatial"), mQActionPointer);
}
//method defined in interface
void QgsOraclePlugin::help()
{
//implement me!
}
// Slot called when the menu item is triggered
// If you created more menu items / toolbar buttons in initiGui, you should
// create a separate handler for each action - this single run() method will
// not be enough
void QgsOraclePlugin::run()
{
QgsOracleSelectGeoraster *myPluginGui = new QgsOracleSelectGeoraster(mQGisIface->mainWindow(), mQGisIface, QgisGui::ModalDialogFlags);
myPluginGui->setAttribute(Qt::WA_DeleteOnClose);
myPluginGui->show();
}
// Unload the plugin by cleaning up the GUI
void QgsOraclePlugin::unload()
{
// remove the GUI
mQGisIface->removePluginMenu("&Oracle Spatial", mQActionPointer);
mQGisIface->removeToolBarIcon(mQActionPointer);
delete mQActionPointer;
}
//////////////////////////////////////////////////////////////////////////
//
//
// THE FOLLOWING CODE IS AUTOGENERATED BY THE PLUGIN BUILDER SCRIPT
// YOU WOULD NORMALLY NOT NEED TO MODIFY THIS, AND YOUR PLUGIN
// MAY NOT WORK PROPERLY IF YOU MODIFY THIS INCORRECTLY
//
//
//////////////////////////////////////////////////////////////////////////
/**
* Required extern functions needed for every plugin
* These functions can be called prior to creating an instance
* of the plugin class
*/
// Class factory to return a new instance of the plugin class
QGISEXTERN QgisPlugin * classFactory(QgisInterface * theQgisInterfacePointer)
{
return new QgsOraclePlugin(theQgisInterfacePointer);
}
// Return the name of the plugin - note that we do not user class members as
// the class may not yet be insantiated when this method is called.
QGISEXTERN QString name()
{
return sName;
}
// Return the description
QGISEXTERN QString description()
{
return sDescription;
}
// Return the type (either UI or MapLayer plugin)
QGISEXTERN int type()
{
return sPluginType;
}
// Return the version number for the plugin
QGISEXTERN QString version()
{
return sPluginVersion;
}
// Delete ourself
QGISEXTERN void unload(QgisPlugin * thePluginPointer)
{
delete thePluginPointer;
}

View File

@ -0,0 +1,65 @@
/***************************************************************************
oracleplugin.h
-------------------
begin : Oracle Spatial Plugin
copyright : (C) Ivan Lucena
email : ivan.lucena@pmldnet.com
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#ifndef OraclePlugin_H
#define OraclePlugin_H
// Qt Includes
#include <QObject>
#include <QAction>
// QGIS Includes
#include <qgisplugin.h>
#include <qgisinterface.h>
#include <qgisgui.h>
class QgsOraclePlugin : public QObject, public QgisPlugin
{
Q_OBJECT
public:
/**
* Constructor for a plugin. The QgisInterface pointer is passed by
* QGIS when it attempts to instantiate the plugin.
* @param theInterface Pointer to the QgisInterface object.
*/
QgsOraclePlugin(QgisInterface * theInterface);
//! Destructor
virtual ~QgsOraclePlugin();
public slots:
//! init the gui
virtual void initGui();
//! Show the dialog box
void run();
//! unload the plugin
void unload();
//! show the help document
void help();
private:
int mPluginType;
//! Pointer to the QGIS interface object
QgisInterface *mQGisIface;
//!pointer to the qaction for this plugin
QAction * mQActionPointer;
};
#endif //OraclePlugin_H

View File

@ -0,0 +1,88 @@
/***************************************************************************
oracleconnectgui.cpp
-------------------
begin : Oracle Spatial Plugin
copyright : (C) Ivan Lucena
email : ivan.lucena@pmldnet.com
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#include "qgsoracleconnect_ui.h"
// Qt Includes
#include <QSettings>
#include <QMessageBox>
QgsOracleConnect::QgsOracleConnect(QWidget* parent,
const QString& connName,
Qt::WFlags fl) : QDialog(parent, fl)
{
setupUi(this);
if ( ! connName.isEmpty() )
{
// populate the dialog with the information stored for the connection
// populate the fields with the stored setting parameters
QSettings settings;
QString key = "/Oracle/connections/" + connName;
txtDatabase->setText( settings.value( key + "/database" ).toString() );
txtUsername->setText( settings.value( key + "/username" ).toString() );
if ( settings.value( key + "/savepass" ).toString() == "true" )
{
txtPassword->setText( settings.value( key + "/password" ).toString() );
chkStorePassword->setChecked( true );
}
txtName->setText( connName );
}
}
QgsOracleConnect::~QgsOracleConnect()
{
}
void QgsOracleConnect::on_btnCancel_clicked()
{
helpInfo();
}
void QgsOracleConnect::on_btnOk_clicked()
{
saveConnection();
}
void QgsOracleConnect::saveConnection()
{
QSettings settings;
QString baseKey = "/Oracle/connections/";
settings.setValue( baseKey + "selected", txtName->text() );
baseKey += txtName->text();
settings.setValue( baseKey + "/database", txtDatabase->text() );
settings.setValue( baseKey + "/username", txtUsername->text() );
settings.setValue( baseKey + "/password", txtPassword->text() );
settings.setValue( baseKey + "/savepass", chkStorePassword->isChecked() ? "true" : "false" );
settings.setValue( baseKey + "/subdtset", "GEOR:" +
txtUsername->text() + "/" +
txtPassword->text() + "@" +
txtDatabase->text() );
accept();
}
void QgsOracleConnect::helpInfo()
{
// QgsContextHelp::run( context_id );
}

View File

@ -0,0 +1,46 @@
/***************************************************************************
oracleconnectgui.u
-------------------
begin : Oracle Spatial Plugin
copyright : (C) Ivan Lucena
email : ivan.lucena@pmldnet.com
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#ifndef QgsOracleConnect_H
#define QgsOracleConnect_H
// Qt Designer Includes
#include "ui_qgsoracleconnectbase.h"
// QGIS Includes
#include <qgisgui.h>
class QgsOracleConnect : public QDialog, private Ui::OracleConnectGuiBase
{
Q_OBJECT
public:
QgsOracleConnect(QWidget* parent = 0,
const QString& connName = QString::null,
Qt::WFlags fl = QgisGui::ModalDialogFlags);
~QgsOracleConnect();
private:
void saveConnection();
void helpInfo();
public slots:
void on_btnOk_clicked();
void on_btnCancel_clicked();
void on_btnHelp_clicked();
};
#endif /* _ORACLECONNECTGUI_H */

View File

@ -0,0 +1,248 @@
<ui version="4.0" >
<class>OracleConnectGuiBase</class>
<widget class="QDialog" name="OracleConnectGuiBase" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>436</width>
<height>207</height>
</rect>
</property>
<property name="windowTitle" >
<string>Create Oracle Connection</string>
</property>
<property name="windowIcon" >
<iconset>
<normaloff/>
</iconset>
</property>
<widget class="QWidget" name="layoutWidget" >
<property name="geometry" >
<rect>
<x>339</x>
<y>11</y>
<width>89</width>
<height>189</height>
</rect>
</property>
<layout class="QVBoxLayout" name="boxConfirm" >
<property name="spacing" >
<number>6</number>
</property>
<property name="margin" >
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="btnOk" >
<property name="text" >
<string>OK</string>
</property>
<property name="shortcut" >
<string/>
</property>
<property name="autoDefault" >
<bool>true</bool>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCancel" >
<property name="text" >
<string>Cancel</string>
</property>
<property name="shortcut" >
<string/>
</property>
<property name="autoDefault" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>87</width>
<height>121</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="GroupBox1" >
<property name="geometry" >
<rect>
<x>10</x>
<y>10</y>
<width>322</width>
<height>191</height>
</rect>
</property>
<property name="title" >
<string>Connection Information</string>
</property>
<layout class="QVBoxLayout" name="_2" >
<property name="spacing" >
<number>0</number>
</property>
<property name="margin" >
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="boxFields" >
<property name="spacing" >
<number>6</number>
</property>
<property name="margin" >
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="boxFieldLabels" >
<property name="spacing" >
<number>6</number>
</property>
<property name="margin" >
<number>0</number>
</property>
<item>
<widget class="QLabel" name="TextLabel1_2" >
<property name="text" >
<string>Name</string>
</property>
<property name="buddy" >
<cstring>txtName</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="TextLabel2" >
<property name="text" >
<string>Database instance</string>
</property>
<property name="buddy" >
<cstring>txtDatabase</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="TextLabel3" >
<property name="text" >
<string>Username</string>
</property>
<property name="buddy" >
<cstring>txtUsername</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="TextLabel3_2" >
<property name="text" >
<string>Password</string>
</property>
<property name="buddy" >
<cstring>txtPassword</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="boxFieldEntries" >
<property name="spacing" >
<number>6</number>
</property>
<property name="margin" >
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="txtName" >
<property name="toolTip" >
<string>Name of the new connection</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtDatabase" />
</item>
<item>
<widget class="QLineEdit" name="txtUsername" />
</item>
<item>
<widget class="QLineEdit" name="txtPassword" >
<property name="echoMode" >
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="boxCheckbox" >
<property name="spacing" >
<number>6</number>
</property>
<property name="margin" >
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="chkStorePassword" >
<property name="text" >
<string>Save Password</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<layoutdefault spacing="6" margin="11" />
<resources/>
<connections>
<connection>
<sender>btnOk</sender>
<signal>clicked()</signal>
<receiver>OracleConnectGuiBase</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>383</x>
<y>24</y>
</hint>
<hint type="destinationlabel" >
<x>217</x>
<y>103</y>
</hint>
</hints>
</connection>
<connection>
<sender>btnCancel</sender>
<signal>clicked()</signal>
<receiver>OracleConnectGuiBase</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>383</x>
<y>56</y>
</hint>
<hint type="destinationlabel" >
<x>217</x>
<y>103</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,321 @@
/***************************************************************************
oracleselectgui.cpp
-------------------
begin : Oracle Spatial Plugin
copyright : (C) Ivan Lucena
email : ivan.lucena@pmldnet.com
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#include "qgsselectgeoraster_ui.h"
#include "qgsoracleconnect_ui.h"
//GDAL includes
#include "gdal.h"
#include "ogr_api.h"
#include "ogrsf_frmts.h"
#include "qgsvectorlayer.h"
QgsOracleSelectGeoraster::QgsOracleSelectGeoraster(QWidget* parent,
QgisInterface* iface,
Qt::WFlags fl) : QDialog(parent, fl), mIface(iface)
{
setupUi(this);
/*
* Load the list of connection from the registry
*/
populateConnectionList();
/*
* Repeat last selected connection
*/
QSettings settings;
QString selected = settings.value( "/Oracle/connections/selected" ).toString();
if ( selected == cmbConnections->currentText() )
{
this->connectToServer();
}
}
QgsOracleSelectGeoraster::~QgsOracleSelectGeoraster()
{
}
void QgsOracleSelectGeoraster::populateConnectionList()
{
QSettings settings;
settings.beginGroup( "/Oracle/connections" );
QStringList keys = settings.childGroups();
QStringList::Iterator it = keys.begin();
/*
* Fillup the combobox with connection names
*/
cmbConnections->clear();
while ( it != keys.end() )
{
cmbConnections->addItem( *it );
++it;
}
settings.endGroup();
setConnectionListPosition();
/*
* Update the status of several buttons
*/
if ( keys.begin() == keys.end() )
{
btnConnect->setEnabled( false );
btnEdit->setEnabled( false );
btnDelete->setEnabled( false );
}
else
{
btnConnect->setEnabled( true );
btnEdit->setEnabled( true );
btnDelete->setEnabled( true );
}
}
void QgsOracleSelectGeoraster::addNewConnection()
{
QgsOracleConnect *oc = new QgsOracleConnect( this, "New Connection" );
if ( oc->exec() )
{
populateConnectionList();
}
}
void QgsOracleSelectGeoraster::editConnection()
{
QgsOracleConnect *oc = new QgsOracleConnect( this, cmbConnections->currentText() );
if ( oc->exec() )
{
populateConnectionList();
}
}
void QgsOracleSelectGeoraster::deleteConnection()
{
QSettings settings;
QString key = "/Oracle/connections/" + cmbConnections->currentText();
QString msg =
tr( "Are you sure you want to remove the " ) +
cmbConnections->currentText() +
tr( " connection and all associated settings?" );
QMessageBox::StandardButton result = QMessageBox::information( this,
tr( "Confirm Delete" ),
msg,
QMessageBox::Ok | QMessageBox::Cancel );
if ( result == QMessageBox::Ok )
{
settings.remove( key + "/database" );
settings.remove( key + "/username" );
settings.remove( key + "/password" );
settings.remove( key + "/savepass" );
settings.remove( key + "/subdtset" );
settings.remove( key );
cmbConnections->removeItem( cmbConnections->currentIndex() );
setConnectionListPosition();
lineEdit->setText( "" );
listWidget->clear();
}
}
void QgsOracleSelectGeoraster::connectToServer()
{
QSettings settings;
QString key = "/Oracle/connections/" + cmbConnections->currentText();
QString username = settings.value( key + "/username" ).toString();
QString password = settings.value( key + "/password" ).toString();
QString savepass = settings.value( key + "/savepass" ).toString();
QString database = settings.value( key + "/database" ).toString();
QString subdtset = settings.value( key + "/subdtset" ).toString();
bool makeConnection = true;
if ( savepass == "false" )
{
makeConnection = false;
QString password = QInputDialog::getText( this,
tr( "Password for " ) + username + "/<password>@" + database,
tr( "Please enter your password:" ),
QLineEdit::Password,
QString::null,
&makeConnection);
}
if (makeConnection)
{
settings.setValue( "/Oracle/connections/selected",
cmbConnections->currentText() );
showSelection( subdtset );
lineEdit->setText( subdtset );
}
}
void QgsOracleSelectGeoraster::showSelection( const QString & line )
{
QString identification = line;
GDALDatasetH hDS = NULL;
GDALAccess eAccess = GA_ReadOnly;
/*
* Set access mode
*/
if( checkBox->checkState() == Qt::Checked )
{
eAccess = GA_Update;
}
/*
* Try to open georaster dataset
*/
hDS = GDALOpenShared( identification.toAscii(), eAccess );
btnAdd->setEnabled( false );
if ( hDS == NULL )
{
QMessageBox::information( this,
tr( "Open failed" ),
tr( "The connection to " + identification.toAscii() +
" failed. Please verify your connection parameters."
" Make sure you have the GDAL GeoRaster plugin installed." ) );
return;
}
btnAdd->setEnabled( true );
/*
* Get subdataset list
*/
char **papszMetadata = NULL;
papszMetadata = GDALGetMetadata( hDS, "SUBDATASETS" );
int nSubDatasets = CSLCount( papszMetadata );
/*
* Add GeoRaster Layer
*/
if ( ! nSubDatasets )
{
mIface->addRasterLayer( identification );
GDALClose(hDS);
return;
}
/*
* Save subdataset
*/
QSettings settings;
settings.setValue( "/Oracle/connections/" +
cmbConnections->currentText() + "/subdtset", identification );
/*
* List subdatasets
*/
QStringList fields = identification.split(',');
QString count = QString::number( nSubDatasets / 2 );
QString plural = "s";
if ( count == "1" )
{
plural = "";
}
if ( fields.size() < 4 )
{
labelStatus->setText( QString( "%1 GeoRaster table%2" )
.arg( count ).arg( plural ) );
checkBox->setEnabled( false );
}
else if ( fields.size() == 4 )
{
labelStatus->setText( QString( "%1 GeoRaster column%2 on table %3" )
.arg( count ).arg( plural ).arg( fields[3] ) );
checkBox->setEnabled( false );
}
else if ( fields.size() == 5 )
{
labelStatus->setText( QString( "%1 GeoRaster object%2 on table %3 column %4" )
.arg( count ).arg( plural ).arg( fields[3] ).arg( fields[4] ) );
checkBox->setEnabled( true );
}
else
{
labelStatus->setText( QString( "%1 GeoRaster object%2 on table %3 column %4 where %5" )
.arg( count ).arg( plural ).arg( fields[3] ).arg( fields[4] ).arg( fields[5] ) );
checkBox->setEnabled( true );
}
/*
* Populate selection list based on subdataset names
*/
listWidget->clear();
QListWidgetItem *textItem;
for ( int i = 0; i < nSubDatasets; i += 2 )
{
QString metadata = papszMetadata[i];
QStringList subdataset = metadata.split( '=' );
textItem = new QListWidgetItem( subdataset[1] );
listWidget->addItem( textItem );
}
GDALClose(hDS);
}
void QgsOracleSelectGeoraster::showHelp()
{
// implement me
}
void QgsOracleSelectGeoraster::setConnectionListPosition()
{
QSettings settings;
// If possible, set the item currently displayed database
QString toSelect = settings.value( "/Oracle/connections/selected" ).toString();
// Does toSelect exist in cmbConnections?
bool set = false;
for ( int i = 0; i < cmbConnections->count(); ++ i)
{
if ( cmbConnections->itemText(i) == toSelect )
{
cmbConnections->setCurrentIndex( i );
set = true;
break;
}
}
// If we couldn't find the stored item, but there are some,
// default to the last item (this makes some sense when deleting
// items as it allows the user to repeatidly click on delete to
// remove a whole lot of items).
if ( ! set && cmbConnections->count() > 0 )
{
// If toSelect is null, then the selected connection wasn't found
// by QSettings, which probably means that this is the first time
// the user has used qgis with database connections, so default to
// the first in the list of connetions. Otherwise default to the last.
if ( toSelect.isNull() )
cmbConnections->setCurrentIndex( 0 );
else
cmbConnections->setCurrentIndex( cmbConnections->count() - 1 );
}
}

View File

@ -0,0 +1,95 @@
/***************************************************************************
oracleselectgui.h
-------------------
begin : Oracle Spatial Plugin
copyright : (C) Ivan Lucena
email : ivan.lucena@pmldnet.com
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#ifndef OraclePluginGUI_H
#define OraclePluginGUI_H
// Qt Designer Includes
#include "ui_qgsselectgeorasterbase.h"
//Qt includes
#include <QSettings>
#include <QMessageBox>
#include <QInputDialog>
// QGIS Includes
#include <qgisinterface.h>
#include <qgsmapcanvas.h>
class QgsOracleSelectGeoraster : public QDialog, private Ui::SelectGeoRasterBase
{
Q_OBJECT
public:
QgsOracleSelectGeoraster(QWidget* parent, QgisInterface* iface, Qt::WFlags fl = 0);
~QgsOracleSelectGeoraster();
private:
QgisInterface* mIface;
QString mUri;
private:
void addNewConnection();
void editConnection();
void deleteConnection();
void populateConnectionList();
void connectToServer();
void showHelp();
void setConnectionListPosition();
void showSelection( const QString & line );
public slots:
void on_btnNew_clicked()
{
addNewConnection();
};
void on_btnEdit_clicked()
{
editConnection();
};
void on_btnDelete_clicked()
{
deleteConnection();
};
void on_btnConnect_clicked()
{
connectToServer();
};
void on_listWidget_clicked( QModelIndex Index )
{
if( lineEdit->text() == listWidget->currentItem()->text() )
{
showSelection( lineEdit->text() );
}
else
{
lineEdit->setText( listWidget->currentItem()->text() );
}
}
void on_btnAdd_clicked()
{
showSelection( lineEdit->text() );
};
};
#endif

View File

@ -0,0 +1,284 @@
<ui version="4.0" >
<class>SelectGeoRasterBase</class>
<widget class="QDialog" name="SelectGeoRasterBase" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>461</width>
<height>454</height>
</rect>
</property>
<property name="windowTitle" >
<string>Select Oracle Spatial GeoRaster</string>
</property>
<property name="windowIcon" >
<iconset>
<normaloff>../../ui</normaloff>../../ui</iconset>
</property>
<property name="sizeGripEnabled" >
<bool>true</bool>
</property>
<property name="modal" >
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" colspan="4" >
<widget class="QGroupBox" name="GroupBox1" >
<property name="title" >
<string>Server Connections</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="4" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>131</width>
<height>30</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="5" >
<widget class="QComboBox" name="cmbConnections" />
</item>
<item row="1" column="0" >
<widget class="QPushButton" name="btnConnect" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>C&amp;onnect</string>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QPushButton" name="btnEdit" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Edit</string>
</property>
</widget>
</item>
<item row="1" column="3" >
<widget class="QPushButton" name="btnDelete" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Delete</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QPushButton" name="btnNew" >
<property name="text" >
<string>&amp;New</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="4" >
<widget class="QGroupBox" name="gbCRS" >
<property name="title" >
<string>Selection</string>
</property>
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="margin" >
<number>9</number>
</property>
<item>
<widget class="QLabel" name="labelCoordRefSys" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit" />
</item>
<item>
<widget class="QCheckBox" name="checkBox" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Update</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0" colspan="4" >
<widget class="QLabel" name="labelStatus" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Ignored" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Ready</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="2" >
<widget class="QPushButton" name="btnAdd" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>&amp;Select</string>
</property>
<property name="shortcut" >
<string>Alt+A</string>
</property>
<property name="autoDefault" >
<bool>true</bool>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4" >
<widget class="QGroupBox" name="btnGrpImageEncoding" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>16</width>
<height>64</height>
</size>
</property>
<property name="title" >
<string>Subdatasets</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QListWidget" name="listWidget" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFillBackground" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>284</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" >
<widget class="QPushButton" name="btnHelp" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="text" >
<string>Help</string>
</property>
<property name="shortcut" >
<string>F1</string>
</property>
<property name="autoDefault" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="3" >
<widget class="QPushButton" name="btnCancel" >
<property name="text" >
<string>C&amp;lose</string>
</property>
<property name="shortcut" >
<string>Alt+L</string>
</property>
<property name="autoDefault" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<tabstops>
<tabstop>cmbConnections</tabstop>
<tabstop>btnConnect</tabstop>
<tabstop>btnNew</tabstop>
<tabstop>btnEdit</tabstop>
<tabstop>btnDelete</tabstop>
<tabstop>btnHelp</tabstop>
<tabstop>btnAdd</tabstop>
<tabstop>btnCancel</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>btnCancel</sender>
<signal>clicked()</signal>
<receiver>SelectGeoRasterBase</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>410</x>
<y>457</y>
</hint>
<hint type="destinationlabel" >
<x>229</x>
<y>252</y>
</hint>
</hints>
</connection>
</connections>
</ui>