Skip to content
Permalink
Browse files
use messagebar to report test connection results in the Add new PostGIS
connection dialog
  • Loading branch information
alexbruy committed May 23, 2017
1 parent 90bef91 commit 9b7d389736b0eb87b98c336628d5daad3fb1f72b
Showing with 140 additions and 145 deletions.
  1. +10 −6 src/providers/postgres/qgspgnewconnection.cpp
  2. +2 −0 src/providers/postgres/qgspgnewconnection.h
  3. +128 −139 src/ui/qgspgnewconnectionbase.ui
@@ -104,6 +104,12 @@ QgsPgNewConnection::QgsPgNewConnection( QWidget *parent, const QString &connName
txtName->setText( connName );
}
}

QgsPgNewConnection::~QgsPgNewConnection()
{
delete bar;
}

//! Autoconnected SLOTS *
void QgsPgNewConnection::accept()
{
@@ -201,17 +207,15 @@ void QgsPgNewConnection::testConnection()
if ( conn )
{
// Database successfully opened; we can now issue SQL commands.
QMessageBox::information( this,
tr( "Test connection" ),
tr( "Connection to %1 was successful" ).arg( txtDatabase->text() ) );
bar->pushMessage( tr( "Connection to %1 was successful" ).arg( txtDatabase->text() ),
QgsMessageBar::INFO );

// free pg connection resources
conn->unref();
}
else
{
QMessageBox::information( this,
tr( "Test connection" ),
tr( "Connection failed - consult message log for details.\n\n" ) );
bar->pushMessage( tr( "Connection failed - consult message log for details." ),
QgsMessageBar::WARNING );
}
}
@@ -32,6 +32,8 @@ class QgsPgNewConnection : public QDialog, private Ui::QgsPgNewConnectionBase
//! Constructor
QgsPgNewConnection( QWidget *parent = nullptr, const QString &connName = QString::null, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );

~QgsPgNewConnection();

//! Tests the connection using the parameters supplied
void testConnection();
public slots:
@@ -26,32 +26,110 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout3">
<item row="1" column="0">
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<item row="1" column="0">
<widget class="QGroupBox" name="GroupBox1">
<property name="title">
<string>Connection Information</string>
</property>
<layout class="QGridLayout" name="gridLayout2">
<property name="leftMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>5</number>
</property>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="TextLabel1_2">
<property name="text">
<string>Name</string>
</property>
<property name="buddy">
<cstring>txtName</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="txtName">
<property name="toolTip">
<string>Name of the new connection</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Service</string>
</property>
<property name="buddy">
<cstring>txtService</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="txtService"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="TextLabel1">
<property name="text">
<string>Host</string>
</property>
<property name="buddy">
<cstring>txtHost</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="txtHost"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="TextLabel2_2">
<property name="text">
<string>Port</string>
</property>
<property name="buddy">
<cstring>txtPort</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="txtPort">
<property name="text">
<string>5432</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="TextLabel2">
<property name="text">
<string>Database</string>
</property>
<property name="buddy">
<cstring>txtDatabase</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="txtDatabase"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="TextLabel3_3">
<property name="text">
<string>SSL mode</string>
</property>
<property name="buddy">
<cstring>cbxSSLmode</cstring>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="cbxSSLmode"/>
</item>
</layout>
</item>
<item>
<widget class="QTabWidget" name="tabAuthentication">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
@@ -127,7 +205,14 @@
</widget>
</widget>
</item>
<item row="3" column="0">
<item>
<widget class="QPushButton" name="btnConnect">
<property name="text">
<string>&amp;Test Connection</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_geometryColumnsOnly">
<property name="toolTip">
<string>Restrict the displayed tables to those that are in the layer registries.</string>
@@ -140,112 +225,27 @@
</property>
</widget>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout">
<item>
<layout class="QVBoxLayout">
<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="label">
<property name="text">
<string>Service</string>
</property>
<property name="buddy">
<cstring>txtService</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="TextLabel1">
<property name="text">
<string>Host</string>
</property>
<property name="buddy">
<cstring>txtHost</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="TextLabel2_2">
<property name="text">
<string>Port</string>
</property>
<property name="buddy">
<cstring>txtPort</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="TextLabel2">
<property name="text">
<string>Database</string>
</property>
<property name="buddy">
<cstring>txtDatabase</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="TextLabel3_3">
<property name="text">
<string>SSL mode</string>
</property>
<property name="buddy">
<cstring>cbxSSLmode</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout">
<item>
<widget class="QLineEdit" name="txtName">
<property name="toolTip">
<string>Name of the new connection</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtService"/>
</item>
<item>
<widget class="QLineEdit" name="txtHost"/>
</item>
<item>
<widget class="QLineEdit" name="txtPort">
<property name="text">
<string>5432</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtDatabase"/>
</item>
<item>
<widget class="QComboBox" name="cbxSSLmode"/>
</item>
</layout>
</item>
</layout>
</item>
<item row="4" column="0">
<item>
<widget class="QCheckBox" name="cb_dontResolveType">
<property name="text">
<string>Don't resolve type of unrestricted columns (GEOMETRY)</string>
</property>
</widget>
</item>
<item row="6" column="0">
<item>
<widget class="QCheckBox" name="cb_publicSchemaOnly">
<property name="toolTip">
<string>Restrict the search to the public schema for spatial tables not in the geometry_columns table</string>
</property>
<property name="whatsThis">
<string>When searching for spatial tables that are not in the geometry_columns tables, restrict the search to tables that are in the public schema (for some databases this can save lots of time)</string>
</property>
<property name="text">
<string>Only look in the 'public' schema</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_allowGeometrylessTables">
<property name="text">
<string>Also list tables with no geometry</string>
@@ -255,7 +255,7 @@
</property>
</widget>
</item>
<item row="7" column="0">
<item>
<widget class="QCheckBox" name="cb_useEstimatedMetadata">
<property name="toolTip">
<string>Use estimated table statistics for the layer metadata.</string>
@@ -276,27 +276,7 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="btnConnect">
<property name="text">
<string>&amp;Test Connection</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="cb_publicSchemaOnly">
<property name="toolTip">
<string>Restrict the search to the public schema for spatial tables not in the geometry_columns table</string>
</property>
<property name="whatsThis">
<string>When searching for spatial tables that are not in the geometry_columns tables, restrict the search to tables that are in the public schema (for some databases this can save lots of time)</string>
</property>
<property name="text">
<string>Only look in the 'public' schema</string>
</property>
</widget>
</item>
<item row="8" column="0">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -312,6 +292,9 @@
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QgsMessageBar" name="bar" native="true"/>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
@@ -321,6 +304,12 @@
<extends>QLineEdit</extends>
<header>qgspasswordlineedit.h</header>
</customwidget>
<customwidget>
<class>QgsMessageBar</class>
<extends>QWidget</extends>
<header>qgsmessagebar.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>txtName</tabstop>

0 comments on commit 9b7d389

Please sign in to comment.