[QGIS Commit] r8293 - trunk/qgis/src/plugins/spit

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Mar 28 13:36:21 EDT 2008


Author: jef
Date: 2008-03-28 13:36:20 -0400 (Fri, 28 Mar 2008)
New Revision: 8293

Removed:
   trunk/qgis/src/plugins/spit/qgseditreservedwordsbase.ui
   trunk/qgis/src/plugins/spit/qgseditreservedwordsdialog.cpp
   trunk/qgis/src/plugins/spit/qgseditreservedwordsdialog.h
Modified:
   trunk/qgis/src/plugins/spit/CMakeLists.txt
   trunk/qgis/src/plugins/spit/qgspgutil.cpp
   trunk/qgis/src/plugins/spit/qgspgutil.h
   trunk/qgis/src/plugins/spit/qgsshapefile.cpp
   trunk/qgis/src/plugins/spit/qgsshapefile.h
   trunk/qgis/src/plugins/spit/qgsspit.cpp
   trunk/qgis/src/plugins/spit/qgsspit.h
   trunk/qgis/src/plugins/spit/qgsspitbase.ui
Log:
spit plugin fix
- quote values and identifiers properly
- remove now unnecessary reserved word dialog
- also consider primary key field and geometry field in double field check
- allow rename of primary key field
- remove disabled connect button (spit automatically connects on OK)
- keep the window open window if there was an error
- fixes #865 and #930


Modified: trunk/qgis/src/plugins/spit/CMakeLists.txt
===================================================================
--- trunk/qgis/src/plugins/spit/CMakeLists.txt	2008-03-28 11:02:05 UTC (rev 8292)
+++ trunk/qgis/src/plugins/spit/CMakeLists.txt	2008-03-28 17:36:20 UTC (rev 8293)
@@ -7,7 +7,6 @@
      qgsconnectiondialog.cpp
      qgspgutil.cpp
      qgsshapefile.cpp
