Skip to content

Commit 002eb0d

Browse files
author
Emilio Loi
committedApr 13, 2013
First attempt to create a load style ui
1 parent 8694c19 commit 002eb0d

8 files changed

+169
-5
lines changed
 

‎src/app/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ SET(QGIS_APP_SRCS
8282
qgsmaptooltextannotation.cpp
8383
qgsmaptoolvertexedit.cpp
8484
qgssavestyletodbdialog.cpp
85+
qgsloadstylefromdbdialog.cpp
8586

8687
nodetool/qgsmaptoolnodetool.cpp
8788
nodetool/qgsselectedfeature.cpp
@@ -229,6 +230,7 @@ SET (QGIS_APP_MOC_HDRS
229230
qgsmaptoolsplitfeatures.h
230231
qgsmaptoolvertexedit.h
231232
qgssavestyletodbdialog.h
233+
qgsloadstylefromdbdialog.h
232234

233235
nodetool/qgsmaptoolnodetool.h
234236
nodetool/qgsselectedfeature.h

‎src/app/qgsloadstylefromdbdialog.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/***************************************************************************
2+
* *
3+
* This program is free software; you can redistribute it and/or modify *
4+
* it under the terms of the GNU General Public License as published by *
5+
* the Free Software Foundation; either version 2 of the License, or *
6+
* (at your option) any later version. *
7+
* *
8+
***************************************************************************/
9+
10+
#include "qgsloadstylefromdbdialog.h"
11+
#include "qgslogger.h"
12+
13+
#include <QMessageBox>
14+
15+
QgsLoadStyleFromDBDialog::QgsLoadStyleFromDBDialog( QWidget *parent )
16+
: QDialog( parent )
17+
{
18+
setupUi( this );
19+
}

‎src/app/qgsloadstylefromdbdialog.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/***************************************************************************
2+
* *
3+
* This program is free software; you can redistribute it and/or modify *
4+
* it under the terms of the GNU General Public License as published by *
5+
* the Free Software Foundation; either version 2 of the License, or *
6+
* (at your option) any later version. *
7+
* *
8+
***************************************************************************/
9+
10+
#ifndef QGSADDATTRDIALOG_H
11+
#define QGSADDATTRDIALOG_H
12+
13+
#include "ui_qgsloadstylefromdbdialog.h"
14+
#include "qgisgui.h"
15+
#include "qgsfield.h"
16+
17+
//class QgsVectorLayer;
18+
19+
class QgsLoadStyleFromDBDialog: public QDialog, private Ui::QgsLoadStyleFromDBDialogLayout
20+
{
21+
Q_OBJECT
22+
public:
23+
explicit QgsLoadStyleFromDBDialog( QWidget *parent = 0 );
24+
// QgsAddAttrDialog( QgsVectorLayer *vlayer,
25+
// QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
26+
// QgsAddAttrDialog( const std::list<QString>& typelist,
27+
// QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
28+
29+
// QgsField field() const;
30+
31+
public slots:
32+
// void on_mTypeBox_currentIndexChanged( int idx );
33+
// void on_mLength_editingFinished();
34+
// void accept();
35+
36+
private:
37+
// QString mLayerType;
38+
39+
// void setPrecisionMinMax();
40+
};
41+
42+
#endif

‎src/app/qgssavestyletodbdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ QgsSaveStyleToDbDialog::QgsSaveStyleToDbDialog( QWidget *parent ) :
1818
QDialog( parent )
1919
{
2020
setupUi( this );
21-
setWindowTitle( "Save style in Postgres" );
21+
setWindowTitle( "Save style in database" );
2222
mDescriptionEdit->setTabChangesFocus( true );
2323
setTabOrder( mNameEdit, mDescriptionEdit );
2424
setTabOrder( mDescriptionEdit, mUseAsDefault );

‎src/app/qgsvectorlayerproperties.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "qgslabelinggui.h"
3535
#include "qgslabel.h"
3636
#include "qgslegenditem.h"
37+
//#include "qgsloadstylefromdbdialog.h"
3738
#include "qgsgenericprojectionselector.h"
3839
#include "qgslogger.h"
3940
#include "qgsmaplayerregistry.h"
@@ -747,7 +748,7 @@ void QgsVectorLayerProperties::loadStyleMenuTriggered( QAction *action )
747748

748749
void QgsVectorLayerProperties::showListOfStylesFromDatabase()
749750
{
750-
//TODO el1073 ui&logic
751+
// QgsLoadStyleFromDBDialog dialog;
751752
}
752753

753754
QList<QgsVectorOverlayPlugin*> QgsVectorLayerProperties::overlayPlugins() const

‎src/app/qgsvectorlayerproperties.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,15 @@ class QgsVectorLayerProperties : public QDialog, private Ui::QgsVectorLayerPrope
136136

137137
/** called when is possible to choice if load the style from filesystem or from db */
138138
void loadStyleMenuTriggered( QAction * );
139-
/** when provider supports, it will list all the styles relative the layer */
140-
void showListOfStylesFromDatabase();
139+
141140

142141
protected:
143142

144143
void saveStyleAs( StyleType styleType );
145144

145+
/** when provider supports, it will list all the styles relative the layer */
146+
void showListOfStylesFromDatabase();
147+
146148
void updateSymbologyPage();
147149

148150
QgsVectorLayer *layer;

‎src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3246,7 +3246,7 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
32463246
char* c = PQgetvalue( result, 0, 0 );
32473247
if( *c == '0' )
32483248
{
3249-
QString createTabeQuery = QObject::tr( "CREATE TABLE public.%1 ( f_table_catalog varchar(256), f_table_schema varchar(256), f_table_name varchar(256), f_geometry_column varchar(256), styleName varchar(30), styleQML xml, styleSLD xml, useAsDefault boolean, description text, owner varchar(30), ui xml, update_time timestamp DEFAULT CURRENT_TIMESTAMP );" ).arg( styleTableName );
3249+
QString createTabeQuery = QObject::tr( "CREATE TABLE public.%1 (id SERIAL PRIMARY KEY, f_table_catalog varchar(256), f_table_schema varchar(256), f_table_name varchar(256), f_geometry_column varchar(256), styleName varchar(30), styleQML xml, styleSLD xml, useAsDefault boolean, description text, owner varchar(30), ui xml, update_time timestamp DEFAULT CURRENT_TIMESTAMP );" ).arg( styleTableName );
32503250

32513251
res = conn->PQexec( createTabeQuery );
32523252
if ( res.PQresultStatus() != PGRES_COMMAND_OK )

‎src/ui/qgsloadstylefromdbdialog.ui

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>QgsLoadStyleFromDBDialogLayout</class>
4+
<widget class="QDialog" name="QgsLoadStyleFromDBDialogLayout">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>475</width>
10+
<height>390</height>
11+
</rect>
12+
</property>
13+
<property name="sizePolicy">
14+
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
15+
<horstretch>0</horstretch>
16+
<verstretch>0</verstretch>
17+
</sizepolicy>
18+
</property>
19+
<property name="windowTitle">
20+
<string>Add column</string>
21+
</property>
22+
<property name="modal">
23+
<bool>true</bool>
24+
</property>
25+
<layout class="QGridLayout" name="gridLayout">
26+
<item row="0" column="0">
27+
<layout class="QVBoxLayout" name="verticalLayout">
28+
<item>
29+
<widget class="QLabel" name="label">
30+
<property name="text">
31+
<string>Styles related to the layer</string>
32+
</property>
33+
</widget>
34+
</item>
35+
<item>
36+
<widget class="QTableView" name="mRelatedTable"/>
37+
</item>
38+
<item>
39+
<widget class="QLabel" name="label_2">
40+
<property name="text">
41+
<string>Other styles on the database</string>
42+
</property>
43+
</widget>
44+
</item>
45+
<item>
46+
<widget class="QTableView" name="mOthersTable"/>
47+
</item>
48+
<item>
49+
<layout class="QHBoxLayout" name="horizontalLayout">
50+
<item>
51+
<spacer name="horizontalSpacer">
52+
<property name="orientation">
53+
<enum>Qt::Horizontal</enum>
54+
</property>
55+
<property name="sizeHint" stdset="0">
56+
<size>
57+
<width>40</width>
58+
<height>20</height>
59+
</size>
60+
</property>
61+
</spacer>
62+
</item>
63+
<item>
64+
<widget class="QPushButton" name="mCancelButton">
65+
<property name="sizePolicy">
66+
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
67+
<horstretch>0</horstretch>
68+
<verstretch>0</verstretch>
69+
</sizepolicy>
70+
</property>
71+
<property name="text">
72+
<string>Cancel</string>
73+
</property>
74+
</widget>
75+
</item>
76+
<item>
77+
<widget class="QPushButton" name="mLoadButton">
78+
<property name="sizePolicy">
79+
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
80+
<horstretch>0</horstretch>
81+
<verstretch>0</verstretch>
82+
</sizepolicy>
83+
</property>
84+
<property name="text">
85+
<string>Load Style</string>
86+
</property>
87+
</widget>
88+
</item>
89+
</layout>
90+
</item>
91+
</layout>
92+
</item>
93+
</layout>
94+
</widget>
95+
<layoutdefault spacing="6" margin="11"/>
96+
<resources/>
97+
<connections/>
98+
</ui>

0 commit comments

Comments
 (0)