Navigation Menu

Skip to content

Commit

Permalink
support for icons in postgis selection dialog
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@13 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
gsherman committed Jul 6, 2002
1 parent 2464896 commit f75d535
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 49 deletions.
84 changes: 84 additions & 0 deletions src/qgisicons.h
@@ -0,0 +1,84 @@
#ifndef QGISICONS_H
#define QGISICONS_H
/* XPM */
static const char * layer_points[] = {
"16 16 14 1",
" c None",
". c #60EE0E",
"+ c #60EF0E",
"@ c #60ED0E",
"# c #5FEE0E",
"$ c #5DE70E",
"% c #5FEB0E",
"& c #5CE70D",
"* c #5DE70D",
"= c #5AE00D",
"- c #5CE70E",
"; c #60EC0E",
"> c #58DB0D",
", c #5BE40E",
" ",
" ",
" ",
" ",
" ",
" .++ ",
" +++++ ",
" +++++++ ",
" +++++@+ ",
" ##.+$%+ ",
" &*=-; ",
" >,% ",
" ",
" ",
" ",
" "};

/* XPM */
static const char * layer_lines[] = {
"16 16 2 1",
" c None",
". c #5272FF",
" ",
" .. . ",
" .. .. ",
" . .... ",
" . . ",
" ... . ",
" .... ",
" .. ",
" .. ",
" . ",
" .. ",
" .. ",
" .. ",
" .. ",
" . ",
" "};


/* XPM */
static const char * layer_polygon[] = {
"16 16 3 1",
" c None",
". c #D86652",
"+ c #ddfcc9",
" ",
" .. ",
" .... ...... ",
" .++...++++. ",
" ..++++++++. ",
" ...++++.. ",
" .++++. ",
" ..+++++.. ",
" ..+++++++. ",
" ..++++++++.. ",
" .++++++++... ",
" .++...+++. ",
" .......+++. ",
" ..... ",
" .. ",
" "};


#endif // QGISICONS_H
39 changes: 37 additions & 2 deletions src/qgsdbsourceselect.cpp
@@ -1,9 +1,11 @@
#include <libpq++.h>
#include <iostream>
#include <qsettings.h>
#include <qpixmap.h>
#include <qlistbox.h>
#include <qstringlist.h>
#include <qcombobox.h>
#include "qgisicons.h"
#include "qgsdbsourceselect.h"
#include "qgsnewconnection.h"

Expand All @@ -27,6 +29,20 @@ void QgsDbSourceSelect::addNewConnection(){
if(nc->exec()){
}
}
void QgsDbSourceSelect::editConnection(){

QgsNewConnection *nc = new QgsNewConnection();
// populate the fields with the stored setting parameters
QSettings settings;

QString key = "/Qgis/connections/" + cmbConnections->currentText();
QString host = settings.readEntry(key+"/host");
QString database = settings.readEntry(key+"/database");
QString username = settings.readEntry(key+"/username");
QString password = settings.readEntry(key+"/password");
if(nc->exec()){
}
}

