Skip to content

Commit 379e1d1

Browse files
author
g_j_m
committed
Provide the user with the option to only display spatial tables that
are listed in the geometry_columns table. For well-maintained databases (where all the spatial tables of interest have been listed in the geometry_columns table) this can considerably speed up the initial display of available spatial tables. git-svn-id: http://svn.osgeo.org/qgis/trunk@5718 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent a1069f9 commit 379e1d1

5 files changed

+110
-76
lines changed

src/gui/qgsdbsourceselect.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ void QgsDbSourceSelect::on_btnConnect_clicked()
314314
connString += username;
315315
QString password = settings.readEntry(key + "/password");
316316
bool searchPublicOnly = settings.readBoolEntry(key + "/publicOnly");
317+
bool searchGeometryColumnsOnly = settings.readBoolEntry(key + "/geometryColumnsOnly");
317318
bool makeConnection = true;
318319
if (password == QString::null)
319320
{
@@ -394,7 +395,8 @@ void QgsDbSourceSelect::on_btnConnect_clicked()
394395

395396
// get the list of suitable tables and columns and populate the UI
396397
geomCol details;
397-
if (getGeometryColumnInfo(pd, details, searchPublicOnly))
398+
if (getGeometryColumnInfo(pd, details, searchGeometryColumnsOnly,
399+
searchPublicOnly))
398400
{
399401
details.sort();
400402
geomCol::const_iterator iter = details.begin();
@@ -519,7 +521,8 @@ void QgsDbSourceSelect::setSql(QTableWidgetItem *item)
519521
}
520522

521523
bool QgsDbSourceSelect::getGeometryColumnInfo(PGconn *pg,
522-
geomCol& details, bool searchPublicOnly)
524+
geomCol& details, bool searchGeometryColumnsOnly,
525+
bool searchPublicOnly)
523526
{
524527
bool ok = false;
525528

@@ -573,6 +576,9 @@ bool QgsDbSourceSelect::getGeometryColumnInfo(PGconn *pg,
573576
}
574577
PQclear(result);
575578

579+
if (searchGeometryColumnsOnly)
580+
return ok;
581+
576582
// Now have a look for geometry columns that aren't in the
577583
// geometry_columns table. This code is specific to postgresql,
578584
// but an equivalent query should be possible in other

src/gui/qgsdbsourceselect.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ class QgsDbSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
9797
typedef std::list<geomPair > geomCol;
9898

9999
bool getGeometryColumnInfo(PGconn *pd,
100-
geomCol& details, bool searchPublicOnly);
100+
geomCol& details,
101+
bool searchGeometryColumnsOnly,
102+
bool searchPublicOnly);
101103
// Set the position of the database connection list to the last
102104
// used one.
103105
void setConnectionListPosition();