-     qgseditreservedwordsdialog.cpp
 )
 
 SET (SPIT_PLUGIN_SRCS
@@ -23,14 +22,12 @@
 SET (SPIT_UIS
      qgsconnectiondialogbase.ui
      qgsspitbase.ui
-     qgseditreservedwordsbase.ui
      ../../ui/qgsmessageviewer.ui
 )
 
 SET (SPIT_EXE_MOC_HDRS
      qgsspit.h
      qgsshapefile.h
-     qgseditreservedwordsdialog.h
      qgsconnectiondialog.h
 )
 

Deleted: trunk/qgis/src/plugins/spit/qgseditreservedwordsbase.ui
===================================================================
--- trunk/qgis/src/plugins/spit/qgseditreservedwordsbase.ui	2008-03-28 11:02:05 UTC (rev 8292)
+++ trunk/qgis/src/plugins/spit/qgseditreservedwordsbase.ui	2008-03-28 17:36:20 UTC (rev 8293)
@@ -1,135 +0,0 @@
-<ui version="4.0" >
- <class>QgsEditReservedWordsBase</class>
- <widget class="QDialog" name="QgsEditReservedWordsBase" >
-  <property name="geometry" >
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>497</width>
-    <height>468</height>
-   </rect>
-  </property>
-  <property name="windowTitle" >
-   <string>Edit Reserved Words</string>
-  </property>
-  <property name="sizeGripEnabled" >
-   <bool>true</bool>
-  </property>
-  <property name="modal" >
-   <bool>true</bool>
-  </property>
-  <layout class="QGridLayout" >
-   <property name="margin" >
-    <number>9</number>
-   </property>
-   <property name="spacing" >
-    <number>6</number>
-   </property>
-   <item row="1" column="0" >
-    <widget class="QTableWidget" name="lvColumns" >
-     <property name="minimumSize" >
-      <size>
-       <width>0</width>
-       <height>0</height>
-      </size>
-     </property>
-     <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;">Double click the Column Name column to change the name of the column.&lt;/p>&lt;/body>&lt;/html></string>
-     </property>
-     <property name="selectionMode" >
-      <enum>QAbstractItemView::NoSelection</enum>
-     </property>
-     <property name="selectionBehavior" >
-      <enum>QAbstractItemView::SelectRows</enum>
-     </property>
-     <column>
-      <property name="text" >
-       <string>Status</string>
-      </property>
-     </column>
-     <column>
-      <property name="text" >
-       <string>Column Name</string>
-      </property>
-     </column>
-     <column>
-      <property name="text" >
-       <string>Index</string>
-      </property>
-     </column>
-    </widget>
-   </item>
-   <item row="0" column="0" colspan="2" >
-    <widget class="QTextEdit" name="txtExplanation" >
-     <property name="sizePolicy" >
-      <sizepolicy>
-       <hsizetype>7</hsizetype>
-       <vsizetype>0</vsizetype>
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="maximumSize" >
-      <size>
-       <width>16777215</width>
-       <height>101</height>
-      </size>
-     </property>
-     <property name="readOnly" >
-      <bool>true</bool>
-     </property>
-     <property name="html" >
-      <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;">This shapefile contains reserved words. These may affect the import into PostgreSQL. Edit the column names so none of the reserved words listed at the right are used (click on a Column Name entry to edit). You may also change any other column name if desired.&lt;/p>&lt;/body>&lt;/html></string>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="1" >
-    <widget class="QGroupBox" name="groupBox" >
-     <property name="title" >
-      <string>Reserved Words</string>
-     </property>
-     <layout class="QGridLayout" >
-      <property name="margin" >
-       <number>9</number>
-      </property>
-      <property name="spacing" >
-       <number>6</number>
-      </property>
-      <item row="0" column="0" >
-       <widget class="QListWidget" name="lstReservedWords" >
-        <property name="sizePolicy" >
-         <sizepolicy>
-          <hsizetype>5</hsizetype>
-          <vsizetype>7</vsizetype>
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="maximumSize" >
-         <size>
-          <width>140</width>
-          <height>16777215</height>
-         </size>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item row="2" column="0" colspan="2" >
-    <widget class="QDialogButtonBox" name="buttonBox" >
-     <property name="orientation" >
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons" >
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
-     </property>
-    </widget>
-   </item>
-  </layout>
- </widget>
- <layoutdefault spacing="6" margin="11" />
- <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
- <resources/>
- <connections/>
-</ui>

Deleted: trunk/qgis/src/plugins/spit/qgseditreservedwordsdialog.cpp
===================================================================
--- trunk/qgis/src/plugins/spit/qgseditreservedwordsdialog.cpp	2008-03-28 11:02:05 UTC (rev 8292)
+++ trunk/qgis/src/plugins/spit/qgseditreservedwordsdialog.cpp	2008-03-28 17:36:20 UTC (rev 8293)
@@ -1,116 +0,0 @@
-/***************************************************************************
-     qgseditreservedwordsdialog.cpp
-     --------------------------------------
-    Date                 : Sun Sep 16 12:13:18 AKDT 2007
-    Copyright            : (C) 2007 by Gary E. Sherman
-    Email                : sherman at mrcc dot com
- ***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-// $Id$
-
-#include <QIcon>
-#include <QPixmap>
-#include <QTableWidgetItem>
-
-#include "qgscontexthelp.h"
-#include "qgspgutil.h"
-#include "spit_icons.h"
-
-#include "qgseditreservedwordsdialog.h"
-QgsEditReservedWordsDialog::QgsEditReservedWordsDialog(QWidget *parent, Qt::WFlags fl)
-  : QDialog(parent, fl)
-{
-  setupUi(this);
-  // buggered if I know why setting the columns and their labels in
-  // designer doesn't last until here, hence it's done manually...
-  lvColumns->setColumnCount(3);
-  QStringList headerText;
-  headerText << tr("Status") << tr("Column Name") << tr("Index");
-  lvColumns->setHorizontalHeaderLabels(headerText);
-  lvColumns->resizeColumnsToContents();
-}
-
-QgsEditReservedWordsDialog::~QgsEditReservedWordsDialog()
-{
-}
-void QgsEditReservedWordsDialog::setReservedWords(const QStringList &words)
-{
-  lstReservedWords->addItems(words);
-}
-void QgsEditReservedWordsDialog::checkWord(QTableWidgetItem* item)
-{
-  // Column 1 is the one that the user can edit. However we can get
-  // itemChanged signals from any item in the table, so ignore other
-  // columns.
-  if (lvColumns->column(item) != 1)
-    return;
-
-  QgsPgUtil *pgu = QgsPgUtil::instance();
-  int row = lvColumns->row(item);
-
-  // Column 0 is the one with the tick/cross pixmap
-  if(pgu->isReserved(item->text()))
-  {
-    lvColumns->item(row, 0)->setIcon(QIcon(QPixmap(icon_reserved)));
-  }
-  else
-  {
-    lvColumns->item(row, 0)->setIcon(QIcon(QPixmap(icon_ok)));
-  }
-}
-void QgsEditReservedWordsDialog::addColumn(QString column, bool isReserved, int index)
-{
-  QString indexNumber;
-  indexNumber = indexNumber.setNum(index);
-
-  QTableWidgetItem *reservedItem = new QTableWidgetItem();
-  QTableWidgetItem *nameItem = new QTableWidgetItem(column);
-  QTableWidgetItem *indexItem = new QTableWidgetItem(indexNumber);
-
-  // Two of the columns shouldn't be editable
-  reservedItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
-  indexItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
-
-  // Set the appropriate icon
-  if(isReserved)
-  {
-    reservedItem->setIcon(QIcon(QPixmap(icon_reserved)));
-  }
-  else
-  {
-    reservedItem->setIcon(QIcon(QPixmap(icon_ok)));
-  }
-
-  // Insert a new row into the table
-  int rows = lvColumns->rowCount();
-  lvColumns->insertRow(rows);
-  lvColumns->setItem(rows, 0, reservedItem);
-  lvColumns->setItem(rows, 1, nameItem);
-  lvColumns->setItem(rows, 2, indexItem);
-}
-QStringList QgsEditReservedWordsDialog::columnNames()
-{
-  // Extract and return the renamed columns from the table
-  QStringList cols;
-  lvColumns->sortItems(2);
-
-  for (int i = 0; i < lvColumns->rowCount(); ++i)
-  {
-    cols << lvColumns->item(0, 2)->text();
-  }
-  return QStringList(cols);
-}
-void QgsEditReservedWordsDialog::setDescription(const QString &description)
-{
-  txtExplanation->setPlainText(description);
-}
-void QgsEditReservedWordsDialog::on_buttonBox_helpRequested()
-{
-  QgsContextHelp::run(context_id);
-}

Deleted: trunk/qgis/src/plugins/spit/qgseditreservedwordsdialog.h
===================================================================
--- trunk/qgis/src/plugins/spit/qgseditreservedwordsdialog.h	2008-03-28 11:02:05 UTC (rev 8292)
+++ trunk/qgis/src/plugins/spit/qgseditreservedwordsdialog.h	2008-03-28 17:36:20 UTC (rev 8293)
@@ -1,48 +0,0 @@
-/***************************************************************************
-     qgseditreservedwordsdialog.h
-     --------------------------------------
-    Date                 : Sun Sep 16 12:13:24 AKDT 2007
-    Copyright            : (C) 2007 by Gary E. Sherman
-    Email                : sherman at mrcc dot com
- ***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-#ifndef QGSEDITRESERVEDWORDSDIALOG_H
-#define QGSEDITRESERVEDWORDSDIALOG_H
-
-// $Id$
-
-#include "ui_qgseditreservedwordsbase.h"
-#include "qgisgui.h"
-class QgsEditReservedWordsDialog : public QDialog, private Ui::QgsEditReservedWordsBase
-{
-    Q_OBJECT
-public:
-    QgsEditReservedWordsDialog(QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags);
-    ~QgsEditReservedWordsDialog();
-    void addColumn(QString column, bool isReserved, int index);
-    void setReservedWords(const QStringList &);
-    QStringList columnNames();
-    //! Set the description displayed in the dialog
-    void setDescription(const QString &description);
-
-private:
-    void checkWord(QTableWidgetItem *);
-
-    static const int context_id = 0;
-
-private slots:
-    void on_buttonBox_accepted() { accept(); }
-    void on_buttonBox_rejected() { reject(); }
-    void on_buttonBox_helpRequested();
-    void on_lvColumns_itemChanged(QTableWidgetItem* item) { checkWord(item); }
-    void on_lvColumns_itemClicked(QTableWidgetItem* item) 
-      { lvColumns->editItem(item); }
-
-};
-#endif //QGSEDITRESERVEDWORDSDIALOG_H

Modified: trunk/qgis/src/plugins/spit/qgspgutil.cpp
===================================================================
--- trunk/qgis/src/plugins/spit/qgspgutil.cpp	2008-03-28 11:02:05 UTC (rev 8292)
+++ trunk/qgis/src/plugins/spit/qgspgutil.cpp	2008-03-28 17:36:20 UTC (rev 8293)
@@ -24,22 +24,15 @@
   }
   return mInstance;
 }
+
 QgsPgUtil::QgsPgUtil()
 {
-  // load the reserved word map
-  initReservedWords();
 }
+
 QgsPgUtil::~QgsPgUtil()
 {
 }
-bool QgsPgUtil::isReserved(QString word)
-{
-  // uppercase the word before testing it since all our reserved words are
-  // stored in uppercase
-  
-  QStringList::iterator it = mReservedWords.find(word.upper());
-  return (it != mReservedWords.end());
-}
+
 void QgsPgUtil::setConnection(PGconn *con)
 {
   mPgConnection = con;
@@ -48,106 +41,19 @@
 {
   return mPgConnection;
 }
-const QStringList & QgsPgUtil::reservedWords()
+
+QString QgsPgUtil::quotedIdentifier( QString ident )
 {
-  return mReservedWords;
+  ident.replace('"', "\"\"");
+  return ident.prepend("\"").append("\"");
 }
-void QgsPgUtil::initReservedWords()
+
+QString QgsPgUtil::quotedValue( QString value )
 {
-  // create the reserved word list by loading
-  // the words into a QStringList. We code them here
-  // for now rather than deal with the complexities
-  // of finding and loading from a text file
-  // in the install path
-  mReservedWords << "ALL"
-    << "ANALYSE"
-    << "ANALYZE"
-    << "AND"
-    << "ANY"
-    << "ARRAY"
-    << "AS"
-    << "ASC"
-    << "AUTHORIZATION"
-    << "BETWEEN"
-    << "BINARY"
-    << "BOTH"
-    << "CASE"
-    << "CAST"
-    << "CHECK"
-    << "COLLATE"
-    << "COLUMN"
-    << "CONSTRAINT"
-    << "CREATE"
-    << "CROSS"
-    << "CURRENT_DATE"
-    << "CURRENT_TIME"
-    << "CURRENT_TIMESTAMP"
-    << "CURRENT_USER"
-    << "DEFAULT"
-    << "DEFERRABLE"
-    << "DESC"
-    << "DISTINCT"
-    << "DO"
-    << "ELSE"
-    << "END"
-    << "EXCEPT"
-    << "FALSE"
-    << "FOR"
-    << "FOREIGN"
-    << "FREEZE"
-    << "FROM"
-    << "FULL"
-    << "GRANT"
-    << "GROUP"
-    << "HAVING"
-    << "ILIKE"
-    << "IN"
-    << "INITIALLY"
-    << "INNER"
-    << "INTERSECT"
-    << "INTO"
-    << "IS"
-    << "ISNULL"
-    << "JOIN"
-    << "LEADING"
-    << "LEFT"
-    << "LIKE"
-    << "LIMIT"
-    << "LOCALTIME"
-    << "LOCALTIMESTAMP"
-    << "NAMES"
-    << "NATURAL"
-    << "NEW"
-    << "NOT"
-    << "NOTNULL"
-    << "NULL"
-    << "OFF"
-    << "OFFSET"
-    << "OLD"
-    << "ON"
-    << "ONLY"
-    << "OR"
-    << "ORDER"
-    << "OUTER"
-    << "OVERLAPS"
-    << "PLACING"
-    << "PRIMARY"
-    << "REFERENCES"
-    << "RIGHT"
-    << "SELECT"
-    << "SESSION_USER"
-    << "SIMILAR"
-    << "SOME"
-    << "TABLE"
-    << "THEN"
-    << "TO"
-    << "TRAILING"
-    << "TRUE"
-    << "UNION"
-    << "UNIQUE"
-    << "USER"
-    << "USING"
-    << "VERBOSE"
-    << "WHEN"
-    << "WHERE";
+  if( value.isNull() )
+    return "NULL";
+  
+  // FIXME: use PQescapeStringConn
+  value.replace("'", "''");
+  return value.prepend("'").append("'");
 }

Modified: trunk/qgis/src/plugins/spit/qgspgutil.h
===================================================================
--- trunk/qgis/src/plugins/spit/qgspgutil.h	2008-03-28 11:02:05 UTC (rev 8292)
+++ trunk/qgis/src/plugins/spit/qgspgutil.h	2008-03-28 17:36:20 UTC (rev 8293)
@@ -33,12 +33,7 @@
     //! Instance function to return a pointer to the one and
     //only QgsPgUtil object (QgsPgUtil is a Singleton)
     static QgsPgUtil* instance();
-    /*! Checks to see if word is a PG reserved word.
-     * The comparison is case-insensitive.
-     * @param word Word to check
-     * @return True if word is a PG reserved word
-     */
-    bool isReserved(QString word);
+    
     /*!
      * Set the connection to be used in database operations
      * @param con Pointer to an active PostgreSQL connection
@@ -49,10 +44,15 @@
      * @return Pointer to the PostgreSQL connection object
      */
     PGconn *connection();
-    /*!
-     * Get the reserved word list
+
+        /** Double quote a PostgreSQL identifier for placement in a SQL string.
      */
-    const QStringList & reservedWords();
+    static QString quotedIdentifier( QString ident );
+
+    /** Quote a value for placement in a SQL string.
+     */
+    static QString quotedValue( QString value );
+    
   protected:
     //! Protected constructor
     QgsPgUtil();

Modified: trunk/qgis/src/plugins/spit/qgsshapefile.cpp
===================================================================
--- trunk/qgis/src/plugins/spit/qgsshapefile.cpp	2008-03-28 11:02:05 UTC (rev 8292)
+++ trunk/qgis/src/plugins/spit/qgsshapefile.cpp	2008-03-28 17:36:20 UTC (rev 8293)
@@ -36,6 +36,8 @@
 #include "qgis.h"
 #include "qgslogger.h"
 
+#include "qgspgutil.h"
+
 // for htonl
 #ifdef WIN32
 #include <winsock.h>
@@ -60,7 +62,7 @@
   // init the geometry types
   geometries << "NULL" << "POINT" << "LINESTRING" << "POLYGON" << "MULTPOINT" 
     << "MULTILINESTRING" << "MULTIPOLYGON" << "GEOMETRYCOLLECTION";
-  
+
   codec = QTextCodec::codecForName(encoding.toLocal8Bit().data());
   if (!codec)
     codec = QTextCodec::codecForLocale();
@@ -219,7 +221,7 @@
       int numFields = OGR_F_GetFieldCount(feat);
       for(int n=0; n<numFields; n++)
       {
-          QString s = codec->toUnicode(OGR_Fld_GetNameRef(OGR_F_GetFieldDefnRef(feat,n)));
+        QString s = codec->toUnicode(OGR_Fld_GetNameRef(OGR_F_GetFieldDefnRef(feat,n)));
         column_names.push_back(s);
       }
       
@@ -263,41 +265,30 @@
   }
 }
 
