1
1
/* **************************************************************************
2
- qgsbrowserdockwidget.h
2
+ qgsbrowserdockwidget_p.h
3
+
4
+ Private classes for QgsBrowserDockWidget
5
+
3
6
---------------------
4
- begin : July 2011
5
- copyright : (C) 2011 by Martin Dobias
6
- email : wonder dot sk at gmail dot com
7
+ begin : May 2017
8
+ copyright : (C) 2017 by Alessandro Pasotti
9
+ real work done by : (C) 2011 by Martin Dobias
10
+ email : a dot pasotti at itopen dot it
7
11
***************************************************************************
8
12
* *
9
13
* This program is free software; you can redistribute it and/or modify *
12
16
* (at your option) any later version. *
13
17
* *
14
18
***************************************************************************/
15
- #ifndef QGSBROWSERDOCKWIDGET_H
16
- #define QGSBROWSERDOCKWIDGET_H
19
+
20
+
21
+ #ifndef QGSBROWSERDOCKWIDGET_P_H
22
+ #define QGSBROWSERDOCKWIDGET_P_H
23
+
24
+ // / @cond PRIVATE
25
+
26
+ //
27
+ // W A R N I N G
28
+ // -------------
29
+ //
30
+ // This file is not part of the QGIS API. It exists purely as an
31
+ // implementation detail. This header file may change from version to
32
+ // version without notice, or even be removed.
33
+ //
34
+
17
35
18
36
#include < ui_qgsbrowserdockwidgetbase.h>
19
37
#include < ui_qgsbrowserlayerpropertiesbase.h>
24
42
#include " qgsbrowsertreeview.h"
25
43
#include " qgsdockwidget.h"
26
44
#include < QSortFilterProxyModel>
27
- #include " qgis_app.h"
28
45
29
46
class QgsBrowserModel ;
30
47
class QModelIndex ;
@@ -33,23 +50,41 @@ class QgsLayerItem;
33
50
class QgsDataItem ;
34
51
class QgsBrowserTreeFilterProxyModel ;
35
52
36
- // hack to show wrapped text without spaces
53
+ /* *
54
+ * Hack to show wrapped text without spaces
55
+ */
37
56
class QgsBrowserPropertiesWrapLabel : public QTextEdit
38
57
{
39
58
Q_OBJECT
40
59
public:
60
+
61
+ /* *
62
+ * Constructor for QgsBrowserPropertiesWrapLabel
63
+ * \param text label text
64
+ * \param parent parent widget
65
+ */
41
66
QgsBrowserPropertiesWrapLabel ( const QString &text, QWidget *parent = nullptr );
42
67
43
68
private slots:
44
69
void adjustHeight ( QSizeF size );
45
70
};
46
71
72
+ /* *
73
+ * The QgsBrowserPropertiesWidget base class
74
+ */
47
75
class QgsBrowserPropertiesWidget : public QWidget
48
76
{
49
77
Q_OBJECT
50
78
public:
79
+
80
+ /* *
81
+ * Constructor for QgsBrowserPropertiesWidget
82
+ * \param parent parent widget
83
+ */
51
84
explicit QgsBrowserPropertiesWidget ( QWidget *parent = nullptr );
85
+ // ! Factory method to create a new browser properties widget
52
86
static QgsBrowserPropertiesWidget *createWidget ( QgsDataItem *item, QWidget *parent = nullptr );
87
+ // ! Stub
53
88
virtual void setItem ( QgsDataItem *item ) { Q_UNUSED ( item ) }
54
89
// ! Set content widget, usually item paramWidget. Takes ownership.
55
90
virtual void setWidget ( QWidget *widget );
@@ -62,137 +97,128 @@ class QgsBrowserPropertiesWidget : public QWidget
62
97
virtual void setCondensedMode ( bool condensedMode ) { Q_UNUSED ( condensedMode ); }
63
98
};
64
99
100
+ /* *
101
+ * The QgsBrowserLayerProperties class
102
+ */
65
103
class QgsBrowserLayerProperties : public QgsBrowserPropertiesWidget , private Ui ::QgsBrowserLayerPropertiesBase
66
104
{
67
105
Q_OBJECT
68
106
public:
107
+
108
+ /* *
109
+ * Constructor for QgsBrowserLayerProperties
110
+ * \param parent parent widget
111
+ */
69
112
explicit QgsBrowserLayerProperties ( QWidget *parent = nullptr );
113
+ // ! Set item
70
114
void setItem ( QgsDataItem *item ) override ;
71
115
116
+ /* * Sets whether the properties widget should display in condensed mode, ie, for display in a dock
117
+ * widget rather than it's own separate dialog.
118
+ * \param condensedMode set to true to enable condensed mode
119
+ * \since QGIS 2.10
120
+ */
72
121
virtual void setCondensedMode ( bool condensedMode ) override ;
73
122
74
123
private:
75
124
QgsBrowserPropertiesWrapLabel *mUriLabel = nullptr ;
76
125
};
77
126
127
+ /* *
128
+ * The QgsBrowserDirectoryProperties class
129
+ */
78
130
class QgsBrowserDirectoryProperties : public QgsBrowserPropertiesWidget , private Ui ::QgsBrowserDirectoryPropertiesBase
79
131
{
80
132
Q_OBJECT
81
133
public:
134
+
135
+ /* *
136
+ * Constructor for QgsBrowserDirectoryProperties
137
+ * \param parent parent widget
138
+ */
82
139
explicit QgsBrowserDirectoryProperties ( QWidget *parent = nullptr );
83
140
141
+ // ! Create widget from the given item and add it
84
142
void setItem ( QgsDataItem *item ) override ;
85
143
private:
86
144
QgsDirectoryParamWidget *mDirectoryWidget = nullptr ;
87
145
QgsBrowserPropertiesWrapLabel *mPathLabel = nullptr ;
88
146
};
89
147
148
+ /* *
149
+ * The QgsBrowserPropertiesDialog class
150
+ */
90
151
class QgsBrowserPropertiesDialog : public QDialog , private Ui ::QgsBrowserPropertiesDialogBase
91
152
{
92
153
Q_OBJECT
93
154
public:
155
+
156
+ /* *
157
+ * Constructor for QgsBrowserPropertiesDialog
158
+ * \param settingsSection prefix for settings (from the object name)
159
+ * \param parent parent widget
160
+ */
94
161
QgsBrowserPropertiesDialog ( const QString &settingsSection, QWidget *parent = nullptr );
95
162
~QgsBrowserPropertiesDialog ();
96
163
164
+ // ! Create dialog from the given item and add it
97
165
void setItem ( QgsDataItem *item );
98
166
99
167
private:
100
168
QgsBrowserPropertiesWidget *mPropertiesWidget = nullptr ;
101
169
QString mSettingsSection ;
102
170
};
103
171
104
- class APP_EXPORT QgsBrowserDockWidget : public QgsDockWidget, private Ui::QgsBrowserDockWidgetBase
105
- {
106
- Q_OBJECT
107
- public:
108
- explicit QgsBrowserDockWidget ( const QString &name, QWidget *parent = nullptr );
109
- ~QgsBrowserDockWidget ();
110
- void addFavoriteDirectory ( const QString &favDir );
111
-
112
- public slots:
113
- void addLayerAtIndex ( const QModelIndex &index );
114
- void showContextMenu ( QPoint );
115
-
116
- void addFavorite ();
117
- void addFavoriteDirectory ();
118
- void removeFavorite ();
119
-
120
- void refresh ();
121
-
122
- void showFilterWidget ( bool visible );
123
- void enablePropertiesWidget ( bool enable );
124
- void setFilterSyntax ( QAction * );
125
- void setCaseSensitive ( bool caseSensitive );
126
- void setFilter ();
127
-
128
- // layer menu items
129
- void addSelectedLayers ();
130
- void showProperties ();
131
- void hideItem ();
132
- void toggleFastScan ();
133
-
134
- void selectionChanged ( const QItemSelection &selected, const QItemSelection &deselected );
135
- void splitterMoved ();
136
-
137
- protected:
138
- void refreshModel ( const QModelIndex &index );
139
- void showEvent ( QShowEvent *event ) override ;
140
- void addLayer ( QgsLayerItem *layerItem );
141
- void clearPropertiesWidget ();
142
- void setPropertiesWidget ();
143
-
144
- int selectedItemsCount ();
145
- QString settingsSection () { return objectName ().toLower (); }
146
-
147
- QgsDockBrowserTreeView *mBrowserView = nullptr ;
148
- QgsBrowserModel *mModel = nullptr ;
149
- QgsBrowserTreeFilterProxyModel *mProxyModel = nullptr ;
150
- QString mInitPath ;
151
- bool mPropertiesWidgetEnabled ;
152
- // height fraction
153
- float mPropertiesWidgetHeight ;
154
-
155
- private:
156
- };
157
-
158
172
159
173
/* *
160
- Utility class for correct drag&drop handling.
161
-
162
- We want to allow user to drag layers to qgis window. At the same time we do not
163
- accept drops of the items on our view - but if we ignore the drag enter action
164
- then qgis application consumes the drag events and it is possible to drop the
165
- items on the tree view although the drop is actually managed by qgis app.
174
+ * Utility class for correct drag&drop handling.
175
+ *
176
+ * We want to allow user to drag layers to qgis window. At the same time we do not
177
+ * accept drops of the items on our view - but if we ignore the drag enter action
178
+ * then qgis application consumes the drag events and it is possible to drop the
179
+ * items on the tree view although the drop is actually managed by qgis app.
166
180
*/
167
181
class QgsDockBrowserTreeView : public QgsBrowserTreeView
168
182
{
169
183
Q_OBJECT
170
184
171
185
public:
172
- explicit QgsDockBrowserTreeView ( QWidget *parent );
173
186
187
+ /* *
188
+ * Constructor for QgsDockBrowserTreeView
189
+ * \param parent parent widget
190
+ */
191
+ explicit QgsDockBrowserTreeView ( QWidget *parent );
192
+ // ! Overrides drag enter event
174
193
void dragEnterEvent ( QDragEnterEvent *e ) override ;
194
+ // ! Overrides drag move event
175
195
void dragMoveEvent ( QDragMoveEvent *e ) override ;
196
+ // ! Overrides drag stop event
176
197
void dropEvent ( QDropEvent *e ) override ;
177
198
};
178
199
179
200
/* *
180
- Utility class for filtering browser items
201
+ * Utility class for filtering browser items
181
202
*/
182
203
class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel
183
204
{
184
205
Q_OBJECT
185
206
public:
186
- explicit QgsBrowserTreeFilterProxyModel ( QObject *parent );
187
207
208
+ /* *
209
+ * Constructor for QgsBrowserTreeFilterProxyModel
210
+ * @param parent parent widget
211
+ */
212
+ explicit QgsBrowserTreeFilterProxyModel ( QObject *parent );
213
+ // ! Set the browser model
188
214
void setBrowserModel ( QgsBrowserModel *model );
189
-
215
+ // ! Set the filter syntax
190
216
void setFilterSyntax ( const QString &syntax );
191
-
217
+ // ! Set the filter
192
218
void setFilter ( const QString &filter );
193
-
219
+ // ! Set case sensitivity
194
220
void setCaseSensitive ( bool caseSensitive );
195
-
221
+ // ! Update filter
196
222
void updateFilter ();
197
223
198
224
protected:
@@ -203,20 +229,23 @@ class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel
203
229
QString mPatternSyntax ;
204
230
Qt::CaseSensitivity mCaseSensitivity ;
205
231
232
+ // ! Filter accepts string
206
233
bool filterAcceptsString ( const QString &value ) const ;
207
234
208
- // It would be better to apply the filer only to expanded (visible) items, but using mapFromSource() + view here was causing strange errors
235
+ // ! It would be better to apply the filer only to expanded (visible) items, but using mapFromSource() + view here was causing strange errors
209
236
bool filterAcceptsRow ( int sourceRow, const QModelIndex &sourceParent ) const override ;
210
237
211
- // returns true if at least one ancestor is accepted by filter
238
+ // ! Returns true if at least one ancestor is accepted by filter
212
239
bool filterAcceptsAncestor ( const QModelIndex &sourceIndex ) const ;
213
240
214
- // returns true if at least one descendant s accepted by filter
241
+ // ! Returns true if at least one descendant s accepted by filter
215
242
bool filterAcceptsDescendant ( const QModelIndex &sourceIndex ) const ;
216
243
217
- // filter accepts item name
244
+ // ! Filter accepts item name
218
245
bool filterAcceptsItem ( const QModelIndex &sourceIndex ) const ;
219
246
};
220
247
221
248
222
- #endif // QGSBROWSERDOCKWIDGET_H
249
+ // / @endcond
250
+
251
+ #endif // QGSBROWSERDOCKWIDGET_P_H
0 commit comments