src/plugins/spit/qgsspit.h

Go to the documentation of this file.
00001 #ifndef QGSSPIT_H
00002 #define QGSSPIT_H
00003 /***************************************************************************
00004                         qgsspit.h  -  description
00005                            -------------------
00006   begin                : Fri Dec 19 2003
00007   copyright            : (C) 2003 by Denis Antipov
00008                        : (C) 2004 by Gary Sherman
00009   email                :
00010 ***************************************************************************/
00011 
00012 /***************************************************************************
00013  *                                                                         *
00014  *   This program is free software; you can redistribute it and/or modify  *
00015  *   it under the terms of the GNU General Public License as published by  *
00016  *   the Free Software Foundation; either version 2 of the License, or     *
00017  *   (at your option) any later version.                                   *
00018  *                                                                         *
00019  ***************************************************************************/
00020 /* $Id: qgsspit.h 9502 2008-10-20 20:24:36Z timlinux $ */
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     // In porting from Qt3 to Qt4 it was easier to have these small
00076     // redirects for the widget signals rather than rename the existing
00077     // functions (which would be been connected to the widgets using the
00078     // Qt3 designer signal/slot connection mechanism), in case you were
00079     // wondering.
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     // When the user changes the selected connection, update the schema list
00093     void on_chkUseDefaultSrid_toggled( bool ) { useDefaultSrid(); }
00094     void on_chkUseDefaultGeom_toggled( bool ) { useDefaultGeom(); }
00095 
00096   private:
00097 
00098     // Enum of table columns indexes
00099     enum ShpTableColumns
00100     {
00101       ColFILENAME = 0,
00102       ColFEATURECLASS = 1, // is editable
00103       ColFEATURECOUNT = 2,
00104       ColDBRELATIONNAME = 3,  // is editable
00105       ColDBSCHEMA = 4  // is editable
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 // We want to provide combo boxes in the table of shape files to
00121 // load. Qt4 doesn't provide an 'out-of-the-box' way to do this
00122 // (unlike Qt3), so we have to use the Qt4 delegate technique to
00123 // provide combo boxes for the table, hence this class...
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

Generated on Tue Oct 28 16:51:36 2008 for Quantum GIS API Documentation by  doxygen 1.5.1