-bool QgsShapeFile::insertLayer(QString dbname, QString schema, QString geom_col, 
+bool QgsShapeFile::insertLayer(QString dbname, QString schema, QString primary_key, QString geom_col, 
                                QString srid, PGconn * conn, QProgressDialog& pro, bool &fin,
                                QString& errorText)
 {
   connect(&pro, SIGNAL(canceled()), this, SLOT(cancelImport()));
   import_canceled = false;
   bool result = true;
-  // Mangle the table name to make it PG compliant by replacing spaces with 
-  // underscores
-  table_name = table_name.replace(" ","_");
 
-  QString query = "CREATE TABLE "+schema+"."+table_name+"(gid int4 PRIMARY KEY, ";
+  QString query = QString("CREATE TABLE %1.%2(%3 int4 PRIMARY KEY")
+                    .arg( QgsPgUtil::quotedIdentifier(schema) )
+                    .arg( QgsPgUtil::quotedIdentifier(table_name) )
+                    .arg( QgsPgUtil::quotedIdentifier(primary_key) );
 
-  for(uint n=0; n<column_names.size() && result; n++){
-    if(!column_names[n][0].isLetter())
-      result = false;
-
-    char * esc_str = new char[column_names[n].length()*2+1];
-
-    PQescapeString(esc_str, (const char *)column_names[n].lower(), column_names[n].length());
-    QgsDebugMsg("Escaped " + column_names[n] + " to " + QString(esc_str)); 
-    query += esc_str;
-    query += " " + column_types[n];
-
-    if(n<column_names.size()-1)
-    {
-      query += ", ";
-    }
-    delete[] esc_str;
+  for(uint n=0; n<column_names.size() && result; n++)
+  {
+    query += QString(",%1 %2")
+               .arg( QgsPgUtil::quotedIdentifier(column_names[n]) )
+               .arg( column_types[n] );
   }
   query += " )";
 
   QgsDebugMsg("Query string is: " + query);
 
-  PGresult *res = PQexec(conn, (const char *)query);
+  PGresult *res = PQexec(conn, query.toUtf8() );
 
   if(PQresultStatus(res)!=PGRES_COMMAND_OK){
     // flag error and send query and error message to stdout on debug
@@ -312,10 +303,14 @@
     PQclear(res);
   }
 
-  query = "SELECT AddGeometryColumn(\'" + schema + "\', \'" + table_name + "\', \'"+
-    geom_col + "\', " + srid + ", \'" + geom_type + "\', 2)";
+  query = QString("SELECT AddGeometryColumn(%1,%2,%3,%4,%5,2)")
+            .arg( QgsPgUtil::quotedValue( schema ) )
+            .arg( QgsPgUtil::quotedValue( table_name ) )
+            .arg( QgsPgUtil::quotedValue( geom_col ) )
+            .arg( srid )
+            .arg( QgsPgUtil::quotedValue( geom_type ) );
 
-  res = PQexec(conn, (const char *)query);
+  res = PQexec(conn, query.toUtf8() );
 
   if(PQresultStatus(res)!=PGRES_TUPLES_OK){
     errorText += tr("The database gave an error while executing this SQL:") + "\n";
@@ -332,15 +327,16 @@
 
   if(isMulti)
   {
-    query = QString("select constraint_name from information_schema.table_constraints where table_schema='%1' and table_name='%2' and constraint_name in ('$2','enforce_geotype_the_geom')")
-            .arg( schema ).arg( table_name );
+    query = QString("select constraint_name from information_schema.table_constraints where table_schema=%1 and table_name=%2 and constraint_name in ('$2','enforce_geotype_the_geom')")
+              .arg( QgsPgUtil::quotedValue(schema) )
+              .arg( QgsPgUtil::quotedValue(table_name) );
 
     QStringList constraints;
-    res = PQexec( conn, query );
+    res = PQexec(conn, query.toUtf8() );
     if( PQresultStatus( res ) == PGRES_TUPLES_OK )
     {
       for(int i=0; i<PQntuples(res); i++)
-	constraints.append( PQgetvalue(res, i, 0) );
+        constraints.append( PQgetvalue(res, i, 0) );
     }
     PQclear(res);
 
@@ -350,9 +346,11 @@
       // convert the geometries to the same type or allow
       // multiple types in the check constraint. For now, we
       // just drop the constraint...
-      query = "alter table " + table_name + " drop constraint \"" + constraints[0] + "\"";
+      query = QString("alter table %1 drop constraint %2")
+                .arg( QgsPgUtil::quotedIdentifier(table_name) )
+                .arg( QgsPgUtil::quotedIdentifier(constraints[0]) );
 
-      res = PQexec(conn, (const char*)query);
+      res = PQexec(conn, query.toUtf8() );
       if(PQresultStatus(res)!=PGRES_COMMAND_OK) {
         errorText += tr("The database gave an error while executing this SQL:") + "\n";
         errorText += query + '\n';
@@ -368,8 +366,10 @@
   }
       
   //adding the data into the table
-  for(int m=0;m<features && result; m++){
-    if(import_canceled){
+  for(int m=0; m<features && result; m++)
+  {
+    if(import_canceled)
+    {
       fin = true;
       break;
     }
@@ -378,8 +378,10 @@
     if(feat){
       OGRGeometryH geom = OGR_F_GetGeometryRef(feat);
       if(geom){
-        query = "INSERT INTO \"" + schema + "\".\"" + table_name + "\"" +
-          QString(" VALUES( %1, ").arg(m);
+        query = QString("INSERT INTO %1.%2 VALUES(%3")
+                  .arg( QgsPgUtil::quotedIdentifier(schema) )
+                  .arg( QgsPgUtil::quotedIdentifier(table_name) )
+                  .arg( m );
 
         int num = OGR_G_WkbSize(geom);
         char * geo_temp = new char[num*3];
@@ -390,38 +392,28 @@
         OGR_G_ExportToWkt(geom,&geo_temp);
         QString geometry(geo_temp);
 
-        QString quotes;
-        for(uint n=0; n<column_types.size(); n++){
-          bool numericType(false);
-          if(column_types[n] == "int" || column_types[n] == "float")
-          {
-            quotes = " ";
-            numericType = true;
-          }
+        for(uint n=0; n<column_types.size(); n++) {
+          QString val;
+          
+          // FIXME: OGR_F_GetFieldAsString returns junk when called with a 8.255 float field
+          if( column_types[n] == "float" ) 
+            val = QString::number( OGR_F_GetFieldAsDouble(feat,n) );
           else
-            quotes = "\'";
-          query += quotes;
+            val = codec->toUnicode(OGR_F_GetFieldAsString(feat,n) );
 
-          // escape the string value and cope with blank data
-          QString val = codec->toUnicode(OGR_F_GetFieldAsString(feat,n));
-          if (val.isEmpty() && numericType)
-          {
+          if( val.isEmpty() )
             val = "NULL";
-          }
-          val.replace("'", "''");
-          //char * esc_str = new char[val.length()*2+1];
-          //PQescapeString(esc_str, (const char *)val.lower().utf8(), val.length());
+          else
+            val = QgsPgUtil::quotedValue( val );
 
-          // add escaped value to the query 
-          query += val; //esc_str;
-          query += QString(quotes + ", ");
-
-          //delete[] esc_str;
+          query += "," + val;
         }
-        query += QString("GeometryFromText(\'")+geometry+QString("\', ")+srid+QString("))");
+        query += QString(",GeometryFromText(%1,%2))")
+                   .arg( QgsPgUtil::quotedValue( geometry ) )
+                   .arg( srid );
 
         if(result)
-          res = PQexec(conn, (const char *)query.utf8());
+          res = PQexec(conn, query.utf8() );
 
         if(PQresultStatus(res)!=PGRES_COMMAND_OK){
           // flag error and send query and error message to stdout on debug

Modified: trunk/qgis/src/plugins/spit/qgsshapefile.h
===================================================================
--- trunk/qgis/src/plugins/spit/qgsshapefile.h	2008-03-28 11:02:05 UTC (rev 8292)
+++ trunk/qgis/src/plugins/spit/qgsshapefile.h	2008-03-28 17:36:20 UTC (rev 8293)
@@ -45,7 +45,7 @@
   ~QgsShapeFile();
   int getFeatureCount();
   QString getFeatureClass();
-  bool insertLayer(QString dbname, QString schema, QString geom_col, 
+  bool insertLayer(QString dbname, QString schema, QString primary_key, QString geom_col, 
                    QString srid, PGconn * conn, QProgressDialog& pro, 
                    bool &fin, QString& errorText);
     

Modified: trunk/qgis/src/plugins/spit/qgsspit.cpp
===================================================================
--- trunk/qgis/src/plugins/spit/qgsspit.cpp	2008-03-28 11:02:05 UTC (rev 8292)
+++ trunk/qgis/src/plugins/spit/qgsspit.cpp	2008-03-28 17:36:20 UTC (rev 8293)
@@ -37,7 +37,6 @@
 #include "qgsspit.h"
 #include "qgsconnectiondialog.h"
 #include "qgsdatasourceuri.h"
-#include "qgseditreservedwordsdialog.h"
 #include "qgsmessageviewer.h"
 #include "spiticon.xpm"
 #include "qgslogger.h"
@@ -68,7 +67,7 @@
   tblShapefiles->setColumnCount(5);
   QStringList headerText;
   headerText << tr("File Name") << tr("Feature Class") << tr("Features") 
-	     << tr("DB Relation Name") << tr("Schema");
+    << tr("DB Relation Name") << tr("Schema");
   tblShapefiles->setHorizontalHeaderLabels(headerText);
   tblShapefiles->verticalHeader()->hide();
   tblShapefiles->horizontalHeader()->setStretchLastSection(true);
@@ -83,6 +82,8 @@
   useDefaultSrid();
   useDefaultGeom();
 
+  txtPrimaryKeyName->setText("gid");
+
   schema_list << "public";
   gl_key = "/PostgreSQL/connections/";
   getSchema();
@@ -100,7 +101,8 @@
 }
 
 QgsSpit::~QgsSpit()
-{}
+{
+}
 
 void QgsSpit::populateConnectionList()
 {
@@ -167,12 +169,12 @@
   QSettings settings;
 
   QgsEncodingFileDialog dlg(this,
-                        tr("Add Shapefiles"),
-                        settings.readEntry( "/Plugin-Spit/last_directory" ),
-                        tr("Shapefiles (*.shp);;All files (*.*)"),
-                        settings.readEntry( "/Plugin-Spit/last_encoding" ) );
+    tr("Add Shapefiles"),
+    settings.readEntry( "/Plugin-Spit/last_directory" ),
+    tr("Shapefiles (*.shp);;All files (*.*)"),
+    settings.readEntry( "/Plugin-Spit/last_encoding" ) );
   dlg.setMode(QFileDialog::ExistingFiles);
-  
+
   if (dlg.exec() != QDialog::Accepted)
     return;
   QStringList files = dlg.selectedFiles();
@@ -192,7 +194,7 @@
 
     // Check to ensure that we don't insert the same file twice
     QList<QTableWidgetItem*> items = tblShapefiles->findItems(*it, 
-							Qt::MatchExactly);
+                                                              Qt::MatchExactly);
     if (items.count() > 0)
     {
       exist = true;
@@ -223,69 +225,27 @@
           QString featureClass = file->getFeatureClass();
           fileList.push_back( file );
 
-	  QTableWidgetItem *filenameItem       = new QTableWidgetItem( name );
-	  QTableWidgetItem *featureClassItem   = new QTableWidgetItem( featureClass );
-	  QTableWidgetItem *featureCountItem   = new QTableWidgetItem( QString( "%1" ).arg( file->getFeatureCount() ) );
+          QTableWidgetItem *filenameItem       = new QTableWidgetItem( name );
+          QTableWidgetItem *featureClassItem   = new QTableWidgetItem( featureClass );
+          QTableWidgetItem *featureCountItem   = new QTableWidgetItem( QString( "%1" ).arg( file->getFeatureCount() ) );
           // Sanitize the relation name to make it pg friendly
           QString relName = file->getTable().replace(QRegExp("\\s"), "_");
-	  QTableWidgetItem *dbRelationNameItem = new QTableWidgetItem( relName );
-	  QTableWidgetItem *dbSchemaNameItem   = new QTableWidgetItem( cmbSchema->currentText() );
+          QTableWidgetItem *dbRelationNameItem = new QTableWidgetItem( relName );
+          QTableWidgetItem *dbSchemaNameItem   = new QTableWidgetItem( cmbSchema->currentText() );
 
-	  // All items are editable except for these two
-	  filenameItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
-	  featureCountItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+          // All items are editable except for these two
+          filenameItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+          featureCountItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
 
           int row = tblShapefiles->rowCount();
           tblShapefiles->insertRow( row );
-	  tblShapefiles->setItem( row, ColFILENAME, filenameItem );
-	  tblShapefiles->setItem( row, ColFEATURECLASS, featureClassItem );
-	  tblShapefiles->setItem( row, ColFEATURECOUNT, featureCountItem );
-	  tblShapefiles->setItem( row, ColDBRELATIONNAME, dbRelationNameItem );
+          tblShapefiles->setItem( row, ColFILENAME, filenameItem );
+          tblShapefiles->setItem( row, ColFEATURECLASS, featureClassItem );
+          tblShapefiles->setItem( row, ColFEATURECOUNT, featureCountItem );
+          tblShapefiles->setItem( row, ColDBRELATIONNAME, dbRelationNameItem );
           tblShapefiles->setItem( row, ColDBSCHEMA, dbSchemaNameItem );
 
           total_features += file->getFeatureCount();
-
-          // check for postgresql reserved words
-          // First get an instance of the PG utility class
-          QgsPgUtil *pgu = QgsPgUtil::instance();
-          bool hasReservedWords = false;
-          // if a reserved word is found, set the flag so the "adjustment"
-          // dialog can be presented to the user
-	  hasReservedWords = false;
-          for ( std::vector<QString>::size_type i = 0; i < file->column_names.size(); i++ )
-          {
-            if ( pgu->isReserved( file->column_names[ i ] ) )
-            {
-              hasReservedWords = true;
-            }
-          }
-          // Why loop through all of them and then turn around and test
-          // the flag? Because if there are reserved words, we want to
-          // add all columns to the listview so the user can have the
-          // opportunity to change them.
-          if ( hasReservedWords )
-          {
-            // show the dialog for adjusting reserved words. Reserved
-            // words are displayed differently so they are easy to spot
-            QgsEditReservedWordsDialog * srw = new QgsEditReservedWordsDialog( this );
-            srw->setCaption( file->getTable().upper() + tr(" - Edit Column Names") );
-            // load the reserved words list
-            srw->setReservedWords( pgu->reservedWords() );
-            // load the columns and set their status
-            for ( std::vector<QString>::size_type i = 0; i < file->column_names.size(); i++ )
-            {
-              srw->addColumn( file->column_names[ i ],
-                              pgu->isReserved( file->column_names[ i ] ), i );
-            }
-            if ( srw->exec() )
-            {
-              // get the new column specs from the listview control
-              // and replace the existing column spec for the shapefile
-              file->setColumnNames( srw->columnNames() );
-            }
-          }
-
-
         }
         else
         {
@@ -340,12 +300,12 @@
       }
     }
 
-  for ( int i = temp.size()-1; i >= 0; --i )
-    tblShapefiles->removeRow( temp[ i ] );
+    for ( int i = temp.size()-1; i >= 0; --i )
+      tblShapefiles->removeRow( temp[ i ] );
 
-  QList<QTableWidgetItem*> selected = tblShapefiles->selectedItems();
-  for (int i = 0; i < selected.count(); ++i)
-    selected[i]->setSelected(false);
+    QList<QTableWidgetItem*> selected = tblShapefiles->selectedItems();
+    for (int i = 0; i < selected.count(); ++i)
+      selected[i]->setSelected(false);
 }
 
 void QgsSpit::removeAllFiles()
@@ -393,27 +353,27 @@
 {
   QString message = tr("General Interface Help:") + "\n\n";
   message += QString(
-               tr("PostgreSQL Connections:") + "\n" ) + QString(
-               "----------------------------------------------------------------------------------------\n" ) + QString(
-               tr("[New ...] - create a new connection") + "\n" ) + QString(
-               tr("[Edit ...] - edit the currently selected connection") + "\n" ) + QString(
-               tr("[Remove] - remove the currently selected connection") + "\n" ) + QString(
-               tr("-you need to select a connection that works (connects properly) in order to import files") + "\n" ) + QString(
-               tr("-when changing connections Global Schema also changes accordingly") + "\n\n" ) + QString(
-               tr("Shapefile List:") + "\n" ) + QString(
-               "----------------------------------------------------------------------------------------\n" ) + QString(
-               tr("[Add ...] - open a File dialog and browse to the desired file(s) to import") + "\n" ) + QString(
-               tr("[Remove] - remove the currently selected file(s) from the list") + "\n" ) + QString(
-               tr("[Remove All] - remove all the files in the list") + "\n" ) + QString(
-               tr("[SRID] - Reference ID for the shapefiles to be imported") + "\n" ) + QString(
-               tr("[Use Default (SRID)] - set SRID to -1") + "\n" ) + QString(
-               tr("[Geometry Column Name] - name of the geometry column in the database") + "\n" ) + QString(
-               tr("[Use Default (Geometry Column Name)] - set column name to \'the_geom\'") + "\n" ) + QString(
-               tr("[Glogal Schema] - set the schema for all files to be imported into") + "\n\n" ) + QString(
-               "----------------------------------------------------------------------------------------\n" ) + QString(
-               tr("[Import] - import the current shapefiles in the list") + "\n" ) + QString(
-               tr("[Quit] - quit the program\n") ) + QString(
-               tr("[Help] - display this help dialog") + "\n\n" );
+    tr("PostgreSQL Connections:") + "\n" ) + QString(
+    "----------------------------------------------------------------------------------------\n" ) + QString(
+    tr("[New ...] - create a new connection") + "\n" ) + QString(
+    tr("[Edit ...] - edit the currently selected connection") + "\n" ) + QString(
+    tr("[Remove] - remove the currently selected connection") + "\n" ) + QString(
+    tr("-you need to select a connection that works (connects properly) in order to import files") + "\n" ) + QString(
+    tr("-when changing connections Global Schema also changes accordingly") + "\n\n" ) + QString(
+    tr("Shapefile List:") + "\n" ) + QString(
+    "----------------------------------------------------------------------------------------\n" ) + QString(
+    tr("[Add ...] - open a File dialog and browse to the desired file(s) to import") + "\n" ) + QString(
+    tr("[Remove] - remove the currently selected file(s) from the list") + "\n" ) + QString(
+    tr("[Remove All] - remove all the files in the list") + "\n" ) + QString(
+    tr("[SRID] - Reference ID for the shapefiles to be imported") + "\n" ) + QString(
+    tr("[Use Default (SRID)] - set SRID to -1") + "\n" ) + QString(
+    tr("[Geometry Column Name] - name of the geometry column in the database") + "\n" ) + QString(
+    tr("[Use Default (Geometry Column Name)] - set column name to \'the_geom\'") + "\n" ) + QString(
+    tr("[Glogal Schema] - set the schema for all files to be imported into") + "\n\n" ) + QString(
+    "----------------------------------------------------------------------------------------\n" ) + QString(
+    tr("[Import] - import the current shapefiles in the list") + "\n" ) + QString(
+    tr("[Quit] - quit the program\n") ) + QString(
+    tr("[Help] - display this help dialog") + "\n\n" );
   QgsMessageViewer * e = new QgsMessageViewer( this );
   e->setMessageAsPlainText( message );
   e->exec(); // deletes itself on close
@@ -434,10 +394,10 @@
   {
     QgsDataSourceURI uri;
     uri.setConnection( settings.readEntry( gl_key + connName + "/host" ),
-                       settings.readEntry( gl_key + connName + "/port" ),
-                       settings.readEntry( gl_key + connName + "/database" ),
-                       settings.readEntry( gl_key + connName + "/username" ),
-                       settings.readEntry( gl_key + connName + "/password" ) );
+      settings.readEntry( gl_key + connName + "/port" ),
+      settings.readEntry( gl_key + connName + "/database" ),
+      settings.readEntry( gl_key + connName + "/username" ),
+      settings.readEntry( gl_key + connName + "/password" ) );
 
     pd = PQconnectdb( ( const char * ) uri.connInfo() );
 
@@ -446,17 +406,20 @@
       QMessageBox::warning( this, tr("Import Shapefiles"), tr("Connection failed - Check settings and try again") );
       result = false;
     }
-  
-#ifdef QGISDEBUG
-    int errcode = PQsetClientEncoding(pd, "UNICODE");
-    if(errcode==0)
-      qWarning("encoding successfully set");
-    else if(errcode==-1)
-      qWarning("error in setting encoding");
-    else
-      qWarning("undefined return value from encoding setting");
-#endif
-  
+
+    int errcode=PQsetClientEncoding(pd, QString("UNICODE").toLocal8Bit());
+    if(errcode==0) 
+    {
+      QgsDebugMsg("encoding successfully set");
+    } 
+    else if(errcode==-1) 
+    {
+      QgsDebugMsg("error in setting encoding");
+    } 
+    else 
+    {
+      QgsDebugMsg("undefined return value from encoding setting");
+    }
   }
 
   if (result )
@@ -465,18 +428,18 @@
     QString sql1 = "SELECT postgis_lib_version()"; // available from v 0.9.0 onwards
     QString sql2 = "SELECT postgis_version()"; // depreciated 
 
-    PGresult* ver = PQexec(pd, sql1.toLocal8Bit().data());
+    PGresult* ver = PQexec(pd, sql1.toUtf8() );
     if ( PQresultStatus(ver) != PGRES_TUPLES_OK)
     {
       // In case the version of postgis is older than 0.9.0, try the
       // depreciated call before erroring out.
       PQclear(ver);
-      ver = PQexec(pd, sql2.toLocal8Bit().data());
+      ver = PQexec(pd, sql2.toUtf8() );
       if ( PQresultStatus(ver) != PGRES_TUPLES_OK)
       {
         QMessageBox::warning( this, tr("PostGIS not available"),
-                              tr("<p>The chosen database does not have PostGIS installed, "
-                                 "but this is required for storage of spatial data.</p>"));
+          tr("<p>The chosen database does not have PostGIS installed, "
+          "but this is required for storage of spatial data.</p>"));
         return NULL;
       }
     }
@@ -496,8 +459,9 @@
   {
     QString connName = cmbConnections->currentText();
     QString user = settings.readEntry( gl_key + connName + "/username" );
-    QString schemaSql = QString( "select nspname from pg_namespace,pg_user where nspowner = usesysid and usename = '%1'" ).arg( user );
-    PGresult *schemas = PQexec( pd, ( const char * ) schemaSql );
+    QString schemaSql = QString( "select nspname from pg_namespace,pg_user where nspowner=usesysid and usename=%1" )
+                          .arg( QgsPgUtil::quotedValue(user) );
+    PGresult *schemas = PQexec( pd, schemaSql.toUtf8() );
     // get the schema names
     if ( PQresultStatus( schemas ) == PGRES_TUPLES_OK )
     {
@@ -547,13 +511,13 @@
   if ( total_features == 0 )
   {
     QMessageBox::warning( this, tr("Import Shapefiles"), 
-                         tr("You need to add shapefiles to the list first") );
+      tr("You need to add shapefiles to the list first") );
   }
   else if ( pd != NULL )
   {
     PGresult * res;
     QProgressDialog pro( tr("Importing files"), tr("Cancel"), 
-			 0, total_features, this);
+      0, total_features, this);
 
     pro.setValue( 0 );
     pro.setLabelText(tr("Progress"));
@@ -561,18 +525,20 @@
     //pro->show();
     qApp->processEvents();
 
+    int count=fileList.size(), successes=0;
+
     for ( std::vector<QgsShapeFile*>::size_type i = 0; i < fileList.size() ; i++ )
     {
       QString error = tr("Problem inserting features from file:") + "\n" + 
-                      tblShapefiles->item( i, ColFILENAME )->text();
-                      
+        tblShapefiles->item( i, ColFILENAME )->text();
+
       // if a name starts with invalid character
       if ( ! tblShapefiles->item( i, ColDBRELATIONNAME )->text()[ 0 ].isLetter() )
       {
         QMessageBox::warning( &pro, tr("Import Shapefiles"), 
-                             error + "\n" + tr("Invalid table name.") );
+          error + "\n" + tr("Invalid table name.") );
         pro.setValue( pro.value() 
-                      + tblShapefiles->item( i, ColFEATURECOUNT )->text().toInt() );
+          + tblShapefiles->item( i, ColFEATURECOUNT )->text().toInt() );
         continue;
       }
 
@@ -580,14 +546,17 @@
       if ( ( fileList[ i ] ->column_names ).size() == 0 )
       {
         QMessageBox::warning( &pro, tr("Import Shapefiles"), 
-                            error + "\n" + tr("No fields detected.") );
+          error + "\n" + tr("No fields detected.") );
         pro.setValue( pro.value() + 
-                      tblShapefiles->item( i, ColFEATURECOUNT )->text().toInt() );
+          tblShapefiles->item( i, ColFEATURECOUNT )->text().toInt() );
         continue;
       }
 
       // duplicate field check
       std::vector<QString> names_copy = fileList[ i ] ->column_names;
+      names_copy.push_back( txtPrimaryKeyName->text() );
+      names_copy.push_back( txtGeomName->text() );
+
       QString dupl = "";
       std::sort( names_copy.begin(), names_copy.end() );
 
@@ -597,11 +566,12 @@
         if ( names_copy[ k ] == names_copy[ k - 1 ] )
           dupl += names_copy[ k ] + "\n";
       }
+
       // if duplicate field names exist
       if ( dupl != "" )
       {
         QMessageBox::warning( &pro, tr("Import Shapefiles"), error +
-                              "\n" + tr("The following fields are duplicates:") + "\n" + dupl );
+          "\n" + tr("The following fields are duplicates:") + "\n" + dupl );
         pro.setValue( pro.value() + tblShapefiles->item( i, ColFEATURECOUNT )->text().toInt() );
         continue;
       }
@@ -609,23 +579,22 @@
       // Check and set destination table 
       fileList[ i ] ->setTable( tblShapefiles->item( i, ColDBRELATIONNAME )->text() );
       pro.setLabelText( tr("Importing files") + "\n" 
-                      + tblShapefiles->item(i, ColFILENAME)->text() );
+        + tblShapefiles->item(i, ColFILENAME)->text() );
       bool rel_exists1 = false;
       bool rel_exists2 = false;
-      query = "SELECT f_table_name FROM geometry_columns WHERE f_table_name=\'" 
-              + tblShapefiles->item( i, ColDBRELATIONNAME )->text() +
-              "\' AND f_table_schema=\'" 
-              + tblShapefiles->item( i, ColDBSCHEMA )->text() + "\'";
-      res = PQexec( pd, ( const char * ) query );
+      query = QString("SELECT f_table_name FROM geometry_columns WHERE f_table_name=%1 AND f_table_schema=%2")
+                .arg( QgsPgUtil::quotedValue( tblShapefiles->item( i, ColDBRELATIONNAME )->text()) )
+                .arg( QgsPgUtil::quotedValue( tblShapefiles->item( i, ColDBSCHEMA )->text()) );
+      res = PQexec( pd, query.toUtf8() );
       rel_exists1 = ( PQntuples( res ) > 0 );
 
       if ( PQresultStatus( res ) != PGRES_TUPLES_OK )
       {
         QString err = PQresultErrorMessage( res );
         QMessageBox::warning( &pro, tr("Import Shapefiles"), error + "\n" +
-                              tr("<p>Error while executing the SQL:</p><p>") +
-                              query + tr("</p><p>The database said:") +
-                              err + "</p>" );
+          tr("<p>Error while executing the SQL:</p><p>") +
+          query + tr("</p><p>The database said:") +
+          err + "</p>" );
         pro.setValue( pro.value() + tblShapefiles->item( i, ColFEATURECOUNT )->text().toInt() );
         PQclear(res);
         continue;
@@ -633,9 +602,10 @@
 
       PQclear( res );
 
-      query = "SELECT tablename FROM pg_tables WHERE tablename=\'" + tblShapefiles->item( i, ColDBRELATIONNAME )->text() + "\' AND schemaname=\'" +
-              tblShapefiles->item( i, ColDBSCHEMA )->text() + "\'";
-      res = PQexec( pd, ( const char * ) query );
+      query = QString("SELECT tablename FROM pg_tables WHERE tablename=%1  AND schemaname=%2")
+                .arg( QgsPgUtil::quotedValue( tblShapefiles->item( i, ColDBRELATIONNAME )->text() ) )
+                .arg( QgsPgUtil::quotedValue( tblShapefiles->item( i, ColDBSCHEMA )->text() ) );
+      res = PQexec( pd, query.toUtf8() );
 
       rel_exists2 = ( PQntuples( res ) > 0 );
 
@@ -643,9 +613,9 @@
       {
         QString err = PQresultErrorMessage( res );
         QMessageBox::warning( &pro, tr("Import Shapefiles"), error + "\n" +
-                              tr("<p>Error while executing the SQL:</p><p>") +
-                              query + tr("</p><p>The database said:") +
-                              err + "</p>" );
+          tr("<p>Error while executing the SQL:</p><p>") +
+          query + tr("</p><p>The database said:") +
+          err + "</p>" );
 
         pro.setValue( pro.value() + tblShapefiles->item( i, ColFEATURECOUNT )->text().toInt() );
         PQclear(res);
@@ -658,14 +628,14 @@
 
       // begin session
       query = "BEGIN";
-      res = PQexec( pd, query );
+      res = PQexec( pd, query.toUtf8() );
       if ( PQresultStatus( res ) != PGRES_COMMAND_OK )
       {
         QString err = PQresultErrorMessage( res );
         QMessageBox::warning( &pro, tr("Import Shapefiles"), error + "\n" +
-                              tr("<p>Error while executing the SQL:</p><p>") +
-                              query + tr("</p><p>The database said:") +
-                              err + "</p>" );
+          tr("<p>Error while executing the SQL:</p><p>") +
+          query + tr("</p><p>The database said:") +
+          err + "</p>" );
         pro.setValue( pro.value() + tblShapefiles->item( i, ColFEATURECOUNT )->text().toInt() );
         PQclear(res);
         continue;
@@ -675,20 +645,19 @@
         PQclear( res );
       }
 