src/gui/qgsnewconnection.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ QgsNewConnection::QgsNewConnection(QWidget *parent, const QString& connName, Qt:
4949
if ( ! settings.readBoolEntry(key + "/publicOnly", false))
5050
s = Qt::Unchecked;
5151
cb_publicSchemaOnly->setCheckState(s);
52+
s = Qt::Checked;
53+
if ( ! settings.readBoolEntry(key + "/geometrycolumnsOnly", false))
54+
s = Qt::Unchecked;
55+
cb_geometryColumnsOnly->setCheckState(s);
5256
if (settings.readEntry(key + "/save") == "true")
5357
{
5458
txtPassword->setText(settings.readEntry(key + "/password"));
@@ -74,6 +78,13 @@ void QgsNewConnection::on_btnCancel_clicked(){
7478
// cancel the dialog
7579
reject();
7680
}
81+
void QgsNewConnection::on_cb_geometryColumnsOnly_clicked()
82+
{
83+
if (cb_geometryColumnsOnly->checkState() == Qt::Checked)
84+
cb_publicSchemaOnly->setEnabled(false);
85+
else
86+
cb_publicSchemaOnly->setEnabled(true);
87+
}
7788

7889
/** end Autoconnected SLOTS **/
7990

@@ -119,6 +130,7 @@ void QgsNewConnection::saveConnection()
119130
settings.writeEntry(baseKey + "/username", txtUsername->text());
120131
settings.writeEntry(baseKey + "/password", txtPassword->text());
121132
settings.writeEntry(baseKey + "/publicOnly", cb_publicSchemaOnly->isChecked());
133+
settings.writeEntry(baseKey + "/geometryColumnsOnly", cb_geometryColumnsOnly->isChecked());
122134
if (chkStorePassword->isChecked())
123135
{
124136
settings.writeEntry(baseKey + "/save", "true");

src/gui/qgsnewconnection.h

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class QgsNewConnection : public QDialog, private Ui::QgsNewConnectionBase
4242
void on_btnCancel_clicked();
4343
void on_btnHelp_clicked();
4444
void on_btnConnect_clicked();
45+
void on_cb_geometryColumnsOnly_clicked();
4546
private:
4647
static const int context_id = -929865718;
4748
};

src/ui/qgsnewconnectionbase.ui

+86-73
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<x>0</x>
1010
<y>0</y>
1111
<width>435</width>
12-
<height>389</height>
12+
<height>320</height>
1313
</rect>
1414
</property>
1515
<property name="sizePolicy" >
@@ -33,6 +33,77 @@
3333
<property name="spacing" >
3434
<number>6</number>
3535
</property>
36+
<item row="0" column="1" >
37+
<layout class="QVBoxLayout" >
38+
<property name="margin" >
39+
<number>0</number>
40+
</property>
41+
<property name="spacing" >
42+
<number>6</number>
43+
</property>
44+
<item>
45+
<widget class="QPushButton" name="btnOk" >
46+
<property name="text" >
47+
<string>OK</string>
48+
</property>
49+
<property name="shortcut" >
50+
<string/>
51+
</property>
52+
<property name="autoDefault" >
53+
<bool>true</bool>
54+
</property>
55+
<property name="default" >
56+
<bool>true</bool>
57+
</property>
58+
</widget>
59+
</item>
60+
<item>
61+
<widget class="QPushButton" name="btnCancel" >
62+
<property name="text" >
63+
<string>Cancel</string>
64+
</property>
65+
<property name="shortcut" >
66+
<string/>
67+
</property>
68+
<property name="autoDefault" >
69+
<bool>true</bool>
70+
</property>
71+
</widget>
72+
</item>
73+
<item>
74+
<widget class="QPushButton" name="btnHelp" >
75+
<property name="enabled" >
76+
<bool>true</bool>
77+
</property>
78+
<property name="text" >
79+
<string>Help</string>
80+
</property>
81+
<property name="shortcut" >
82+
<string>F1</string>
83+
</property>
84+
<property name="autoDefault" >
85+
<bool>true</bool>
86+
</property>
87+
</widget>
88+
</item>
89+
<item>
90+
<spacer>
91+
<property name="orientation" >
92+
<enum>Qt::Vertical</enum>
93+
</property>
94+
<property name="sizeType" >
95+
<enum>QSizePolicy::Expanding</enum>
96+
</property>
97+
<property name="sizeHint" >
98+
<size>
99+
<width>87</width>
100+
<height>150</height>
101+
</size>
102+
</property>
103+
</spacer>
104+
</item>
105+
</layout>
106+
</item>
36107
<item row="0" column="0" >
37108
<widget class="Q3GroupBox" name="GroupBox1" >
38109
<property name="title" >
@@ -192,6 +263,19 @@
192263
</item>
193264
</layout>
194265
</item>
266+
<item>
267+
<widget class="QCheckBox" name="cb_geometryColumnsOnly" >
268+
<property name="toolTip" >
269+
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:Sans Serif; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;">Restrict the displayed tables to those that are in the geometry_columns table&lt;/p>&lt;/body>&lt;/html></string>
270+
</property>
271+
<property name="whatsThis" >
272+
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:Sans Serif; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;">Restricts the displayed tables to those that are in the geometry_columns table. This can speed up the initial display of spatial tables.&lt;/p>&lt;/body>&lt;/html></string>
273+
</property>
274+
<property name="text" >
275+
<string>Only look in the geometry_columns table</string>
276+
</property>
277+
</widget>
278+
</item>
195279
<item>
196280
<widget class="QCheckBox" name="cb_publicSchemaOnly" >
197281
<property name="toolTip" >
@@ -208,85 +292,14 @@
208292
</layout>
209293
</widget>
210294
</item>
211-
<item row="0" column="1" >
212-
<layout class="QVBoxLayout" >
213-
<property name="margin" >
214-
<number>0</number>
215-
</property>
216-
<property name="spacing" >
217-
<number>6</number>
218-
</property>
219-
<item>
220-
<widget class="QPushButton" name="btnOk" >
221-
<property name="text" >
222-
<string>OK</string>
223-
</property>
224-
<property name="shortcut" >
225-
<string/>
226-
</property>
227-
<property name="autoDefault" >
228-
<bool>true</bool>
229-
</property>
230-
<property name="default" >
231-
<bool>true</bool>
232-
</property>
233-
</widget>
234-
</item>
235-
<item>
236-
<widget class="QPushButton" name="btnCancel" >
237-
<property name="text" >
238-
<string>Cancel</string>
239-
</property>
240-
<property name="shortcut" >
241-
<string/>
242-
</property>
243-
<property name="autoDefault" >
244-
<bool>true</bool>
245-
</property>
246-
</widget>
247-
</item>
248-
<item>
249-
<widget class="QPushButton" name="btnHelp" >
250-
<property name="enabled" >
251-
<bool>true</bool>
252-
</property>
253-
<property name="text" >
254-
<string>Help</string>
255-
</property>
256-
<property name="shortcut" >
257-
<string>F1</string>
258-
</property>
259-
<property name="autoDefault" >
260-
<bool>true</bool>
261-
</property>
262-
</widget>
263-
</item>
264-
<item>
265-
<spacer>
266-
<property name="orientation" >
267-
<enum>Qt::Vertical</enum>
268-
</property>
269-
<property name="sizeType" >
270-
<enum>QSizePolicy::Expanding</enum>
271-
</property>
272-
<property name="sizeHint" >
273-
<size>
274-
<width>87</width>
275-
<height>200</height>
276-
</size>
277-
</property>
278-
</spacer>
279-
</item>
280-
</layout>
281-
</item>
282295
</layout>
283296
</widget>
284297
<layoutdefault spacing="6" margin="11" />
285298
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
286299
<customwidgets>
287300
<customwidget>
288301
<class>Q3GroupBox</class>
289-
<extends></extends>
302+
<extends>QGroupBox</extends>
290303
<header>Qt3Support/Q3GroupBox</header>
291304
<container>1</container>
292305
<pixmap></pixmap>

0 commit comments

Comments
 (0)