1
/***************************************************************************
2
qgspatialitesourceselect.h - description
5
copyright : (C) 2008 by Sandro Furieri
6
email : a.furieri@lqt.it
7
***************************************************************************/
9
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
16
***************************************************************************/
17
#ifndef QGSSPATIALITESOURCESELECT_H
18
#define QGSSPATIALITESOURCESELECT_H
19
#include "ui_qgsspatialitesourceselectbase.h"
22
#include "qgsspatialitefilterproxymodel.h"
23
#include "qgsspatialitetablemodel.h"
24
#include "qgscontexthelp.h"
28
#include <spatialite/sqlite3.h>
40
#include <QFileDialog>
43
class QTableWidgetItem;
47
/*! \class QgsSpatiaLiteSourceSelect
48
* \brief Dialog to create connections and add tables from SpatiaLite.
50
* This dialog allows the user to define and save connection information
51
* for SpatiaLite/SQLite databases. The user can then connect and add
52
* tables from the database to the map canvas.
54
class QgsSpatiaLiteSourceSelect: public QDialog, private Ui::QgsSpatiaLiteSourceSelectBase
61
QgsSpatiaLiteSourceSelect( QgisApp * app, Qt::WFlags fl = QgisGui::ModalDialogFlags );
63
~QgsSpatiaLiteSourceSelect() {}
64
//! Populate the connection list combo box
65
void populateConnectionList();
66
//! Determines the tables the user selected and closes the dialog
68
//! String list containing the selected tables
69
QStringList selectedTables();
70
//! Connection info (DB-path)
71
QString connectionInfo();
72
// Store the selected database
76
/*! Connects to the database using the stored connection parameters.
77
* Once connected, available layers are displayed.
79
void on_btnConnect_clicked();
81
//! Opens the create connection dialog to build a new connection
82
void on_btnNew_clicked();
83
//! Deletes the selected connection
84
void on_btnDelete_clicked();
85
void on_mSearchOptionsButton_clicked();
86
void on_mSearchTableEdit_textChanged( const QString & text );
87
void on_mSearchColumnComboBox_currentIndexChanged( const QString & text );
88
void on_mSearchModeComboBox_currentIndexChanged( const QString & text );
89
void on_cmbConnections_activated( int );
90
void setLayerType( QString table, QString column, QString type );
91
//!Sets a new regular expression to the model
92
void setSearchExpression( const QString & regexp );
94
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
105
typedef std::pair < QString, QString > geomPair;
106
typedef std::list < geomPair > geomCol;
108
/**Checks if geometry_columns_auth table exists*/
109
bool checkGeometryColumnsAuth( sqlite3 * handle );
111
/**Checks if views_geometry_columns table exists*/
112
bool checkViewsGeometryColumns( sqlite3 * handle );
114
/**Checks if virts_geometry_columns table exists*/
115
bool checkVirtsGeometryColumns( sqlite3 * handle );
117
/**Checks if this layer has been declared HIDDEN*/
118
bool isDeclaredHidden( sqlite3 * handle, QString table, QString geom );
120
/**cleaning well-formatted SQL strings*/
121
QString quotedValue( QString value ) const;
123
/**Inserts information about the spatial tables into mTableModel*/
124
bool getTableInfo( sqlite3 * handle );
126
// SpatiaLite DB open / close
127
sqlite3 *openSpatiaLiteDb( QString path );
128
void closeSpatiaLiteDb( sqlite3 * handle );
130
// Set the position of the database connection list to the last
132
void setConnectionListPosition();
133
// Combine the table and column data into a single string
134
// useful for display to the user
135
QString fullDescription( QString table, QString column, QString type );
137
QStringList mColumnLabels;
139
QStringList m_selectedTables;
140
// Storage for the range of layer type icons
141
QMap < QString, QPair < QString, QIcon > >mLayerIcons;
142
//! Pointer to the qgis application mainwindow
144
//! Model that acts as datasource for mTableTreeWidget
145
QgsSpatiaLiteTableModel mTableModel;
146
QgsSpatiaLiteFilterProxyModel mProxyModel;
148
QPushButton *mAddButton;
151
#endif // QGSSPATIALITESOURCESELECT_H