-      query = "SET SEARCH_PATH TO \'";
-      if ( tblShapefiles->item( i, ColDBSCHEMA )->text() == "public" )
-        query += "public\'";
-      else
-        query += tblShapefiles->item( i, ColDBSCHEMA )->text() + "\', \'public\'";
-      res = PQexec( pd, query );
+      query = "SET SEARCH_PATH TO ";
+      if ( tblShapefiles->item( i, ColDBSCHEMA )->text() != "public" )
+        query += QgsPgUtil::quotedValue( tblShapefiles->item( i, ColDBSCHEMA )->text() ) + ",";
+      query += QgsPgUtil::quotedValue( "public" );
+      res = PQexec( pd, query.toUtf8() );
 
       if ( PQresultStatus( res ) != PGRES_COMMAND_OK )
       {
         QString err = PQresultErrorMessage( res );
         QMessageBox::warning( &pro, tr("Import Shapefiles"), error + "\n" +
-                              tr("<p>Error while executing the SQL:</p><p>") +
-                              query + tr("</p><p>The database said:") +
-                              err + "</p>" );
+          tr("<p>Error while executing the SQL:</p><p>") +
+          query + tr("</p><p>The database said:") +
+          err + "</p>" );
         pro.setValue( pro.value() + tblShapefiles->item( i, ColFEATURECOUNT )->text().toInt() );
         PQclear(res);
         continue;
