Skip to content

Commit

Permalink
Provide the user with the option to only display spatial tables that
Browse files Browse the repository at this point in the history
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
  • Loading branch information
g_j_m committed Aug 21, 2006
1 parent a1069f9 commit 379e1d1
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 76 deletions.
10 changes: 8 additions & 2 deletions src/gui/qgsdbsourceselect.cpp
Expand Up @@ -314,6 +314,7 @@ void QgsDbSourceSelect::on_btnConnect_clicked()
connString += username;
QString password = settings.readEntry(key + "/password");
bool searchPublicOnly = settings.readBoolEntry(key + "/publicOnly");
bool searchGeometryColumnsOnly = settings.readBoolEntry(key + "/geometryColumnsOnly");
bool makeConnection = true;
if (password == QString::null)
{
Expand Down Expand Up @@ -394,7 +395,8 @@ void QgsDbSourceSelect::on_btnConnect_clicked()

// get the list of suitable tables and columns and populate the UI
geomCol details;
if (getGeometryColumnInfo(pd, details, searchPublicOnly))
if (getGeometryColumnInfo(pd, details, searchGeometryColumnsOnly,
searchPublicOnly))
{
details.sort();
geomCol::const_iterator iter = details.begin();
Expand Down Expand Up @@ -519,7 +521,8 @@ void QgsDbSourceSelect::setSql(QTableWidgetItem *item)
}

bool QgsDbSourceSelect::getGeometryColumnInfo(PGconn *pg,
geomCol& details, bool searchPublicOnly)
geomCol& details, bool searchGeometryColumnsOnly,
bool searchPublicOnly)
{
bool ok = false;

Expand Down Expand Up @@ -573,6 +576,9 @@ bool QgsDbSourceSelect::getGeometryColumnInfo(PGconn *pg,
}
PQclear(result);

if (searchGeometryColumnsOnly)
return ok;

// Now have a look for geometry columns that aren't in the
// geometry_columns table. This code is specific to postgresql,
// but an equivalent query should be possible in other
Expand Down
4 changes: 3 additions & 1 deletion src/gui/qgsdbsourceselect.h
Expand Up @@ -97,7 +97,9 @@ class QgsDbSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
typedef std::list<geomPair > geomCol;

bool getGeometryColumnInfo(PGconn *pd,
geomCol& details, bool searchPublicOnly);
geomCol& details,
bool searchGeometryColumnsOnly,
bool searchPublicOnly);
// Set the position of the database connection list to the last
// used one.
void setConnectionListPosition();
Expand Down
12 changes: 12 additions & 0 deletions src/gui/qgsnewconnection.cpp
Expand Up @@ -49,6 +49,10 @@ QgsNewConnection::QgsNewConnection(QWidget *parent, const QString& connName, Qt:
if ( ! settings.readBoolEntry(key + "/publicOnly", false))
s = Qt::Unchecked;
cb_publicSchemaOnly->setCheckState(s);
s = Qt::Checked;
if ( ! settings.readBoolEntry(key + "/geometrycolumnsOnly", false))
s = Qt::Unchecked;
cb_geometryColumnsOnly->setCheckState(s);
if (settings.readEntry(key + "/save") == "true")
{
txtPassword->setText(settings.readEntry(key + "/password"));
Expand All @@ -74,6 +78,13 @@ void QgsNewConnection::on_btnCancel_clicked(){
// cancel the dialog
reject();
}
void QgsNewConnection::on_cb_geometryColumnsOnly_clicked()
{
if (cb_geometryColumnsOnly->checkState() == Qt::Checked)
cb_publicSchemaOnly->setEnabled(false);
else
cb_publicSchemaOnly->setEnabled(true);
}

/** end Autoconnected SLOTS **/

Expand Down Expand Up @@ -119,6 +130,7 @@ void QgsNewConnection::saveConnection()
settings.writeEntry(baseKey + "/username", txtUsername->text());
settings.writeEntry(baseKey + "/password", txtPassword->text());
settings.writeEntry(baseKey + "/publicOnly", cb_publicSchemaOnly->isChecked());
settings.writeEntry(baseKey + "/geometryColumnsOnly", cb_geometryColumnsOnly->isChecked());
if (chkStorePassword->isChecked())
{
settings.writeEntry(baseKey + "/save", "true");
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsnewconnection.h
Expand Up @@ -42,6 +42,7 @@ class QgsNewConnection : public QDialog, private Ui::QgsNewConnectionBase
void on_btnCancel_clicked();
void on_btnHelp_clicked();
void on_btnConnect_clicked();
void on_cb_geometryColumnsOnly_clicked();
private:
static const int context_id = -929865718;
};
Expand Down
159 changes: 86 additions & 73 deletions src/ui/qgsnewconnectionbase.ui
Expand Up @@ -9,7 +9,7 @@
<x>0</x>
<y>0</y>
<width>435</width>
<height>389</height>
<height>320</height>
</rect>
</property>
<property name="sizePolicy" >
Expand All @@ -33,6 +33,77 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</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>
<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>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>87</width>
<height>150</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="0" >
<widget class="Q3GroupBox" name="GroupBox1" >
<property name="title" >
Expand Down Expand Up @@ -192,6 +263,19 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="cb_geometryColumnsOnly" >
<property name="toolTip" >
<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>
</property>
<property name="whatsThis" >
<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>
</property>
<property name="text" >
<string>Only look in the geometry_columns table</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_publicSchemaOnly" >
<property name="toolTip" >
Expand All @@ -208,85 +292,14 @@
</layout>
</widget>
</item>
<item row="0" column="1" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</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>
<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>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>87</width>
<height>200</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>Q3GroupBox</class>
<extends></extends>
<extends>QGroupBox</extends>
<header>Qt3Support/Q3GroupBox</header>
<container>1</container>
<pixmap></pixmap>
Expand Down

0 comments on commit 379e1d1

Please sign in to comment.