void QgsDbSourceSelect::dbConnect(){
// populate the table list
Expand All @@ -41,9 +57,16 @@ void QgsDbSourceSelect::dbConnect(){
PgDatabase *pd = new PgDatabase((const char *)conninfo);
cout << pd->ErrorMessage();
if(pd->Status()==CONNECTION_OK){
// create the pixmaps for the layer types
QPixmap pxPoint;
pxPoint = QPixmap(layer_points);
QPixmap pxLine;
pxLine = QPixmap(layer_lines);
QPixmap pxPoly;
pxPoly = QPixmap(layer_polygon);
qDebug("Connection succeeded");
// get the list of tables
QString sql = "select f_table_name from geometry_columns where f_table_schema ='"
QString sql = "select * from geometry_columns where f_table_schema ='"
+ settings.readEntry(key+"/database") + "'";
qDebug("Fetching tables using: " + sql);
int result = pd->ExecTuplesOk((const char *)sql);
Expand All @@ -53,7 +76,19 @@ void QgsDbSourceSelect::dbConnect(){
qDebug( msg);
for(int idx = 0; idx < pd->Tuples(); idx++){
QString v = pd->GetValue(idx,"f_table_name");
lstTables->insertItem(v);
QString type = pd->GetValue(idx,"type");
QPixmap *p;
if(type == "POINT" || type == "MULTIPOINT")
p = &pxPoint;
else
if(type == "MULTIPOLYGON" || type == "POLYGON")
p = &pxPoly;
else
if(type == "LINESTRING" || type == "MULTILINESTRING")
p = &pxLine;
else
p = 0;
lstTables->insertItem(*p,v);
}
}else{
qDebug( "Unable to get list of spatially enabled tables from geometry_columns table");
Expand Down
1 change: 1 addition & 0 deletions src/qgsdbsourceselect.h
Expand Up @@ -8,6 +8,7 @@ class QgsDbSourceSelect : public QgsDbSourceSelectBase
QgsDbSourceSelect();
~QgsDbSourceSelect();
void addNewConnection();
void editConnection();
void dbConnect();
};

Expand Down
97 changes: 50 additions & 47 deletions src/qgsdbsourceselectbase.ui
Expand Up @@ -9,7 +9,7 @@
<x>0</x>
<y>0</y>
<width>305</width>
<height>367</height>
<height>338</height>
</rect>
</property>
<property name="font">
Expand All @@ -34,7 +34,7 @@
<property name="spacing">
<number>6</number>
</property>
<widget class="QLayoutWidget" row="2" column="1" rowspan="2" colspan="1">
<widget class="QLayoutWidget" row="2" column="1">
<property name="name">
<cstring>Layout5</cstring>
</property>
Expand Down Expand Up @@ -112,19 +112,6 @@
</spacer>
</grid>
</widget>
<widget class="QLabel" row="1" column="0">
<property name="name">
<cstring>TextLabel3_2_2</cstring>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Tables</string>
</property>
</widget>
<widget class="QGroupBox" row="0" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>GroupBox1</cstring>
Expand All @@ -142,7 +129,12 @@
<property name="spacing">
<number>6</number>
</property>
<widget class="QPushButton" row="1" column="1">
<widget class="QComboBox" row="0" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>cmbConnections</cstring>
</property>
</widget>
<widget class="QPushButton" row="1" column="0">
<property name="name">
<cstring>btnConnect</cstring>
</property>
Expand All @@ -152,42 +144,36 @@
</widget>
<widget class="QPushButton" row="1" column="2">
<property name="name">
<cstring>btnConnect_2</cstring>
<cstring>btnEdit</cstring>
</property>
<property name="text">
<string>Create</string>
</property>
</widget>
<widget class="QComboBox" row="0" column="0" rowspan="1" colspan="4">
<property name="name">
<cstring>cmbConnections</cstring>
<string>Edit</string>
</property>
</widget>
<spacer row="1" column="0">
<property name="name">
<cstring>Spacer3</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
</spacer>
<spacer row="1" column="3">
<widget class="QPushButton" row="1" column="1">
<property name="name">
<cstring>Spacer3_2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
<cstring>btnNew</cstring>
</property>
<property name="sizeType">
<enum>Expanding</enum>
<property name="text">
<string>New</string>
</property>
</spacer>
</widget>
</grid>
</widget>
<widget class="QListBox" row="3" column="0">
<widget class="QLabel" row="1" column="0">
<property name="name">
<cstring>TextLabel3_2_2</cstring>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Tables</string>
</property>
</widget>
<widget class="QListBox" row="2" column="0">
<property name="name">
<cstring>lstTables</cstring>
</property>
Expand Down Expand Up @@ -217,20 +203,37 @@
<slot>addTables()</slot>
</connection>
<connection>
<sender>btnConnect_2</sender>
<sender>btnNew</sender>
<signal>clicked()</signal>
<receiver>QgsDbSourceSelectBase</receiver>
<slot>addNewConnection()</slot>
</connection>
<connection>
<sender>btnEdit</sender>
<signal>clicked()</signal>
<receiver>QgsDbSourceSelectBase</receiver>
<slot>editConnection()</slot>
</connection>
</connections>
<tabstops>
<tabstop>cmbConnections</tabstop>
<tabstop>btnConnect</tabstop>
<tabstop>btnNew</tabstop>
<tabstop>btnEdit</tabstop>
<tabstop>lstTables</tabstop>
<tabstop>btnAdd</tabstop>
<tabstop>btnCancel</tabstop>
<tabstop>btnHelp</tabstop>
</tabstops>
<includes>
<include location="local" impldecl="in implementation">qgsdbsourceselectbase.ui.h</include>
</includes>
<slots>
<slot>init()</slot>
<slot>dbConnect()</slot>
<slot>addTables()</slot>
<slot>addNewConnection()</slot>
<slot>addTables()</slot>
<slot>dbConnect()</slot>
<slot>init()</slot>
<slot>editConnection()</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>
6 changes: 6 additions & 0 deletions src/qgsdbsourceselectbase.ui.h
Expand Up @@ -26,3 +26,9 @@ void QgsDbSourceSelectBase::addNewConnection()
{

}


void QgsDbSourceSelectBase::editConnection()
{

}
12 changes: 12 additions & 0 deletions src/qgsnewconnectionbase.ui
Expand Up @@ -293,6 +293,18 @@
<slot>saveConnection()</slot>
</connection>
</connections>
<tabstops>
<tabstop>txtName</tabstop>
<tabstop>txtHost</tabstop>
<tabstop>txtDatabase</tabstop>
<tabstop>txtUsername</tabstop>
<tabstop>txtPassword</tabstop>
<tabstop>chkStorePassword</tabstop>
<tabstop>btnConnect</tabstop>
<tabstop>buttonOk</tabstop>
<tabstop>buttonCancel</tabstop>
<tabstop>buttonHelp</tabstop>
</tabstops>
<slots>
<slot>saveConnection()</slot>
<slot>testConnection()</slot>
Expand Down

0 comments on commit f75d535

Please sign in to comment.