00001 #ifndef QGSSPIT_H
00002 #define QGSSPIT_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <vector>
00022 #include <algorithm>
00023
00024 #include <QStringList>
00025 #include <QString>
00026 #include <QItemDelegate>
00027
00028 #include "qgsshapefile.h"
00029 #include "ui_qgsspitbase.h"
00030
00031 class QTableWidgetItem;
00032
00033 extern "C"
00034 {
00035 #include <libpq-fe.h>
00036 }
00037
00038 class QgsSpit : public QDialog, private Ui::QgsSpitBase
00039 {
00040 Q_OBJECT
00041 public:
00042 QgsSpit( QWidget *parent = 0, Qt::WFlags fl = 0 );
00043 ~QgsSpit();
00045 void populateConnectionList();
00047 void dbConnect();
00049 QStringList selectedTables();
00051 QString connectionInfo();
00053 void newConnection();
00055 void editConnection();
00057 void removeConnection();
00059 void addFile();
00061 void removeFile();
00063 void removeAllFiles();
00065 void useDefaultSrid();
00067 void useDefaultGeom();
00069 void helpInfo();
00071 void import();
00072
00073 public slots:
00074
00075
00076
00077
00078
00079
00080 void on_btnConnect_clicked() { dbConnect(); }
00081 void on_btnEdit_clicked() { editConnection(); }
00082 void on_btnNew_clicked() { newConnection(); }
00083 void on_btnRemove_clicked() { removeConnection(); }
00084 void on_buttonBox_accepted() { import(); }
00085 void on_buttonBox_helpRequested() { helpInfo(); }
00086 void on_buttonBox_rejected() { reject(); }
00087 void on_btnAddFile_clicked() { addFile(); }
00088 void on_btnRemoveAll_clicked() { removeAllFiles(); }
00089 void on_btnRemoveFile_clicked() { removeFile(); }
00090 void on_tblShapefiles_itemClicked( QTableWidgetItem* item )
00091 { tblShapefiles->editItem( item ); }
00092
00093 void on_chkUseDefaultSrid_toggled( bool ) { useDefaultSrid(); }
00094 void on_chkUseDefaultGeom_toggled( bool ) { useDefaultGeom(); }
00095
00096 private:
00097
00098
00099 enum ShpTableColumns
00100 {
00101 ColFILENAME = 0,
00102 ColFEATURECLASS = 1,
00103 ColFEATURECOUNT = 2,
00104 ColDBRELATIONNAME = 3,
00105 ColDBSCHEMA = 4
00106 };
00107
00108 PGconn* checkConnection();
00109 QStringList schema_list;
00110 QStringList geometry_list;
00111 int total_features;
00112 std::vector <QgsShapeFile *> fileList;
00113 int defSrid;
00114 QString defGeom;
00115 int defaultSridValue;
00116 QString defaultGeomValue;
00117 PGconn *conn;
00118 };
00119
00120
00121
00122
00123
00124
00125 class ShapefileTableDelegate : public QItemDelegate
00126 {
00127 Q_OBJECT
00128
00129 public:
00130 ShapefileTableDelegate( QObject *parent, QStringList& schema_list ) :
00131 mSchemaList( schema_list ) {}
00132
00133 QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option,
00134 const QModelIndex &index ) const;
00135
00136 void setEditorData( QWidget *editor, const QModelIndex &index ) const;
00137 void setModelData( QWidget *editor, QAbstractItemModel *model,
00138 const QModelIndex &index ) const;
00139
00140 void updateEditorGeometry( QWidget *editor,
00141 const QStyleOptionViewItem &option, const QModelIndex &index ) const;
00142 void updateSchemaList( QStringList& schema_list, QString currentSchema );
00143
00144 private:
00145 QStringList mSchemaList;
00146 int mCurrentIndex;
00147 };
00148
00149 #endif