QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
qgsbrowserwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsbrowserwidget.h
3  ---------------------
4  begin : July 2011
5  copyright : (C) 2011 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSBROWSERWIDGET_H
16 #define QGSBROWSERWIDGET_H
17 
18 #include "ui_qgsbrowserwidgetbase.h"
19 #include "qgsmimedatautils.h"
20 #include "qgspanelwidget.h"
21 #include "qgis_gui.h"
22 
23 class QgsBrowserGuiModel;
24 class QgsDockBrowserTreeView;
25 class QgsLayerItem;
26 class QgsDataItem;
28 class QgsMessageBar;
30 
31 class QModelIndex;
32 class QItemSelection;
33 
39 class GUI_EXPORT QgsBrowserWidget : public QgsPanelWidget, private Ui::QgsBrowserWidgetBase
40 {
41  Q_OBJECT
42  public:
43 
49  explicit QgsBrowserWidget( QgsBrowserGuiModel *browserModel, QWidget *parent SIP_TRANSFERTHIS = nullptr );
50  ~QgsBrowserWidget() override;
51 
59  void setMessageBar( QgsMessageBar *bar );
60 
66  QgsMessageBar *messageBar();
67 
78  void setDisabledDataItemsKeys( const QStringList &filter );
79 
80  public slots:
81 
86  void updateProjectHome() SIP_SKIP;
87 
93  void setActiveIndex( const QModelIndex &index ) SIP_SKIP;
94 
98  void refresh();
99 
100  // keep the stable API slim for now!
101 #ifndef SIP_RUN
102 
103  signals:
105  void openFile( const QString &fileName, const QString &fileTypeHint = QString() );
110 
111 #endif
112 
113  protected:
114  void showEvent( QShowEvent *event ) override;
115 
116  private slots:
117  void itemDoubleClicked( const QModelIndex &index );
118  void onOptionsChanged();
119 
121  void showContextMenu( QPoint );
122 
124  void showFilterWidget( bool visible );
126  void enablePropertiesWidget( bool enable );
128  void setFilterSyntax( QAction * );
130  void setCaseSensitive( bool caseSensitive );
132  void setFilter();
133 
135  void addSelectedLayers();
137  void showProperties();
139  void hideItem();
140 
141  private:
143  void selectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
145  void splitterMoved();
147  void refreshModel( const QModelIndex &index );
149  void addLayer( QgsLayerItem *layerItem );
151  void clearPropertiesWidget();
153  void setPropertiesWidget();
154 
156  int selectedItemsCount();
158  QString settingsSection() { return objectName().toLower(); }
159 
160  QgsDataItemGuiContext createContext();
161 
162  QgsDockBrowserTreeView *mBrowserView = nullptr;
163  QgsBrowserGuiModel *mModel = nullptr;
164  QgsBrowserProxyModel *mProxyModel = nullptr;
165  QString mInitPath;
166  bool mPropertiesWidgetEnabled = false;
167  // height fraction
168  float mPropertiesWidgetHeight = 0;
169 
170  QgsMessageBar *mMessageBar = nullptr;
171  QStringList mDisabledDataItemsKeys;
172 
173  friend class QgsBrowserDockWidget;
174 };
175 
176 #endif // QGSBROWSERWIDGET_H
A dock widget containing a QgsBrowserWidget for navigating and managing data sources.
A model for showing available data sources and other items in a structured tree.
A QSortFilterProxyModel subclass for filtering and sorting browser model items.
A widget showing a browser tree view along with toolbar and toggleable properties pane.
void connectionsChanged()
Connections changed in the browser.
void handleDropUriList(const QgsMimeDataUtils::UriList &)
Emitted when drop uri list needs to be handled.
void openFile(const QString &fileName, const QString &fileTypeHint=QString())
Emitted when a file needs to be opened.
Encapsulates the context in which a QgsDataItem is shown within the application GUI.
Base class for all items in the model.
Definition: qgsdataitem.h:46
Item that represents a layer that can be opened with one of the providers.
Definition: qgslayeritem.h:30
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
QList< QgsMimeDataUtils::Uri > UriList
Base class for any widget that can be shown as a inline panel.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_SKIP
Definition: qgis_sip.h:126