@@ -701,27 +670,28 @@
       if ( rel_exists1 || rel_exists2 )
       {
         QMessageBox::StandardButton del_confirm = QMessageBox::warning( this,
-                                       tr("Import Shapefiles - Relation Exists"),
-                                       tr("The Shapefile:" ) + "\n" + tblShapefiles->item( i, 0 )->text() + "\n" + tr("will use [") +
-                                       tblShapefiles->item( i, ColDBRELATIONNAME )->text() + tr("] relation for its data,") + "\n" + tr("which already exists and possibly contains data.") + "\n" +
-                                       tr("To avoid data loss change the \"DB Relation Name\"") + "\n" + tr("for this Shapefile in the main dialog file list.") + "\n\n" +
-                                       tr("Do you want to overwrite the [") + tblShapefiles->item( i, ColDBRELATIONNAME )->text() + tr("] relation?"),
-                                       QMessageBox::Ok | QMessageBox::Cancel );
+          tr("Import Shapefiles - Relation Exists"),
+          tr("The Shapefile:" ) + "\n" + tblShapefiles->item( i, 0 )->text() + "\n" + tr("will use [") +
+          tblShapefiles->item( i, ColDBRELATIONNAME )->text() + tr("] relation for its data,") + "\n" + tr("which already exists and possibly contains data.") + "\n" +
+          tr("To avoid data loss change the \"DB Relation Name\"") + "\n" + tr("for this Shapefile in the main dialog file list.") + "\n\n" +
+          tr("Do you want to overwrite the [") + tblShapefiles->item( i, ColDBRELATIONNAME )->text() + tr("] relation?"),
+          QMessageBox::Ok | QMessageBox::Cancel );
 
         if ( del_confirm == QMessageBox::Ok )
         {
           if ( rel_exists2 )
           {
-            query = "DROP TABLE " + tblShapefiles->item( i, ColDBRELATIONNAME )->text();
+            query = QString("DROP TABLE %1")
+                      .arg( QgsPgUtil::quotedIdentifier( tblShapefiles->item( i, ColDBRELATIONNAME )->text() ) );
 
-            res = PQexec( pd, ( const char * ) query );
+            res = PQexec( pd, query.toUtf8() );
             if ( PQresultStatus( res ) != PGRES_COMMAND_OK )
             {
               QString err = PQresultErrorMessage( res );
               QMessageBox::warning( &pro, tr("Import Shapefiles"), error + "\n" +
-                                    tr("<p>Error while executing the SQL:</p><p>") +
-                                    query + tr("</p><p>The database said:") +
-                                    err + "</p>" );
+                tr("<p>Error while executing the SQL:</p><p>") +
+                query + tr("</p><p>The database said:") +
+                err + "</p>" );
               pro.setValue( pro.value() + tblShapefiles->item( i, ColFEATURECOUNT )->text().toInt() );
               PQclear(res);
               continue;
@@ -734,56 +704,56 @@
 
           if ( rel_exists1 )
           {
-	    query = QString("SELECT f_geometry_column FROM geometry_columns WHERE f_table_schema='%1' AND f_table_name='%2'")
-		    .arg( tblShapefiles->item( i, ColDBSCHEMA )->text() )
-		    .arg( tblShapefiles->item( i, ColDBRELATIONNAME )->text() );
+            query = QString("SELECT f_geometry_column FROM geometry_columns WHERE f_table_schema=%1 AND f_table_name=%2")
+              .arg( QgsPgUtil::quotedValue( tblShapefiles->item( i, ColDBSCHEMA )->text()) )
+              .arg( QgsPgUtil::quotedValue( tblShapefiles->item( i, ColDBRELATIONNAME )->text()) );
 
-	    QStringList columns;
-	    res = PQexec( pd, query );
-	    if( PQresultStatus( res ) != PGRES_TUPLES_OK )
-	    {
-	      for(int i=0; i<PQntuples(res); i++)
-		columns.append( PQgetvalue(res, i, 0) );
-	    }
+            QStringList columns;
+            res = PQexec( pd, query.toUtf8() );
+            if( PQresultStatus( res ) != PGRES_TUPLES_OK )
+            {
+              for(int i=0; i<PQntuples(res); i++)
+                columns.append( PQgetvalue(res, i, 0) );
+            }
             PQclear(res);
 
-	    for(int i=0; i<columns.size(); i++)
-	    {
-	      query = QString("SELECT DropGeometryColumn('%1','%2','%3')")
-	              .arg( tblShapefiles->item( i, ColDBSCHEMA )->text() )
-	              .arg( tblShapefiles->item( i, ColDBRELATIONNAME )->text() )
-                      .arg( columns[i] );
+            for(int i=0; i<columns.size(); i++)
+            {
+              query = QString("SELECT DropGeometryColumn(%1,%2,%3)")
+                .arg( QgsPgUtil::quotedValue( tblShapefiles->item( i, ColDBSCHEMA )->text() ) )
+                .arg( QgsPgUtil::quotedValue( tblShapefiles->item( i, ColDBRELATIONNAME )->text() ) )
+                .arg( QgsPgUtil::quotedValue( columns[i] ) );
 
-              res = PQexec( pd, ( const char * ) query );
+              res = PQexec( pd, query.toUtf8() );
               if ( PQresultStatus( res ) != PGRES_COMMAND_OK )
               {
                 QString err = PQresultErrorMessage( res );
-		QMessageBox::warning( &pro, tr("Import Shapefiles"), error + "\n" +
-			              tr("<p>Error while executing the SQL:</p><p>") +
-				      query + tr("</p><p>The database said:") + 
-				      err + "</p>" );
-		pro.setValue( pro.value() + tblShapefiles->item( i, ColFEATURECOUNT )->text().toInt() );
-	      }
-	      
-	      PQclear(res);
+                QMessageBox::warning( &pro, tr("Import Shapefiles"), error + "\n" +
+                  tr("<p>Error while executing the SQL:</p><p>") +
+                  query + tr("</p><p>The database said:") + 
+                  err + "</p>" );
+                pro.setValue( pro.value() + tblShapefiles->item( i, ColFEATURECOUNT )->text().toInt() );
+              }
+
+              PQclear(res);
             }
-	  }
+          }
         }
         else
         {
           query = "ROLLBACK";
-          res = PQexec( pd, query );
+          res = PQexec( pd, query.toUtf8() );
           if ( PQresultStatus( res ) != PGRES_COMMAND_OK )
           {
             QString err = PQresultErrorMessage( res );
             QMessageBox::warning( &pro, tr("Import Shapefiles"), error + "\n" +
-                                  tr("<p>Error while executing the SQL:</p><p>") +
-                                  query + tr("</p><p>The database said:") +
-                                  err + "</p>" );
-	  }
+              tr("<p>Error while executing the SQL:</p><p>") +
+              query + tr("</p><p>The database said:") +
+              err + "</p>" );
+          }
           PQclear(res);
