Skip to content

Commit

Permalink
Commit postgis dialog extension to trunk
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7920 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jan 10, 2008
1 parent 27afa4e commit bdad5f6
Show file tree
Hide file tree
Showing 9 changed files with 875 additions and 359 deletions.
586 changes: 327 additions & 259 deletions src/app/qgsdbsourceselect.cpp

Large diffs are not rendered by default.

29 changes: 17 additions & 12 deletions src/app/qgsdbsourceselect.h
Expand Up @@ -19,6 +19,9 @@
#define QGSDBSOURCESELECT_H
#include "ui_qgsdbsourceselectbase.h"
#include "qgisgui.h"
#include "qgsdbfilterproxymodel.h"
#include "qgsdbtablemodel.h"

extern "C"
{
#include <libpq-fe.h>
Expand Down Expand Up @@ -68,8 +71,6 @@ class QgsDbSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
QStringList selectedTables();
//! Connection info (database, host, user, password)
QString connInfo();
//! Return the name of the selected encoding (e.g. UTf-8, ISO-8559-1, etc/)
QString encoding();
// Store the selected database
void dbChanged();
// Utility function to construct the query for finding out the
Expand All @@ -85,12 +86,18 @@ class QgsDbSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
void on_btnNew_clicked();
void on_btnEdit_clicked();
void on_btnDelete_clicked();
void on_lstTables_itemDoubleClicked(QTableWidgetItem *);
void setSql(QTableWidgetItem *);
void on_mSearchOptionsButton_clicked();
void on_mSearchTableEdit_textChanged(const QString & text);
void on_mSearchColumnComboBox_currentIndexChanged(const QString & text);
void on_mSearchModeComboBox_currentIndexChanged(const QString & text);
void setSql(const QModelIndex& index);
void on_btnHelp_clicked();
void on_cmbConnections_activated(int);
void setLayerType(QString schema, QString table, QString column,
QString type);
//!Sets a new regular expression to the model
void setSearchExpression(const QString& regexp);

private:
enum columns {
dbssType=0,
Expand All @@ -107,6 +114,9 @@ class QgsDbSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
bool searchGeometryColumnsOnly,
bool searchPublicOnly);

/**Inserts information about the spatial tables into mTableModel*/
bool getTableInfo(PGconn *pg, bool searchGeometryColumnsOnly, bool searchPublicOnly);

// queue another query for the thread
void addSearchGeometryColumn(const QString &schema, const QString &table, const QString &column);

Expand All @@ -115,10 +125,6 @@ class QgsDbSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
void setConnectionListPosition();
// Show the context help for the dialog
void showHelp();
// initialize row
void initRow(int row);
// update the row
void updateRow(int row, QString detail, QString type);
// Combine the schema, table and column data into a single string
// useful for display to the user
QString fullDescription(QString schema, QString table, QString column, QString type);
Expand All @@ -130,14 +136,13 @@ class QgsDbSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
QStringList m_selectedTables;
// Storage for the range of layer type icons
QMap<QString, QPair<QString, QIcon> > mLayerIcons;
#if 0
// minlength of layer type combobox
int mCbMinLength;
#endif
//! Pointer to the qgis application mainwindow
QgisApp *qgisApp;
PGconn *pd;
static const int context_id = 939347163;
//! Model that acts as datasource for mTableTreeWidget
QgsDbTableModel mTableModel;
QgsDbFilterProxyModel mProxyModel;
};


Expand Down
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -11,6 +11,8 @@ qgsclipper.cpp
qgscontexthelp.cpp
qgscoordinatetransform.cpp
qgsdatasourceuri.cpp
qgsdbfilterproxymodel.cpp
qgsdbtablemodel.cpp
qgsdistancearea.cpp
qgsexception.cpp
qgsfeature.cpp
Expand Down
53 changes: 53 additions & 0 deletions src/core/qgsdbfilterproxymodel.cpp
@@ -0,0 +1,53 @@
/***************************************************************************
qgsdbfilterproxymodel.cpp - description
-------------------------
begin : Dec 2007
copyright : (C) 2007 by Marco Hugentobler
email : marco dot hugentobler at karto dot baug dot ethz dot ch
***************************************************************************/

/***************************************************************************
* *
* 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. *
* *
***************************************************************************/

#include "qgsdbfilterproxymodel.h"

QgsDbFilterProxyModel::QgsDbFilterProxyModel(QObject* parent): QSortFilterProxyModel(parent)
{

}

QgsDbFilterProxyModel::~QgsDbFilterProxyModel()
{

}

bool QgsDbFilterProxyModel::filterAcceptsRow(int row, const QModelIndex & source_parent ) const
{
//if parent is valid, we have a toplevel item that should be always shown
if(!source_parent.isValid())
{
return true;
}

//else we have a row that describes a table and that
//should be tested using the given wildcard/regexp
return QSortFilterProxyModel::filterAcceptsRow(row, source_parent);
}

void QgsDbFilterProxyModel::_setFilterWildcard(const QString& pattern)
{
QSortFilterProxyModel::setFilterWildcard(pattern);
emit layoutChanged();
}

void QgsDbFilterProxyModel::_setFilterRegExp(const QString& pattern)
{
QSortFilterProxyModel::setFilterRegExp(pattern);
emit layoutChanged();
}
39 changes: 39 additions & 0 deletions src/core/qgsdbfilterproxymodel.h
@@ -0,0 +1,39 @@
/***************************************************************************
qgsdbfilterproxymodel.h - description
-----------------------
begin : Dec 2007
copyright : (C) 2007 by Marco Hugentobler
email : marco dot hugentobler at karto dot baug dot ethz dot ch
***************************************************************************/

/***************************************************************************
* *
* 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 QGSDBFILTERPROXYMODEL_H
#define QGSDBFILTERPROXYMODEL_H

#include <QSortFilterProxyModel>

/**A class that implements a custom filter and can be used
as a proxy for QgsDbTableModel*/
class CORE_EXPORT QgsDbFilterProxyModel: public QSortFilterProxyModel
{
public:
QgsDbFilterProxyModel(QObject* parent = 0);
~QgsDbFilterProxyModel();
/**Calls QSortFilterProxyModel::setFilterWildcard and triggers update*/
void _setFilterWildcard(const QString& pattern);
/**Calls QSortFilterProxyModel::setFilterRegExp and triggers update*/
void _setFilterRegExp(const QString& pattern);

protected:
virtual bool filterAcceptsRow(int row, const QModelIndex & source_parent ) const;
};

#endif

0 comments on commit bdad5f6

Please sign in to comment.