/
qgsdb2dataitems.h
174 lines (139 loc) · 4.55 KB
/
qgsdb2dataitems.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/***************************************************************************
qgsdb2dataitems.h - Browser Panel object population
--------------------------------------
Date : 2016-01-27
Copyright : (C) 2016 by David Adler
Shirley Xiao, David Nguyen
Email : dadler at adtechgeospatial.com
xshirley2012 at yahoo.com, davidng0123 at gmail.com
****************************************************************************
*
* 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 "qgsdb2provider.h"
#include "qgsdb2tablemodel.h"
#include "qgsdataitem.h"
class QgsDb2RootItem;
class QgsDb2Connection;
class QgsDb2SchemaItem;
class QgsDb2LayerItem;
/**
* \class QgsDb2RootItem
* \brief Browser Panel DB2 root object.
*/
class QgsDb2RootItem : public QgsDataCollectionItem
{
Q_OBJECT
public:
QgsDb2RootItem( QgsDataItem *parent, QString name, QString path );
~QgsDb2RootItem();
/**
* Add saved connections as children.
*/
QVector<QgsDataItem *> createChildren() override;
#ifdef HAVE_GUI
virtual QWidget *paramWidget() override;
QList<QAction *> actions( QWidget *parent ) override;
#endif
public slots:
#ifdef HAVE_GUI
//void connectionsChanged();
void newConnection();
#endif
};
/**
* \class QgsDb2ConnectionItem
* \brief Browser Panel DB2 connection object (under root).
*/
class QgsDb2ConnectionItem : public QgsDataCollectionItem
{
Q_OBJECT
public:
QgsDb2ConnectionItem( QgsDataItem *parent, QString name, QString path );
~QgsDb2ConnectionItem();
static bool ConnInfoFromSettings( const QString connName,
QString &connInfo, QString &errorMsg );
static bool ConnInfoFromParameters(
const QString &service,
const QString &driver,
const QString &host,
const QString &port,
const QString &database,
const QString &username,
const QString &password,
const QString &authcfg,
QString &connInfo,
QString &errorMsg );
/**
* Fetch geometry column data from server and populate Browser Panel with
* schemas and layers.
*/
QVector<QgsDataItem *> createChildren() override;
virtual bool equal( const QgsDataItem *other ) override;
#ifdef HAVE_GUI
QList<QAction *> actions( QWidget *parent ) override;
#endif
virtual bool acceptDrop() override { return true; }
virtual bool handleDrop( const QMimeData *data, Qt::DropAction action ) override;
bool handleDrop( const QMimeData *data, const QString &toSchema );
void refresh() override;
QString connInfo() const { return mConnInfo; }
signals:
void addGeometryColumn( QgsDb2LayerProperty );
public slots:
#ifdef HAVE_GUI
/**
* Refresh with saved connection data.
*/
void refreshConnection();
/**
* Show dialog to edit and save connection data.
*/
void editConnection();
/**
* Delete saved connection data and remove from Browser Panel.
*/
void deleteConnection();
#endif
//void setAllowGeometrylessTables( bool allow );
//void setLayerType( QgsDb2LayerProperty layerProperty );
private:
QString mConnInfo;
void readConnectionSettings();
};
/**
* \class QgsDb2SchemaItem
* \brief Browser Panel DB2 schema object (under connections).
*/
class QgsDb2SchemaItem : public QgsDataCollectionItem
{
Q_OBJECT
public:
QgsDb2SchemaItem( QgsDataItem *parent, QString name, QString path );
~QgsDb2SchemaItem();
QVector<QgsDataItem *> createChildren() override;
QgsDb2LayerItem *addLayer( QgsDb2LayerProperty layerProperty, bool refresh );
void refresh() override {} // do not refresh directly
void addLayers( QgsDataItem *newLayers );
virtual bool acceptDrop() override { return true; }
virtual bool handleDrop( const QMimeData *data, Qt::DropAction action ) override;
};
/**
* \class QgsDb2LayerItem
* \brief Browser Panel DB2 layer object (under schemas).
*/
class QgsDb2LayerItem : public QgsLayerItem
{
Q_OBJECT
public:
QgsDb2LayerItem( QgsDataItem *parent, QString name, QString path, QgsLayerItem::LayerType layerType, QgsDb2LayerProperty layerProperties );
~QgsDb2LayerItem();
QString createUri();
QgsDb2LayerItem *createClone();
private:
QgsDb2LayerProperty mLayerProperty;
};