-         
-	  pro.setValue( pro.value() + tblShapefiles->item( i, 2 )->text().toInt() );
+
+          pro.setValue( pro.value() + tblShapefiles->item( i, 2 )->text().toInt() );
           continue;
         }
       }
@@ -797,24 +767,23 @@
       QString srid = QString( "%1" ).arg( spinSrid->value() );
       QString errorText;
 
-      bool layerInserted = fileList[ i ] ->insertLayer( dbname, schema, txtGeomName->text(), 
-                                                        srid, pd, pro, canceled, errorText );
+      bool layerInserted = fileList[i]->insertLayer(dbname, schema, txtPrimaryKeyName->text(), txtGeomName->text(), srid, pd, pro, canceled, errorText );
       if ( layerInserted && !canceled )
       { // if file has been imported successfully
         query = "COMMIT";
-        res = PQexec( pd, query );
+        res = PQexec( pd, query.toUtf8() );
         if ( PQresultStatus( res ) != PGRES_COMMAND_OK )
         {
           QString err = PQresultErrorMessage( res );
           QMessageBox::warning( &pro, tr("Import Shapefiles"), error + "\n" +
-                                tr("<p>Error while executing the SQL:</p><p>") +
-                                query + tr("</p><p>The database said:") +
-                                err + "</p>" );
+            tr("<p>Error while executing the SQL:</p><p>") +
+            query + tr("</p><p>The database said:") +
+            err + "</p>" );
           PQclear(res);
           continue;
         }
 
