QGIS API Documentation  3.2.0-Bonn (bc43194)
qgsbrowserdockwidget_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsbrowserdockwidget_p.h
3 
4  Private classes for QgsBrowserDockWidget
5 
6  ---------------------
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
11  ***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  ***************************************************************************/
19 
20 
21 #ifndef QGSBROWSERDOCKWIDGET_P_H
22 #define QGSBROWSERDOCKWIDGET_P_H
23 
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 
35 
36 #include "ui_qgsbrowserdockwidgetbase.h"
37 #include "ui_qgsbrowserlayerpropertiesbase.h"
38 #include "ui_qgsbrowserdirectorypropertiesbase.h"
39 #include "ui_qgsbrowserpropertiesdialogbase.h"
40 
41 #include "qgsdataitem.h"
42 #include "qgsbrowsertreeview.h"
43 #include "qgsdockwidget.h"
44 #include <QSortFilterProxyModel>
45 
46 class QgsBrowserModel;
47 class QModelIndex;
48 class QgsDockBrowserTreeView;
49 class QgsLayerItem;
50 class QgsDataItem;
51 class QgsBrowserTreeFilterProxyModel;
52 
53 #define SIP_NO_FILE
54 
58 class QgsBrowserPropertiesWrapLabel : public QTextEdit
59 {
60  Q_OBJECT
61  public:
62 
68  QgsBrowserPropertiesWrapLabel( const QString &text, QWidget *parent = nullptr );
69 
70  private slots:
71  void adjustHeight( QSizeF size );
72 };
73 
77 class QgsBrowserPropertiesWidget : public QWidget
78 {
79  Q_OBJECT
80  public:
81 
86  explicit QgsBrowserPropertiesWidget( QWidget *parent = nullptr );
88  static QgsBrowserPropertiesWidget *createWidget( QgsDataItem *item, QWidget *parent = nullptr );
90  virtual void setItem( QgsDataItem *item ) { Q_UNUSED( item ) }
92  virtual void setWidget( QWidget *widget );
93 
100  virtual void setCondensedMode( bool condensedMode ) { Q_UNUSED( condensedMode ); }
101 };
102 
106 class QgsBrowserLayerProperties : public QgsBrowserPropertiesWidget, private Ui::QgsBrowserLayerPropertiesBase
107 {
108  Q_OBJECT
109  public:
110 
115  explicit QgsBrowserLayerProperties( QWidget *parent = nullptr );
117  void setItem( QgsDataItem *item ) override;
118 
125  void setCondensedMode( bool condensedMode ) override;
126 
127  private:
128  QgsBrowserPropertiesWrapLabel *mUriLabel = nullptr;
129 };
130 
134 class QgsBrowserDirectoryProperties : public QgsBrowserPropertiesWidget, private Ui::QgsBrowserDirectoryPropertiesBase
135 {
136  Q_OBJECT
137  public:
138 
143  explicit QgsBrowserDirectoryProperties( QWidget *parent = nullptr );
144 
146  void setItem( QgsDataItem *item ) override;
147  private:
148  QgsDirectoryParamWidget *mDirectoryWidget = nullptr;
149  QgsBrowserPropertiesWrapLabel *mPathLabel = nullptr;
150 };
151 
155 class QgsBrowserPropertiesDialog : public QDialog, private Ui::QgsBrowserPropertiesDialogBase
156 {
157  Q_OBJECT
158  public:
159 
165  QgsBrowserPropertiesDialog( const QString &settingsSection, QWidget *parent = nullptr );
166  ~QgsBrowserPropertiesDialog() override;
167 
169  void setItem( QgsDataItem *item );
170 
171  private:
172  QgsBrowserPropertiesWidget *mPropertiesWidget = nullptr;
173  QString mSettingsSection;
174 };
175 
176 
185 class QgsDockBrowserTreeView : public QgsBrowserTreeView
186 {
187  Q_OBJECT
188 
189  public:
190 
195  explicit QgsDockBrowserTreeView( QWidget *parent );
197  void dragEnterEvent( QDragEnterEvent *e ) override;
199  void dragMoveEvent( QDragMoveEvent *e ) override;
201  void dropEvent( QDropEvent *e ) override;
202 
203  private:
204  void setAction( QDropEvent *e );
205 };
206 
210 class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel
211 {
212  Q_OBJECT
213  public:
214 
219  explicit QgsBrowserTreeFilterProxyModel( QObject *parent );
221  void setBrowserModel( QgsBrowserModel *model );
223  QgsBrowserModel *browserModel() { return mModel; }
225  void setFilterSyntax( const QString &syntax );
227  void setFilter( const QString &filter );
229  void setCaseSensitive( bool caseSensitive );
231  void updateFilter();
232 
233  protected:
234 
235  QgsBrowserModel *mModel = nullptr;
236  QString mFilter; //filter string provided
237  QVector<QRegExp> mREList; //list of filters, separated by "|"
238  QString mPatternSyntax;
239  Qt::CaseSensitivity mCaseSensitivity;
240 
242  bool filterAcceptsString( const QString &value ) const;
243 
245  bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override;
246 
248  bool filterAcceptsAncestor( const QModelIndex &sourceIndex ) const;
249 
251  bool filterAcceptsDescendant( const QModelIndex &sourceIndex ) const;
252 
254  bool filterAcceptsItem( const QModelIndex &sourceIndex ) const;
255 };
256 
257 
259 
260 #endif // QGSBROWSERDOCKWIDGET_P_H
The QgsBrowserTreeView class extends QTreeView with save/restore tree state functionality.
Base class for all items in the model.
Definition: qgsdataitem.h:49
A model for showing available data sources and other items in a structured tree.
Item that represents a layer that can be opened with one of the providers.
Definition: qgsdataitem.h:409