Skip to content

Commit

Permalink
fix #2759 and some cleanups
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@13593 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 29, 2010
1 parent 24ce8da commit 1ac041a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 60 deletions.
37 changes: 19 additions & 18 deletions src/plugins/oracle_raster/qgsselectgeoraster_ui.cpp
Expand Up @@ -92,7 +92,7 @@ void QgsOracleSelectGeoraster::populateConnectionList()
}
}

void QgsOracleSelectGeoraster::addNewConnection()
void QgsOracleSelectGeoraster::on_btnNew_clicked()
{
QgsOracleConnect *oc = new QgsOracleConnect( this, "New Connection" );
if ( oc->exec() )
Expand All @@ -101,7 +101,7 @@ void QgsOracleSelectGeoraster::addNewConnection()
}
}

void QgsOracleSelectGeoraster::editConnection()
void QgsOracleSelectGeoraster::on_btnEdit_clicked()
{
QgsOracleConnect *oc = new QgsOracleConnect( this, cmbConnections->currentText() );
if ( oc->exec() )
Expand All @@ -110,7 +110,7 @@ void QgsOracleSelectGeoraster::editConnection()
}
}

void QgsOracleSelectGeoraster::deleteConnection()
void QgsOracleSelectGeoraster::on_btnDelete_clicked()
{
QSettings settings;
QString key = "/Oracle/connections/" + cmbConnections->currentText();
Expand All @@ -137,6 +137,9 @@ void QgsOracleSelectGeoraster::deleteConnection()

void QgsOracleSelectGeoraster::connectToServer()
{
if ( cmbConnections->currentText().isEmpty() )
return;

QSettings settings;
QString key = "/Oracle/connections/" + cmbConnections->currentText();
QString username = settings.value( key + "/username" ).toString();
Expand Down Expand Up @@ -281,32 +284,30 @@ void QgsOracleSelectGeoraster::showSelection( const QString & line )
GDALClose( hDS );
}

void QgsOracleSelectGeoraster::showHelp()
void QgsOracleSelectGeoraster::on_listWidget_clicked( QModelIndex Index )
{
// implement me
if ( lineEdit->text() == listWidget->currentItem()->text() )
{
showSelection( lineEdit->text() );
}
else
{
lineEdit->setText( listWidget->currentItem()->text() );
}
}

void QgsOracleSelectGeoraster::setConnectionListPosition()
{
QSettings settings;
// If possible, set the item currently displayed database
QSettings settings;
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;
}
}
cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) );

// 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 ( cmbConnections->currentIndex() == -1 && 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
Expand Down
49 changes: 7 additions & 42 deletions src/plugins/oracle_raster/qgsselectgeoraster_ui.h
Expand Up @@ -28,6 +28,7 @@
// QGIS Includes
#include <qgisinterface.h>
#include <qgsmapcanvas.h>
#include "qgscontexthelp.h"

class QgsOracleSelectGeoraster : public QDialog, private Ui::SelectGeoRasterBase
{
Expand All @@ -42,54 +43,18 @@ class QgsOracleSelectGeoraster : public QDialog, private Ui::SelectGeoRasterBase
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() );
};

void on_btnConnect_clicked() { connectToServer(); }
void on_btnNew_clicked();
void on_btnEdit_clicked();
void on_btnDelete_clicked();
void on_listWidget_clicked( QModelIndex Index );
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
};

#endif

0 comments on commit 1ac041a

Please sign in to comment.