-	PQclear( res );
+        PQclear( res );
 
         // remove file
         for ( int j = 0; j < tblShapefiles->rowCount(); j++ )
@@ -828,6 +797,7 @@
           }
         }
 
+        successes++;
       }
       else if ( !canceled )
       { // if problem importing file occured
@@ -835,17 +805,17 @@
         QString errTxt = error + "\n" + errorText;
         QMessageBox::warning( this, tr("Import Shapefiles"), errTxt );
         query = "ROLLBACK";
-        res = PQexec( pd, query );
+        res = PQexec( pd, query.toUtf8() );
         if ( PQresultStatus( res ) != PGRES_COMMAND_OK )
         {
           QString err = PQresultErrorMessage( res );
           QMessageBox::warning( &pro, tr("Import Shapefiles"), error + "\n" +
-                                tr("<p>Error while executing the SQL:</p><p>") +
-                                query + tr("</p><p>The database said:") +
-                                err + "</p>" );
+            tr("<p>Error while executing the SQL:</p><p>") +
+            query + tr("</p><p>The database said:") +
+            err + "</p>" );
         }
-      
-	PQclear( res );
+
+        PQclear( res );
       }
       else
       { // if import was actually canceled
@@ -853,36 +823,13 @@
       }
     }
     PQfinish( pd );
-    accept();
+
+    if(successes==count)
+      accept();
+    else
+      QMessageBox::information( &pro, tr("Import Shapefiles"), QString( tr("%1 of %2 shapefiles could not be imported.") ).arg(count-successes).arg(count) );
   }
 }
-void QgsSpit::editColumns( int row, int col, int button, const QPoint &mousePos )
-{
-  // get the shapefile - table row maps directly to the fileList array
-  QgsPgUtil * pgu = QgsPgUtil::instance();
-  // show the dialog for adjusting reserved words. Reserved
-  // words are displayed differently so they are easy to spot
-  QgsEditReservedWordsDialog *srw = new QgsEditReservedWordsDialog( this );
-  srw->setCaption( fileList[ row ] ->getTable().upper() + tr(" - Edit Column Names") );
-  // set the description to indicate that we are editing column names, not
-  // necessarily dealing with reserved words (although that is a possibility too)
-  srw->setDescription(tr("Use the table below to edit column names. Make sure that none of the columns are named using a PostgreSQL reserved word"));
-  // load the reserved words list
-  srw->setReservedWords( pgu->reservedWords() );
-  // load the columns and set their status
-  for ( std::vector<QString>::size_type i = 0; i < fileList[ row ] ->column_names.size(); i++ )
-  {
-    srw->addColumn( fileList[ row ] ->column_names[ i ],
-                    pgu->isReserved( fileList[ row ] ->column_names[ i ] ), i );
-  }
-  if ( srw->exec() )
-  {
-    // get the new column specs from the listview control
-    // and replace the existing column spec for the shapefile
-    fileList[ row ] ->setColumnNames( srw->columnNames() );
-  }
-  delete srw;
-}
 
 void QgsSpit::editShapefile(int row, int col, int button, const QPoint& mousePos)
 {
@@ -890,7 +837,7 @@
   /*
   if (ColFEATURECLASS == col || ColDBRELATIONNAME == col)
   {
-    tblShapefiles->editCell(row, col, FALSE);
+  tblShapefiles->editCell(row, col, FALSE);
   }
   */
 }
@@ -978,4 +925,3 @@
 {
   editor->setGeometry(option.rect);
 }
-

Modified: trunk/qgis/src/plugins/spit/qgsspit.h
===================================================================
--- trunk/qgis/src/plugins/spit/qgsspit.h	2008-03-28 11:02:05 UTC (rev 8292)
+++ trunk/qgis/src/plugins/spit/qgsspit.h	2008-03-28 17:36:20 UTC (rev 8293)
@@ -72,8 +72,6 @@
   void updateSchema();
   //! Import shapefiles into PostgreSQL
   void import();
-  //! Edit the column names for a shapefile in the queue
-  void editColumns( int, int, int, const QPoint & );
   //! Edit import properties of a shapefile in the queue
   void editShapefile( int, int, int, const QPoint & );
 

Modified: trunk/qgis/src/plugins/spit/qgsspitbase.ui
===================================================================
--- trunk/qgis/src/plugins/spit/qgsspitbase.ui	2008-03-28 11:02:05 UTC (rev 8292)
+++ trunk/qgis/src/plugins/spit/qgsspitbase.ui	2008-03-28 17:36:20 UTC (rev 8293)
@@ -22,18 +22,28 @@
    <bool>true</bool>
   </property>
   <layout class="QGridLayout" >
-   <property name="margin" >
+   <property name="leftMargin" >
     <number>9</number>
    </property>
-   <property name="spacing" >
+   <property name="topMargin" >
+    <number>9</number>
+   </property>
+   <property name="rightMargin" >
+    <number>9</number>
+   </property>
+   <property name="bottomMargin" >
+    <number>9</number>
+   </property>
+   <property name="horizontalSpacing" >
     <number>6</number>
    </property>
+   <property name="verticalSpacing" >
+    <number>6</number>
+   </property>
    <item row="0" column="2" >
     <widget class="QLabel" name="txtHeading" >
      <property name="sizePolicy" >
-      <sizepolicy>
-       <hsizetype>5</hsizetype>
-       <vsizetype>1</vsizetype>
+      <sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
        <horstretch>0</horstretch>
        <verstretch>0</verstretch>
       </sizepolicy>
@@ -63,30 +73,41 @@
       <string>Shapefile List</string>
      </property>
      <layout class="QGridLayout" >
-      <property name="margin" >
+      <property name="leftMargin" >
        <number>9</number>
       </property>
