Skip to content

Commit 6232388

Browse files
author
jef
committed
fix #2759 and some cleanups
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13593 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9127bf9 commit 6232388

2 files changed

Lines changed: 26 additions & 60 deletions

File tree

‎src/plugins/oracle_raster/qgsselectgeoraster_ui.cpp‎

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void QgsOracleSelectGeoraster::populateConnectionList()
9292
}
9393
}
9494

95-
void QgsOracleSelectGeoraster::addNewConnection()
95+
void QgsOracleSelectGeoraster::on_btnNew_clicked()
9696
{
9797
QgsOracleConnect *oc = new QgsOracleConnect( this, "New Connection" );
9898
if ( oc->exec() )
@@ -101,7 +101,7 @@ void QgsOracleSelectGeoraster::addNewConnection()
101101
}
102102
}
103103

104-
void QgsOracleSelectGeoraster::editConnection()
104+
void QgsOracleSelectGeoraster::on_btnEdit_clicked()
105105
{
106106
QgsOracleConnect *oc = new QgsOracleConnect( this, cmbConnections->currentText() );
107107
if ( oc->exec() )
@@ -110,7 +110,7 @@ void QgsOracleSelectGeoraster::editConnection()
110110
}
111111
}
112112

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

138138
void QgsOracleSelectGeoraster::connectToServer()
139139
{
140+
if ( cmbConnections->currentText().isEmpty() )
141+
return;
142+
140143
QSettings settings;
141144
QString key = "/Oracle/connections/" + cmbConnections->currentText();
142145
QString username = settings.value( key + "/username" ).toString();
@@ -281,32 +284,30 @@ void QgsOracleSelectGeoraster::showSelection( const QString & line )
281284
GDALClose( hDS );
282285
}
283286

284-
void QgsOracleSelectGeoraster::showHelp()
287+
void QgsOracleSelectGeoraster::on_listWidget_clicked( QModelIndex Index )
285288
{
286-
// implement me
289+
if ( lineEdit->text() == listWidget->currentItem()->text() )
290+
{
291+
showSelection( lineEdit->text() );
292+
}
293+
else
294+
{
295+
lineEdit->setText( listWidget->currentItem()->text() );
296+
}
287297
}
288298

289299
void QgsOracleSelectGeoraster::setConnectionListPosition()
290300
{
291-
QSettings settings;
292301
// If possible, set the item currently displayed database
302+
QSettings settings;
293303
QString toSelect = settings.value( "/Oracle/connections/selected" ).toString();
294-
// Does toSelect exist in cmbConnections?
295-
bool set = false;
296-
for ( int i = 0; i < cmbConnections->count(); ++ i )
297-
{
298-
if ( cmbConnections->itemText( i ) == toSelect )
299-
{
300-
cmbConnections->setCurrentIndex( i );
301-
set = true;
302-
break;
303-
}
304-
}
304+
cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) );
305+
305306
// If we couldn't find the stored item, but there are some,
306307
// default to the last item (this makes some sense when deleting
307308
// items as it allows the user to repeatidly click on delete to
308309
// remove a whole lot of items).
309-
if ( ! set && cmbConnections->count() > 0 )
310+
if ( cmbConnections->currentIndex() == -1 && cmbConnections->count() > 0 )
310311
{
311312
// If toSelect is null, then the selected connection wasn't found
312313
// by QSettings, which probably means that this is the first time

‎src/plugins/oracle_raster/qgsselectgeoraster_ui.h‎

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
// QGIS Includes
2929
#include <qgisinterface.h>
3030
#include <qgsmapcanvas.h>
31+
#include "qgscontexthelp.h"
3132

3233
class QgsOracleSelectGeoraster : public QDialog, private Ui::SelectGeoRasterBase
3334
{
@@ -42,54 +43,18 @@ class QgsOracleSelectGeoraster : public QDialog, private Ui::SelectGeoRasterBase
4243
QString mUri;
4344

4445
private:
45-
void addNewConnection();
46-
void editConnection();
47-
void deleteConnection();
4846
void populateConnectionList();
4947
void connectToServer();
50-
void showHelp();
5148
void setConnectionListPosition();
5249
void showSelection( const QString & line );
5350

5451
public slots:
55-
56-
void on_btnNew_clicked()
57-
{
58-
addNewConnection();
59-
};
60-
61-
void on_btnEdit_clicked()
62-
{
63-
editConnection();
64-
};
65-
66-
void on_btnDelete_clicked()
67-
{
68-
deleteConnection();
69-
};
70-
71-
void on_btnConnect_clicked()
72-
{
73-
connectToServer();
74-
};
75-
76-
void on_listWidget_clicked( QModelIndex Index )
77-
{
78-
if ( lineEdit->text() == listWidget->currentItem()->text() )
79-
{
80-
showSelection( lineEdit->text() );
81-
}
82-
else
83-
{
84-
lineEdit->setText( listWidget->currentItem()->text() );
85-
}
86-
}
87-
88-
void on_btnAdd_clicked()
89-
{
90-
showSelection( lineEdit->text() );
91-
};
92-
52+
void on_btnConnect_clicked() { connectToServer(); }
53+
void on_btnNew_clicked();
54+
void on_btnEdit_clicked();
55+
void on_btnDelete_clicked();
56+
void on_listWidget_clicked( QModelIndex Index );
57+
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
9358
};
9459

9560
#endif

0 commit comments

Comments
 (0)