~ubuntu-branches/ubuntu/trusty/qgis/trusty

« back to all changes in this revision

Viewing changes to src/plugins/spit/qgsspit.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *   (at your option) any later version.                                   *
18
18
 *                                                                         *
19
19
 ***************************************************************************/
20
 
/* $Id: qgsspit.h 5934 2006-10-09 06:38:04Z g_j_m $ */
 
20
/* $Id$ */
21
21
#include <vector>
22
22
#include <algorithm>
23
23
 
37
37
 
38
38
class QgsSpit : public QDialog, private Ui::QgsSpitBase
39
39
{
40
 
  Q_OBJECT;
41
 
public:
42
 
  QgsSpit( QWidget *parent = 0, Qt::WFlags fl = 0 );
43
 
  ~QgsSpit();
44
 
  //! Populate the list of available database connections
45
 
  void populateConnectionList();
46
 
  //! Connect to the selected database
47
 
  void dbConnect() {};
48
 
  //! Return a list of selected tables
49
 
  QStringList selectedTables();
50
 
  //! Return the connection info
51
 
  QString connInfo();
52
 
  //! Create a new PostgreSQL connection
53
 
  void newConnection();
54
 
  //! Edit a PostgreSQL connection
55
 
  void editConnection();
56
 
  //! Remove a PostgreSQL connection
57
 
  void removeConnection();
58
 
  //! Add file to the queue
59
 
  void addFile();
60
 
  //! Remove selected file from the queue
61
 
  void removeFile();
62
 
  //! Remove all files from the queue
63
 
  void removeAllFiles();
64
 
  //! Use the default SRID (Spatial Reference ID)
65
 
  void useDefaultSrid();
66
 
  //! Use the default geometry field name (the_geom)
67
 
  void useDefaultGeom();
68
 
  //! Show brief help
69
 
  void helpInfo();
70
 
  //! Get schemas available in the database
71
 
  void getSchema();
72
 
  void updateSchema();
73
 
  //! Import shapefiles into PostgreSQL
74
 
  void import();
75
 
  //! Edit the column names for a shapefile in the queue
76
 
  void editColumns( int, int, int, const QPoint & );
77
 
  //! Edit import properties of a shapefile in the queue
78
 
  void editShapefile( int, int, int, const QPoint & );
79
 
 
80
 
public slots:
81
 
 
82
 
  // In porting from Qt3 to Qt4 it was easier to have these small
83
 
  // redirects for the widget signals rather than rename the existing
84
 
  // functions (which would be been connected to the widgets using the
85
 
  // Qt3 designer signal/slot connection mechanism), in case you were
86
 
  // wondering. 
87
 
  void on_btnConnect_clicked()    { dbConnect();        }
88
 
  void on_btnEdit_clicked()       { editConnection();   }
89
 
  void on_btnNew_clicked()        { newConnection();    }
90
 
  void on_btnRemove_clicked()     { removeConnection(); }
91
 
  void on_btnImport_clicked()     { import();           } 
92
 
  void on_btnHelp_clicked()       { helpInfo();         }
93
 
  void on_btnQuit_clicked()       { close();           }
94
 
  void on_btnAddFile_clicked()    { addFile();          }
95
 
  void on_btnRemoveAll_clicked()  { removeAllFiles();   }
96
 
  void on_btnRemoveFile_clicked() { removeFile();       }
97
 
  void on_tblShapefiles_itemClicked(QTableWidgetItem* item) 
98
 
    { tblShapefiles->editItem(item); }
99
 
  // When the user changes the selected connection, update the schema list
100
 
  void on_cmbConnections_activated(int) { getSchema(); }
101
 
  void on_chkUseDefaultSrid_toggled(bool) { useDefaultSrid(); }
102
 
  void on_chkUseDefaultGeom_toggled(bool) { useDefaultGeom(); }
103
 
 
104
 
private:
105
 
 
106
 
  // Enum of table columns indexes
107
 
  enum ShpTableColumns
108
 
  {
109
 
    ColFILENAME = 0,
110
 
    ColFEATURECLASS = 1, // is editable
111
 
    ColFEATURECOUNT = 2,
112
 
    ColDBRELATIONNAME = 3,  // is editable
113
 
    ColDBSCHEMA = 4  // is editable
114
 
  };
115
 
  
116
 
  PGconn* checkConnection();
117
 
  QStringList schema_list;
118
 
  QStringList geometry_list;
119
 
  int total_features;
120
 
  std::vector <QgsShapeFile *> fileList;
121
 
  int defSrid;
122
 
  QString defGeom;
123
 
  int defaultSridValue;
124
 
  QString defaultGeomValue;
125
 
  QString gl_key;
 
40
    Q_OBJECT
 
41
  public:
 
42
    QgsSpit( QWidget *parent = 0, Qt::WFlags fl = 0 );
 
43
    ~QgsSpit();
 
44
    //! Populate the list of available database connections
 
45
    void populateConnectionList();
 
46
    //! Connect to the selected database
 
47
    void dbConnect();
 
48
    //! Return a list of selected tables
 
49
    QStringList selectedTables();
 
50
    //! Return the connection info
 
51
    QString connectionInfo();
 
52
    //! Create a new PostgreSQL connection
 
53
    void newConnection();
 
54
    //! Edit a PostgreSQL connection
 
55
    void editConnection();
 
56
    //! Remove a PostgreSQL connection
 
57
    void removeConnection();
 
58
    //! Add file to the queue
 
59
    void addFile();
 
60
    //! Remove selected file from the queue
 
61
    void removeFile();
 
62
    //! Remove all files from the queue
 
63
    void removeAllFiles();
 
64
    //! Use the default SRID (Spatial Reference ID)
 
65
    void useDefaultSrid();
 
66
    //! Use the default geometry field name (the_geom)
 
67
    void useDefaultGeom();
 
68
    //! Show brief help
 
69
    void helpInfo();
 
70
    //! Import shapefiles into PostgreSQL
 
71
    void import();
 
72
 
 
73
  public slots:
 
74
 
 
75
    // In porting from Qt3 to Qt4 it was easier to have these small
 
76
    // redirects for the widget signals rather than rename the existing
 
77
    // functions (which would be been connected to the widgets using the
 
78
    // Qt3 designer signal/slot connection mechanism), in case you were
 
79
    // wondering.
 
80
    void on_btnConnect_clicked()    { dbConnect();        }
 
81
    void on_btnEdit_clicked()       { editConnection();   }
 
82
    void on_btnNew_clicked()        { newConnection();    }
 
83
    void on_btnRemove_clicked()     { removeConnection(); }
 
84
    void on_buttonBox_accepted()    { import();           }
 
85
    void on_buttonBox_helpRequested() { helpInfo();       }
 
86
    void on_buttonBox_rejected()    { reject();           }
 
87
    void on_btnAddFile_clicked()    { addFile();          }
 
88
    void on_btnRemoveAll_clicked()  { removeAllFiles();   }
 
89
    void on_btnRemoveFile_clicked() { removeFile();       }
 
90
    void on_tblShapefiles_itemClicked( QTableWidgetItem* item )
 
91
    { tblShapefiles->editItem( item ); }
 
92
    // When the user changes the selected connection, update the schema list
 
93
    void on_chkUseDefaultSrid_toggled( bool ) { useDefaultSrid(); }
 
94
    void on_chkUseDefaultGeom_toggled( bool ) { useDefaultGeom(); }
 
95
 
 
96
  private:
 
97
 
 
98
    // Enum of table columns indexes
 
99
    enum ShpTableColumns
 
100
    {
 
101
      ColFILENAME = 0,
 
102
      ColFEATURECLASS = 1, // is editable
 
103
      ColFEATURECOUNT = 2,
 
104
      ColDBRELATIONNAME = 3,  // is editable
 
105
      ColDBSCHEMA = 4  // is editable
 
106
    };
 
107
 
 
108
    PGconn* checkConnection();
 
109
    QStringList schema_list;
 
110
    QStringList geometry_list;
 
111
    int total_features;
 
112
    std::vector <QgsShapeFile *> fileList;
 
113
    int defSrid;
 
114
    QString defGeom;
 
115
    int defaultSridValue;
 
116
    QString defaultGeomValue;
 
117
    PGconn *conn;
126
118
};
127
119
 
