-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqgsbrowserdockwidget_p.h
260 lines (215 loc) · 7.84 KB
/
qgsbrowserdockwidget_p.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/***************************************************************************
qgsbrowserdockwidget_p.h
Private classes for QgsBrowserDockWidget
---------------------
begin : May 2017
copyright : (C) 2017 by Alessandro Pasotti
real work done by : (C) 2011 by Martin Dobias
email : a dot pasotti at itopen dot it
***************************************************************************
* *
* 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 QGSBROWSERDOCKWIDGET_P_H
#define QGSBROWSERDOCKWIDGET_P_H
/// @cond PRIVATE
//
// W A R N I N G
// -------------
//
// This file is not part of the QGIS API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
#include "ui_qgsbrowserdockwidgetbase.h"
#include "ui_qgsbrowserlayerpropertiesbase.h"
#include "ui_qgsbrowserdirectorypropertiesbase.h"
#include "ui_qgsbrowserpropertiesdialogbase.h"
#include "qgsdataitem.h"
#include "qgsbrowsertreeview.h"
#include "qgsdockwidget.h"
#include <QSortFilterProxyModel>
class QgsBrowserModel;
class QModelIndex;
class QgsDockBrowserTreeView;
class QgsLayerItem;
class QgsDataItem;
class QgsBrowserTreeFilterProxyModel;
#define SIP_NO_FILE
/**
* Hack to show wrapped text without spaces
*/
class QgsBrowserPropertiesWrapLabel : public QTextEdit
{
Q_OBJECT
public:
/**
* Constructor for QgsBrowserPropertiesWrapLabel
* \param text label text
* \param parent parent widget
*/
QgsBrowserPropertiesWrapLabel( const QString &text, QWidget *parent = nullptr );
private slots:
void adjustHeight( QSizeF size );
};
/**
* The QgsBrowserPropertiesWidget base class
*/
class QgsBrowserPropertiesWidget : public QWidget
{
Q_OBJECT
public:
/**
* Constructor for QgsBrowserPropertiesWidget
* \param parent parent widget
*/
explicit QgsBrowserPropertiesWidget( QWidget *parent = nullptr );
//! Factory method to create a new browser properties widget
static QgsBrowserPropertiesWidget *createWidget( QgsDataItem *item, QWidget *parent = nullptr );
//! Stub
virtual void setItem( QgsDataItem *item ) { Q_UNUSED( item ) }
//! Set content widget, usually item paramWidget. Takes ownership.
virtual void setWidget( QWidget *widget );
/**
* Sets whether the properties widget should display in condensed mode, ie, for display in a dock
* widget rather than it's own separate dialog.
* \param condensedMode set to true to enable condensed mode
* \since QGIS 2.10
*/
virtual void setCondensedMode( bool condensedMode ) { Q_UNUSED( condensedMode ); }
};
/**
* The QgsBrowserLayerProperties class
*/
class QgsBrowserLayerProperties : public QgsBrowserPropertiesWidget, private Ui::QgsBrowserLayerPropertiesBase
{
Q_OBJECT
public:
/**
* Constructor for QgsBrowserLayerProperties
* \param parent parent widget
*/
explicit QgsBrowserLayerProperties( QWidget *parent = nullptr );
//! Set item
void setItem( QgsDataItem *item ) override;
/**
* Sets whether the properties widget should display in condensed mode, ie, for display in a dock
* widget rather than it's own separate dialog.
* \param condensedMode set to true to enable condensed mode
* \since QGIS 2.10
*/
void setCondensedMode( bool condensedMode ) override;
private:
QgsBrowserPropertiesWrapLabel *mUriLabel = nullptr;
};
/**
* The QgsBrowserDirectoryProperties class
*/
class QgsBrowserDirectoryProperties : public QgsBrowserPropertiesWidget, private Ui::QgsBrowserDirectoryPropertiesBase
{
Q_OBJECT
public:
/**
* Constructor for QgsBrowserDirectoryProperties
* \param parent parent widget
*/
explicit QgsBrowserDirectoryProperties( QWidget *parent = nullptr );
//! Create widget from the given item and add it
void setItem( QgsDataItem *item ) override;
private:
QgsDirectoryParamWidget *mDirectoryWidget = nullptr;
QgsBrowserPropertiesWrapLabel *mPathLabel = nullptr;
};
/**
* The QgsBrowserPropertiesDialog class
*/
class QgsBrowserPropertiesDialog : public QDialog, private Ui::QgsBrowserPropertiesDialogBase
{
Q_OBJECT
public:
/**
* Constructor for QgsBrowserPropertiesDialog
* \param settingsSection prefix for settings (from the object name)
* \param parent parent widget
*/
QgsBrowserPropertiesDialog( const QString &settingsSection, QWidget *parent = nullptr );
~QgsBrowserPropertiesDialog() override;
//! Create dialog from the given item and add it
void setItem( QgsDataItem *item );
private:
QgsBrowserPropertiesWidget *mPropertiesWidget = nullptr;
QString mSettingsSection;
};
/**
* Utility class for correct drag&drop handling.
*
* We want to allow user to drag layers to qgis window. At the same time we do not
* accept drops of the items on our view - but if we ignore the drag enter action
* then qgis application consumes the drag events and it is possible to drop the
* items on the tree view although the drop is actually managed by qgis app.
*/
class QgsDockBrowserTreeView : public QgsBrowserTreeView
{
Q_OBJECT
public:
/**
* Constructor for QgsDockBrowserTreeView
* \param parent parent widget
*/
explicit QgsDockBrowserTreeView( QWidget *parent );
//! Overrides drag enter event
void dragEnterEvent( QDragEnterEvent *e ) override;
//! Overrides drag move event
void dragMoveEvent( QDragMoveEvent *e ) override;
//! Overrides drag stop event
void dropEvent( QDropEvent *e ) override;
private:
void setAction( QDropEvent *e );
};
/**
* Utility class for filtering browser items
*/
class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
/**
* Constructor for QgsBrowserTreeFilterProxyModel
* \param parent parent widget
*/
explicit QgsBrowserTreeFilterProxyModel( QObject *parent );
//! Set the browser model
void setBrowserModel( QgsBrowserModel *model );
//! Get the browser model
QgsBrowserModel *browserModel() { return mModel; }
//! Set the filter syntax
void setFilterSyntax( const QString &syntax );
//! Set the filter
void setFilter( const QString &filter );
//! Set case sensitivity
void setCaseSensitive( bool caseSensitive );
//! Update filter
void updateFilter();
protected:
QgsBrowserModel *mModel = nullptr;
QString mFilter; //filter string provided
QVector<QRegExp> mREList; //list of filters, separated by "|"
QString mPatternSyntax;
Qt::CaseSensitivity mCaseSensitivity;
//! Filter accepts string
bool filterAcceptsString( const QString &value ) const;
//! It would be better to apply the filer only to expanded (visible) items, but using mapFromSource() + view here was causing strange errors
bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override;
//! Returns true if at least one ancestor is accepted by filter
bool filterAcceptsAncestor( const QModelIndex &sourceIndex ) const;
//! Returns true if at least one descendant s accepted by filter
bool filterAcceptsDescendant( const QModelIndex &sourceIndex ) const;
//! Filter accepts item name
bool filterAcceptsItem( const QModelIndex &sourceIndex ) const;
};
/// @endcond
#endif // QGSBROWSERDOCKWIDGET_P_H