[QGIS Commit] r8286 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Mar 27 05:13:21 EDT 2008


Author: jef
Date: 2008-03-27 05:13:21 -0400 (Thu, 27 Mar 2008)
New Revision: 8286

Modified:
   trunk/qgis/src/app/qgsdbsourceselect.cpp
Log:
put out a warning message when no accessible postgis tables were found

Modified: trunk/qgis/src/app/qgsdbsourceselect.cpp
===================================================================
--- trunk/qgis/src/app/qgsdbsourceselect.cpp	2008-03-27 00:44:22 UTC (rev 8285)
+++ trunk/qgis/src/app/qgsdbsourceselect.cpp	2008-03-27 09:13:21 UTC (rev 8286)
@@ -536,30 +536,39 @@
   PGresult *result = PQexec(pg, sql.toUtf8());
   if (result)
   {
-    for (int idx = 0; idx < PQntuples(result); idx++)
+    if( PQntuples(result)==0 )
     {
-      QString tableName = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("f_table_name").toUtf8())));
-      QString schemaName = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("f_table_schema").toUtf8())));
+      QMessageBox::warning(this, tr("No accessible tables found"),
+        tr
+        ("Database connection was successful, but no accessible tables were found.\n\n"
+         "Please verify that you have SELECT privilege on a PostGIS' geometry_columns\n"
+         "table and at least one table carrying PostGIS geometry."));
+    }
+    else 
+    {
+      for (int idx = 0; idx < PQntuples(result); idx++)
+      {
+        QString tableName = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("f_table_name").toUtf8())));
+        QString schemaName = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("f_table_schema").toUtf8())));
 
-      QString column = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("f_geometry_column").toUtf8())));
-      QString type = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("type").toUtf8())));
+        QString column = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("f_geometry_column").toUtf8())));
+        QString type = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("type").toUtf8())));
 
-      QString as = "";
-      if(type=="GEOMETRY" && !searchGeometryColumnsOnly) 
-      {
-        addSearchGeometryColumn(schemaName, tableName,  column);
-        as=type="WAITING";
+        QString as = "";
+        if(type=="GEOMETRY" && !searchGeometryColumnsOnly) 
+        {
+          addSearchGeometryColumn(schemaName, tableName,  column);
+          as=type="WAITING";
+        }
+
+        mTableModel.addTableEntry(type, schemaName, tableName, column, "");
       }
-
-      mTableModel.addTableEntry(type, schemaName, tableName, column, "");
     }
     ok = true;
   }
   PQclear(result);
 
   //search for geometry columns in tables that are not in the geometry_columns metatable
-
-
   QApplication::restoreOverrideCursor();
   if (searchGeometryColumnsOnly)
   {



More information about the QGIS-commit mailing list