128
120
// We want to provide combo boxes in the table of shape files to
132
124
 
133
125
class ShapefileTableDelegate : public QItemDelegate
134
126
{
135
 
  Q_OBJECT;
136
 
 
137
 
 public:
138
 
  ShapefileTableDelegate(QObject *parent, QStringList& schema_list) :
139
 
    mSchemaList(schema_list) {}
140
 
 
141
 
  QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
142
 
                        const QModelIndex &index) const;
143
 
 
144
 
  void setEditorData(QWidget *editor, const QModelIndex &index) const;
145
 
  void setModelData(QWidget *editor, QAbstractItemModel *model,
146
 
                    const QModelIndex &index) const;
147
 
 
148
 
  void updateEditorGeometry(QWidget *editor,
149
 
             const QStyleOptionViewItem &option, const QModelIndex &index) const;
150
 
  void updateSchemaList(QStringList& schema_list, QString currentSchema);
151
 
 
152
 
 private:
153
 
  QStringList mSchemaList;
154
 
  int mCurrentIndex;
 
127
    Q_OBJECT
 
128
 
 
129
  public:
 
130
    ShapefileTableDelegate( QObject *parent, QStringList& schema_list ) :
 
131
        mSchemaList( schema_list ) {}
 
132
 
 
133
    QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option,
 
134
                           const QModelIndex &index ) const;
 
135
 
 
136
    void setEditorData( QWidget *editor, const QModelIndex &index ) const;
 
137
    void setModelData( QWidget *editor, QAbstractItemModel *model,
 
138
                       const QModelIndex &index ) const;
 
139
 
 
140
    void updateEditorGeometry( QWidget *editor,
 
141
                               const QStyleOptionViewItem &option, const QModelIndex &index ) const;
 
142
    void updateSchemaList( QStringList& schema_list, QString currentSchema );
 
143
 
 
144
  private:
 
145
    QStringList mSchemaList;
 
146
    int mCurrentIndex;
155
147
};
156
148
 
157
149
#endif