-      <property name="spacing" >
+      <property name="topMargin" >
+       <number>9</number>
+      </property>
+      <property name="rightMargin" >
+       <number>9</number>
+      </property>
+      <property name="bottomMargin" >
+       <number>9</number>
+      </property>
+      <property name="horizontalSpacing" >
        <number>6</number>
       </property>
-      <item row="5" column="0" >
-       <widget class="QTableWidget" name="tblShapefiles" >
-        <property name="selectionMode" >
-         <enum>QAbstractItemView::MultiSelection</enum>
-        </property>
-        <property name="selectionBehavior" >
-         <enum>QAbstractItemView::SelectRows</enum>
-        </property>
-       </widget>
-      </item>
+      <property name="verticalSpacing" >
+       <number>6</number>
+      </property>
       <item row="0" column="0" >
        <layout class="QHBoxLayout" >
-        <property name="margin" >
-         <number>0</number>
-        </property>
         <property name="spacing" >
          <number>6</number>
         </property>
+        <property name="leftMargin" >
+         <number>0</number>
+        </property>
+        <property name="topMargin" >
+         <number>0</number>
+        </property>
+        <property name="rightMargin" >
+         <number>0</number>
+        </property>
+        <property name="bottomMargin" >
+         <number>0</number>
+        </property>
         <item>
          <widget class="QPushButton" name="btnAddFile" >
           <property name="toolTip" >
@@ -159,28 +180,85 @@
       </item>
       <item row="2" column="0" >
        <layout class="QHBoxLayout" >
-        <property name="margin" >
-         <number>0</number>
-        </property>
         <property name="spacing" >
          <number>6</number>
         </property>
+        <property name="leftMargin" >
+         <number>0</number>
+        </property>
+        <property name="topMargin" >
+         <number>0</number>
+        </property>
+        <property name="rightMargin" >
+         <number>0</number>
+        </property>
+        <property name="bottomMargin" >
+         <number>0</number>
+        </property>
         <item>
+         <layout class="QVBoxLayout" >
+          <item>
+           <widget class="QLabel" name="label" >
+            <property name="text" >
+             <string>Primary Key Column Name</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLineEdit" name="txtPrimaryKeyName" />
+          </item>
+         </layout>
+        </item>
+        <item>
+         <spacer>
+          <property name="orientation" >
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" >
+           <size>
+            <width>40</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+        <item>
          <layout class="QGridLayout" >
-          <property name="margin" >
+          <property name="leftMargin" >
            <number>0</number>
           </property>
-          <property name="spacing" >
+          <property name="topMargin" >
+           <number>0</number>
+          </property>
+          <property name="rightMargin" >
+           <number>0</number>
+          </property>
+          <property name="bottomMargin" >
+           <number>0</number>
+          </property>
+          <property name="horizontalSpacing" >
            <number>6</number>
           </property>
-          <item row="1" column="0" >
+          <property name="verticalSpacing" >
+           <number>6</number>
+          </property>
+          <item row="1" column="1" >
            <layout class="QHBoxLayout" >
-            <property name="margin" >
-             <number>0</number>
-            </property>
             <property name="spacing" >
              <number>6</number>
             </property>
+            <property name="leftMargin" >
+             <number>0</number>
+            </property>
+            <property name="topMargin" >
+             <number>0</number>
+            </property>
+            <property name="rightMargin" >
+             <number>0</number>
+            </property>
+            <property name="bottomMargin" >
+             <number>0</number>
+            </property>
             <item>
              <widget class="QLabel" name="textLabel1_2" >
               <property name="text" >
@@ -190,12 +268,12 @@
             </item>
             <item>
              <widget class="QSpinBox" name="spinSrid" >
+              <property name="minimum" >
+               <number>-1</number>
+              </property>
               <property name="maximum" >
                <number>1000000</number>
               </property>
-              <property name="minimum" >
-               <number>-1</number>
-              </property>
               <property name="value" >
                <number>-1</number>
               </property>
@@ -203,7 +281,7 @@
             </item>
            </layout>
           </item>
-          <item row="0" column="0" >
+          <item row="0" column="1" >
            <widget class="QCheckBox" name="chkUseDefaultSrid" >
             <property name="toolTip" >
              <string>Set the SRID to the default value</string>
@@ -219,29 +297,25 @@
          </layout>
         </item>
         <item>
-         <spacer>
-          <property name="orientation" >
-           <enum>Qt::Horizontal</enum>
+         <layout class="QGridLayout" >
+          <property name="leftMargin" >
+           <number>0</number>
           </property>
-          <property name="sizeType" >
-           <enum>QSizePolicy::Expanding</enum>
+          <property name="topMargin" >
+           <number>0</number>
           </property>
-          <property name="sizeHint" >
-           <size>
-            <width>20</width>
-            <height>21</height>
-           </size>
+          <property name="rightMargin" >
+           <number>0</number>
           </property>
-         </spacer>
-        </item>
-        <item>
-         <layout class="QGridLayout" >
-          <property name="margin" >
+          <property name="bottomMargin" >
            <number>0</number>
           </property>
-          <property name="spacing" >
+          <property name="horizontalSpacing" >
            <number>6</number>
           </property>
+          <property name="verticalSpacing" >
+           <number>6</number>
+          </property>
           <item row="0" column="0" >
            <widget class="QCheckBox" name="chkUseDefaultGeom" >
             <property name="toolTip" >
@@ -257,12 +331,21 @@
           </item>
           <item row="1" column="0" >
            <layout class="QHBoxLayout" >
-            <property name="margin" >
-             <number>0</number>
-            </property>
             <property name="spacing" >
              <number>6</number>
             </property>
+            <property name="leftMargin" >
+             <number>0</number>
+            </property>
+            <property name="topMargin" >
+             <number>0</number>
+            </property>
+            <property name="rightMargin" >
+             <number>0</number>
+            </property>
+            <property name="bottomMargin" >
+             <number>0</number>
+            </property>
             <item>
              <widget class="QLabel" name="textLabel1_3" >
               <property name="text" >
@@ -294,12 +377,21 @@
       </item>
       <item row="4" column="0" >
        <layout class="QHBoxLayout" >
-        <property name="margin" >
-         <number>0</number>
-        </property>
         <property name="spacing" >
          <number>6</number>
         </property>
+        <property name="leftMargin" >
+         <number>0</number>
+        </property>
+        <property name="topMargin" >
+         <number>0</number>
+        </property>
+        <property name="rightMargin" >
+         <number>0</number>
+        </property>
+        <property name="bottomMargin" >
+         <number>0</number>
+        </property>
         <item>
          <spacer>
           <property name="orientation" >
@@ -318,12 +410,21 @@
         </item>
         <item>
          <layout class="QHBoxLayout" >
-          <property name="margin" >
-           <number>0</number>
-          </property>
           <property name="spacing" >
            <number>6</number>
           </property>
+          <property name="leftMargin" >
+           <number>0</number>
+          </property>
+          <property name="topMargin" >
+           <number>0</number>
+          </property>
+          <property name="rightMargin" >
+           <number>0</number>
+          </property>
+          <property name="bottomMargin" >
+           <number>0</number>
+          </property>
           <item>
            <widget class="QLabel" name="textLabel1_4" >
             <property name="text" >
@@ -351,6 +452,16 @@
         </item>
        </layout>
       </item>
+      <item row="5" column="0" >
+       <widget class="QTableWidget" name="tblShapefiles" >
+        <property name="selectionMode" >
+         <enum>QAbstractItemView::MultiSelection</enum>
+        </property>
+        <property name="selectionBehavior" >
+         <enum>QAbstractItemView::SelectRows</enum>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>
@@ -360,20 +471,44 @@
       <string>PostgreSQL Connections</string>
      </property>
      <layout class="QGridLayout" >
-      <property name="margin" >
+      <property name="leftMargin" >
        <number>9</number>
       </property>
-      <property name="spacing" >
+      <property name="topMargin" >
+       <number>9</number>
+      </property>
+      <property name="rightMargin" >
+       <number>9</number>
+      </property>
+      <property name="bottomMargin" >
+       <number>9</number>
+      </property>
+      <property name="horizontalSpacing" >
        <number>6</number>
       </property>
+      <property name="verticalSpacing" >
+       <number>6</number>
+      </property>
       <item row="0" column="0" >
        <layout class="QGridLayout" >
-        <property name="margin" >
+        <property name="leftMargin" >
          <number>0</number>
         </property>
-        <property name="spacing" >
+        <property name="topMargin" >
+         <number>0</number>
+        </property>
+        <property name="rightMargin" >
+         <number>0</number>
+        </property>
+        <property name="bottomMargin" >
+         <number>0</number>
+        </property>
+        <property name="horizontalSpacing" >
          <number>6</number>
         </property>
+        <property name="verticalSpacing" >
+         <number>6</number>
+        </property>
         <item row="1" column="1" >
          <widget class="QPushButton" name="btnNew" >
           <property name="toolTip" >
@@ -400,16 +535,6 @@
           </property>
          </widget>
         </item>
-        <item row="1" column="0" >
-         <widget class="QPushButton" name="btnConnect" >
-          <property name="enabled" >
-           <bool>false</bool>
-          </property>
-          <property name="text" >
-           <string>Connect</string>
-          </property>
-         </widget>
-        </item>
         <item row="1" column="2" >
          <widget class="QPushButton" name="btnEdit" >
           <property name="toolTip" >



More information about the QGIS-commit mailing list