QGIS API Documentation  3.8.0-Zanzibar (11aff65)
qgsbrowserdockwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsbrowserdockwidget.cpp
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 #include "qgsbrowserdockwidget.h"
16 #include "qgsbrowserdockwidget_p.h"
17 
18 #include <QAbstractTextDocumentLayout>
19 #include <QHeaderView>
20 #include <QTreeView>
21 #include <QMenu>
22 #include <QToolButton>
23 #include <QFileDialog>
24 #include <QPlainTextDocumentLayout>
25 #include <QSortFilterProxyModel>
26 
27 #include "qgsbrowsermodel.h"
28 #include "qgsbrowsertreeview.h"
29 #include "qgslogger.h"
30 #include "qgsrasterlayer.h"
31 #include "qgsvectorlayer.h"
32 #include "qgsproject.h"
33 #include "qgssettings.h"
34 #include "qgsnewnamedialog.h"
35 #include "qgsbrowserproxymodel.h"
36 #include "qgsgui.h"
38 #include "qgsnative.h"
40 #include "qgsdataitemguiprovider.h"
41 
42 // browser layer properties dialog
43 #include "qgsapplication.h"
44 #include "qgsmapcanvas.h"
45 
46 #include <QDragEnterEvent>
47 
48 QgsBrowserDockWidget::QgsBrowserDockWidget( const QString &name, QgsBrowserModel *browserModel, QWidget *parent )
49  : QgsDockWidget( parent )
50  , mModel( browserModel )
51  , mPropertiesWidgetEnabled( false )
52  , mPropertiesWidgetHeight( 0 )
53 {
54  setupUi( this );
55 
56  mContents->layout()->setContentsMargins( 0, 0, 0, 0 );
57  mContents->layout()->setMargin( 0 );
58  static_cast< QVBoxLayout * >( mContents->layout() )->setSpacing( 0 );
59 
60  setWindowTitle( name );
61 
62  mBrowserView = new QgsDockBrowserTreeView( this );
63  mLayoutBrowser->addWidget( mBrowserView );
64 
65  mWidgetFilter->hide();
66  mLeFilter->setPlaceholderText( tr( "Type here to filter visible items…" ) );
67  // icons from http://www.fatcow.com/free-icons License: CC Attribution 3.0
68 
69  QMenu *menu = new QMenu( this );
70  menu->setSeparatorsCollapsible( false );
71  mBtnFilterOptions->setMenu( menu );
72  QAction *action = new QAction( tr( "Case Sensitive" ), menu );
73  action->setData( "case" );
74  action->setCheckable( true );
75  action->setChecked( false );
76  connect( action, &QAction::toggled, this, &QgsBrowserDockWidget::setCaseSensitive );
77  menu->addAction( action );
78  QActionGroup *group = new QActionGroup( menu );
79  action = new QAction( tr( "Filter Pattern Syntax" ), group );
80  action->setSeparator( true );
81  menu->addAction( action );
82  action = new QAction( tr( "Normal" ), group );
83  action->setData( QgsBrowserProxyModel::Normal );
84  action->setCheckable( true );
85  action->setChecked( true );
86  menu->addAction( action );
87  action = new QAction( tr( "Wildcard(s)" ), group );
88  action->setData( QgsBrowserProxyModel::Wildcards );
89  action->setCheckable( true );
90  menu->addAction( action );
91  action = new QAction( tr( "Regular Expression" ), group );
92  action->setData( QgsBrowserProxyModel::RegularExpression );
93  action->setCheckable( true );
94  menu->addAction( action );
95 
96  mBrowserView->setExpandsOnDoubleClick( false );
97 
98  connect( mActionRefresh, &QAction::triggered, this, &QgsBrowserDockWidget::refresh );
99  connect( mActionAddLayers, &QAction::triggered, this, &QgsBrowserDockWidget::addSelectedLayers );
100  connect( mActionCollapse, &QAction::triggered, mBrowserView, &QgsDockBrowserTreeView::collapseAll );
101  connect( mActionShowFilter, &QAction::triggered, this, &QgsBrowserDockWidget::showFilterWidget );
102  connect( mActionPropertiesWidget, &QAction::triggered, this, &QgsBrowserDockWidget::enablePropertiesWidget );
103  connect( mLeFilter, &QgsFilterLineEdit::returnPressed, this, &QgsBrowserDockWidget::setFilter );
104  connect( mLeFilter, &QgsFilterLineEdit::cleared, this, &QgsBrowserDockWidget::setFilter );
105  connect( mLeFilter, &QgsFilterLineEdit::textChanged, this, &QgsBrowserDockWidget::setFilter );
106  connect( group, &QActionGroup::triggered, this, &QgsBrowserDockWidget::setFilterSyntax );
107  connect( mBrowserView, &QgsDockBrowserTreeView::customContextMenuRequested, this, &QgsBrowserDockWidget::showContextMenu );
108  connect( mBrowserView, &QgsDockBrowserTreeView::doubleClicked, this, &QgsBrowserDockWidget::itemDoubleClicked );
109  connect( mSplitter, &QSplitter::splitterMoved, this, &QgsBrowserDockWidget::splitterMoved );
110 }
111 
113 {
114  QgsSettings settings;
115  settings.setValue( settingsSection() + "/propertiesWidgetEnabled", mPropertiesWidgetEnabled );
116  //settings.setValue(settingsSection() + "/propertiesWidgetHeight", mPropertiesWidget->size().height() );
117  settings.setValue( settingsSection() + "/propertiesWidgetHeight", mPropertiesWidgetHeight );
118 }
119 
120 void QgsBrowserDockWidget::showEvent( QShowEvent *e )
121 {
122  // delayed initialization of the model
123  if ( !mModel->initialized( ) )
124  {
125  mModel->initialize();
126  }
127  if ( ! mProxyModel )
128  {
129  mProxyModel = new QgsBrowserProxyModel( this );
130  mProxyModel->setBrowserModel( mModel );
131  mBrowserView->setSettingsSection( objectName().toLower() ); // to distinguish 2 or more instances of the browser
132  mBrowserView->setBrowserModel( mModel );
133  mBrowserView->setModel( mProxyModel );
134  mBrowserView->setSortingEnabled( true );
135  mBrowserView->sortByColumn( 0, Qt::AscendingOrder );
136  // provide a horizontal scroll bar instead of using ellipse (...) for longer items
137  mBrowserView->setTextElideMode( Qt::ElideNone );
138  mBrowserView->header()->setSectionResizeMode( 0, QHeaderView::ResizeToContents );
139  mBrowserView->header()->setStretchLastSection( false );
140 
141  // selectionModel is created when model is set on tree
142  connect( mBrowserView->selectionModel(), &QItemSelectionModel::selectionChanged,
144 
145  // Forward the model changed signals to the widget
146  connect( mModel, &QgsBrowserModel::connectionsChanged,
148 
149 
150  // objectName used by settingsSection() is not yet set in constructor
151  QgsSettings settings;
152  mPropertiesWidgetEnabled = settings.value( settingsSection() + "/propertiesWidgetEnabled", false ).toBool();
153  mActionPropertiesWidget->setChecked( mPropertiesWidgetEnabled );
154  mPropertiesWidget->setVisible( false ); // false until item is selected
155 
156  mPropertiesWidgetHeight = settings.value( settingsSection() + "/propertiesWidgetHeight" ).toFloat();
157  QList<int> sizes = mSplitter->sizes();
158  int total = sizes.value( 0 ) + sizes.value( 1 );
159  int height = static_cast<int>( total * mPropertiesWidgetHeight );
160  sizes.clear();
161  sizes << total - height << height;
162  mSplitter->setSizes( sizes );
163  }
164 
166 }
167 
168 void QgsBrowserDockWidget::itemDoubleClicked( const QModelIndex &index )
169 {
170  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( index ) );
171  if ( !item )
172  return;
173 
174  QgsDataItemGuiContext context = createContext();
175 
176  const QList< QgsDataItemGuiProvider * > providers = QgsGui::instance()->dataItemGuiProviderRegistry()->providers();
177  for ( QgsDataItemGuiProvider *provider : providers )
178  {
179  if ( provider->handleDoubleClick( item, context ) )
180  return;
181  }
182 
183  // if no providers overrode the double-click handling for this item, we give the item itself a chance
184  if ( !item->handleDoubleClick() )
185  {
186  // double-click not handled by browser model, so use as default view expand behavior
187  if ( mBrowserView->isExpanded( index ) )
188  mBrowserView->collapse( index );
189  else
190  mBrowserView->expand( index );
191  }
192 }
193 
195 {
196  QModelIndex index = mProxyModel->mapToSource( mBrowserView->indexAt( pt ) );
197  QgsDataItem *item = mModel->dataItem( index );
198  if ( !item )
199  return;
200 
201  const QModelIndexList selection = mBrowserView->selectionModel()->selectedIndexes();
202  QList< QgsDataItem * > selectedItems;
203  selectedItems.reserve( selection.size() );
204  for ( const QModelIndex &selectedIndex : selection )
205  {
206  QgsDataItem *selectedItem = mProxyModel->dataItem( selectedIndex );
207  if ( selectedItem )
208  selectedItems << selectedItem;
209  }
210 
211  QMenu *menu = new QMenu( this );
212 
213  const QList<QMenu *> menus = item->menus( menu );
214  QList<QAction *> actions = item->actions( menu );
215 
216  if ( !menus.isEmpty() )
217  {
218  for ( QMenu *mn : menus )
219  {
220  menu->addMenu( mn );
221  }
222  }
223 
224  if ( !actions.isEmpty() )
225  {
226  if ( !menu->actions().isEmpty() )
227  menu->addSeparator();
228  // add action to the menu
229  menu->addActions( actions );
230  }
231 
232  QgsDataItemGuiContext context = createContext();
233 
234  const QList< QgsDataItemGuiProvider * > providers = QgsGui::instance()->dataItemGuiProviderRegistry()->providers();
235  for ( QgsDataItemGuiProvider *provider : providers )
236  {
237  provider->populateContextMenu( item, menu, selectedItems, context );
238  }
239 
240  if ( menu->actions().isEmpty() )
241  {
242  delete menu;
243  return;
244  }
245 
246  menu->popup( mBrowserView->mapToGlobal( pt ) );
247 }
248 
250 {
251  QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() );
252  QgsDataItem *item = mModel->dataItem( index );
253  if ( !item )
254  return;
255 
256  QgsDirectoryItem *dirItem = qobject_cast<QgsDirectoryItem *>( item );
257  if ( !dirItem )
258  return;
259 
261  addFavoriteDirectory( dirItem->dirPath() );
263 }
264 
266 {
267  QString directory = QFileDialog::getExistingDirectory( this, tr( "Add directory to favorites" ) );
268  if ( !directory.isEmpty() )
269  {
271  addFavoriteDirectory( directory );
273  }
274 }
275 
276 void QgsBrowserDockWidget::addFavoriteDirectory( const QString &favDir, const QString &name )
277 {
278  mModel->addFavoriteDirectory( favDir, name );
279 }
280 
282 {
283  mMessageBar = bar;
284 }
285 
287 {
288  return mMessageBar;
289 }
290 
292 {
293  mModel->removeFavorite( mProxyModel->mapToSource( mBrowserView->currentIndex() ) );
294 }
295 
297 {
298  refreshModel( QModelIndex() );
299 }
300 
301 void QgsBrowserDockWidget::refreshModel( const QModelIndex &index )
302 {
303  if ( mModel && mProxyModel )
304  {
305  QgsDataItem *item = mModel->dataItem( index );
306  if ( item )
307  {
308  QgsDebugMsgLevel( "path = " + item->path(), 4 );
309  }
310  else
311  {
312  QgsDebugMsgLevel( QStringLiteral( "invalid item" ), 4 );
313  }
314 
315  if ( item && ( item->capabilities2() & QgsDataItem::Fertile ) )
316  {
317  mModel->refresh( index );
318  }
319 
320  for ( int i = 0; i < mModel->rowCount( index ); i++ )
321  {
322  QModelIndex idx = mModel->index( i, 0, index );
323  QModelIndex proxyIdx = mProxyModel->mapFromSource( idx );
324  QgsDataItem *child = mModel->dataItem( idx );
325 
326  // Check also expanded descendants so that the whole expanded path does not get collapsed if one item is collapsed.
327  // Fast items (usually root items) are refreshed so that when collapsed, it is obvious they are if empty (no expand symbol).
328  if ( mBrowserView->isExpanded( proxyIdx ) || mBrowserView->hasExpandedDescendant( proxyIdx ) || ( child && child->capabilities2() & QgsDataItem::Fast ) )
329  {
330  refreshModel( idx );
331  }
332  else
333  {
334  if ( child && ( child->capabilities2() & QgsDataItem::Fertile ) )
335  {
336  child->depopulate();
337  }
338  }
339  }
340  }
341 }
342 
343 void QgsBrowserDockWidget::addLayer( QgsLayerItem *layerItem )
344 {
345  if ( !layerItem )
346  return;
347 
349  list << layerItem->mimeUri();
350  emit handleDropUriList( list );
351 }
352 
353 bool QgsBrowserDockWidget::addLayerAtIndex( const QModelIndex &index )
354 {
355  QgsDebugMsg( QStringLiteral( "rowCount() = %1" ).arg( mModel->rowCount( mProxyModel->mapToSource( index ) ) ) );
356  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( index ) );
357 
358  if ( item && item->type() == QgsDataItem::Project )
359  {
360  QgsProjectItem *projectItem = qobject_cast<QgsProjectItem *>( item );
361  if ( projectItem )
362  {
363  QApplication::setOverrideCursor( Qt::WaitCursor );
364  emit openFile( projectItem->path(), QStringLiteral( "project" ) );
365  QApplication::restoreOverrideCursor();
366  }
367  return true;
368  }
369  else if ( item && item->type() == QgsDataItem::Layer )
370  {
371  QgsLayerItem *layerItem = qobject_cast<QgsLayerItem *>( item );
372  if ( layerItem )
373  {
374  QApplication::setOverrideCursor( Qt::WaitCursor );
375  addLayer( layerItem );
376  QApplication::restoreOverrideCursor();
377  }
378  return true;
379  }
380  return false;
381 }
382 
384 {
385  QApplication::setOverrideCursor( Qt::WaitCursor );
386 
387  // get a sorted list of selected indexes
388  QModelIndexList list = mBrowserView->selectionModel()->selectedIndexes();
389  std::sort( list.begin(), list.end() );
390 
391  // If any of the layer items are QGIS we just open and exit the loop
392  const auto constList = list;
393  for ( const QModelIndex &index : constList )
394  {
395  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( index ) );
396  if ( item && item->type() == QgsDataItem::Project )
397  {
398  QgsProjectItem *projectItem = qobject_cast<QgsProjectItem *>( item );
399  if ( projectItem )
400  emit openFile( projectItem->path(), QStringLiteral( "project" ) );
401 
402  QApplication::restoreOverrideCursor();
403  return;
404  }
405  }
406 
407  // add items in reverse order so they are in correct order in the layers dock
408  for ( int i = list.size() - 1; i >= 0; i-- )
409  {
410  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( list[i] ) );
411  if ( item && item->type() == QgsDataItem::Layer )
412  {
413  QgsLayerItem *layerItem = qobject_cast<QgsLayerItem *>( item );
414  if ( layerItem )
415  addLayer( layerItem );
416  }
417  }
418 
419  QApplication::restoreOverrideCursor();
420 }
421 
423 {
424  QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() );
425  QgsDataItem *item = mModel->dataItem( index );
426  if ( ! item )
427  return;
428 
429  if ( item->type() == QgsDataItem::Directory )
430  {
431  mModel->hidePath( item );
432  }
433 }
434 
436 {
437  QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() );
438  QgsDataItem *item = mModel->dataItem( index );
439  if ( ! item )
440  return;
441 
442  if ( item->type() == QgsDataItem::Layer || item->type() == QgsDataItem::Directory )
443  {
444  QgsBrowserPropertiesDialog *dialog = new QgsBrowserPropertiesDialog( settingsSection(), this );
445  dialog->setAttribute( Qt::WA_DeleteOnClose );
446  dialog->setItem( item );
447  dialog->show();
448  }
449 }
450 
452 {
453  QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() );
454  QgsDataItem *item = mModel->dataItem( index );
455  if ( ! item )
456  return;
457 
458  if ( item->type() == QgsDataItem::Directory )
459  {
460  QgsSettings settings;
461  QStringList fastScanDirs = settings.value( QStringLiteral( "qgis/scanItemsFastScanUris" ),
462  QStringList() ).toStringList();
463  int idx = fastScanDirs.indexOf( item->path() );
464  if ( idx != -1 )
465  {
466  fastScanDirs.removeAt( idx );
467  }
468  else
469  {
470  fastScanDirs << item->path();
471  }
472  settings.setValue( QStringLiteral( "qgis/scanItemsFastScanUris" ), fastScanDirs );
473  }
474 }
475 
477 {
478  mWidgetFilter->setVisible( visible );
479  if ( ! visible )
480  {
481  mLeFilter->setText( QString() );
482  setFilter();
483  }
484  else
485  {
486  mLeFilter->setFocus();
487  }
488 }
489 
491 {
492  QString filter = mLeFilter->text();
493  if ( mProxyModel )
494  mProxyModel->setFilterString( filter );
495 }
496 
498 {
499  if ( mModel )
500  mModel->updateProjectHome();
501 }
502 
504 {
505  if ( !action || ! mProxyModel )
506  return;
507 
508  mProxyModel->setFilterSyntax( static_cast< QgsBrowserProxyModel::FilterSyntax >( action->data().toInt() ) );
509 }
510 
511 void QgsBrowserDockWidget::setCaseSensitive( bool caseSensitive )
512 {
513  if ( ! mProxyModel )
514  return;
515  mProxyModel->setFilterCaseSensitivity( caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive );
516 }
517 
518 int QgsBrowserDockWidget::selectedItemsCount()
519 {
520  QItemSelectionModel *selectionModel = mBrowserView->selectionModel();
521  if ( selectionModel )
522  {
523  return selectionModel->selectedIndexes().size();
524  }
525  return 0;
526 }
527 
528 QgsDataItemGuiContext QgsBrowserDockWidget::createContext()
529 {
530  QgsDataItemGuiContext context;
531  context.setMessageBar( mMessageBar );
532  return context;
533 }
534 
535 void QgsBrowserDockWidget::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
536 {
537  Q_UNUSED( selected )
538  Q_UNUSED( deselected )
539  if ( mPropertiesWidgetEnabled )
540  {
541  setPropertiesWidget();
542  }
543 }
544 
545 void QgsBrowserDockWidget::clearPropertiesWidget()
546 {
547  while ( mPropertiesLayout->count() > 0 )
548  {
549  delete mPropertiesLayout->itemAt( 0 )->widget();
550  }
551  mPropertiesWidget->setVisible( false );
552 }
553 
554 void QgsBrowserDockWidget::setPropertiesWidget()
555 {
556  clearPropertiesWidget();
557  QItemSelectionModel *selectionModel = mBrowserView->selectionModel();
558  if ( selectionModel )
559  {
560  QModelIndexList indexes = selectionModel->selectedIndexes();
561  if ( indexes.size() == 1 )
562  {
563  QModelIndex index = mProxyModel->mapToSource( indexes.value( 0 ) );
564  QgsDataItem *item = mModel->dataItem( index );
565  QgsBrowserPropertiesWidget *propertiesWidget = QgsBrowserPropertiesWidget::createWidget( item, mPropertiesWidget );
566  if ( propertiesWidget )
567  {
568  propertiesWidget->setCondensedMode( true );
569  mPropertiesLayout->addWidget( propertiesWidget );
570  }
571  }
572  }
573  mPropertiesWidget->setVisible( mPropertiesLayout->count() > 0 );
574 }
575 
577 {
578  mPropertiesWidgetEnabled = enable;
579  if ( enable && selectedItemsCount() == 1 )
580  {
581  setPropertiesWidget();
582  }
583  else
584  {
585  clearPropertiesWidget();
586  }
587 }
588 
590 {
591  QList<int> sizes = mSplitter->sizes();
592  float total = sizes.value( 0 ) + sizes.value( 1 );
593  mPropertiesWidgetHeight = total > 0 ? sizes.value( 1 ) / total : 0;
594 }
virtual QList< QMenu * > menus(QWidget *parent)
Returns the list of menus available for this item.
QString path() const
Definition: qgsdataitem.h:293
Q_DECL_DEPRECATED void toggleFastScan()
Toggle fast scan.
void addSelectedLayers()
Add selected layers to the project.
void connectionsChanged()
Connections changed in the browser, forwarded to the widget and used to notify the provider dialogs o...
void hidePath(QgsDataItem *item)
Hide the given path in the browser model.
This class is a composition of two QSettings instances:
Definition: qgssettings.h:58
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
static QgsDataItemGuiProviderRegistry * dataItemGuiProviderRegistry()
Returns the global data item GUI provider registry, used for tracking providers which affect the brow...
Definition: qgsgui.cpp:99
Q_DECL_DEPRECATED void addFavoriteDirectory()
Add directory from file dialog to favorite.
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:624
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:45
void setBrowserModel(QgsBrowserModel *model)
Sets the underlying browser model.
Type type() const
Definition: qgsdataitem.h:265
virtual void depopulate()
Remove children recursively and set as not populated. This is used when refreshing collapsed items...
QList< QgsDataItemGuiProvider * > providers() const
Returns the list of available providers.
static QgsGui * instance()
Returns a pointer to the singleton instance.
Definition: qgsgui.cpp:48
void setFilterSyntax(FilterSyntax syntax)
Sets the filter syntax.
void enablePropertiesWidget(bool enable)
Enable/disable properties widget.
void hideItem()
Hide current item.
void showEvent(QShowEvent *event) override
Show event override.
bool initialized() const
Returns true if the model has been initialized.
void setFilter()
Apply filter to the model.
void showContextMenu(QPoint)
Show context menu.
Q_DECL_DEPRECATED void addFavorite()
Add current item to favorite.
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QgsDockWidget subclass with more fine-grained control over how the widget is closed or opened...
Definition: qgsdockwidget.h:31
virtual bool handleDoubleClick()
Called when a user double clicks on the item.
void setFilterString(const QString &filter)
Sets the filter string to use when filtering items in the model.
void initialize()
Delayed initialization, needed because the provider registry must be already populated.
QgsDataItem * dataItem(const QModelIndex &idx) const
Returns the data item at the specified index, or nullptr if no item exists at the index...
void removeFavorite(const QModelIndex &index)
Removes a favorite directory from its corresponding model index.
void handleDropUriList(const QgsMimeDataUtils::UriList &)
Emitted when drop uri list needs to be handled.
Abstract base class for providers which affect how QgsDataItem items behave within the application GU...
void setFilterSyntax(QAction *)
Sets filter syntax.
void setFilterCaseSensitivity(Qt::CaseSensitivity sensitivity)
Sets whether item filtering should be case sensitive.
A directory: contains subdirectories and layers.
Definition: qgsdataitem.h:590
void showEvent(QShowEvent *event) override
void showProperties()
Show the layer properties.
Base class for all items in the model.
Definition: qgsdataitem.h:49
QgsBrowserDockWidget(const QString &name, QgsBrowserModel *browserModel, QWidget *parent=nullptr)
Constructor for QgsBrowserDockWidget.
Encapsulates the context in which a QgsDataItem is shown within the application GUI.
void splitterMoved()
Splitter has been moved.
Can create children. Even items without this capability may have children, but cannot create them...
Definition: qgsdataitem.h:211
void setCaseSensitive(bool caseSensitive)
Sets filter case sensitivity.
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:625
Q_DECL_DEPRECATED void removeFavorite()
Remove from favorite.
void addFavoriteDirectory(const QString &directory, const QString &name=QString())
Adds a directory to the favorites group.
void updateProjectHome()
Update project home directory.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
QgsMimeDataUtils::Uri mimeUri() const override
Returns mime URI for the data item.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
void setMessageBar(QgsMessageBar *bar)
Sets the associated message bar.
void cleared()
Emitted when the widget is cleared.
void showFilterWidget(bool visible)
Show/hide filter widget.
virtual QList< QAction * > actions(QWidget *parent)
Returns the list of actions available for this item.
QString dirPath() const
Returns the full path to the directory the item represents.
Definition: qgsdataitem.h:612
void setMessageBar(QgsMessageBar *bar)
Sets a message bar to use alongside the dock widget.
void refresh(const QString &path)
Refresh item specified by path.
Standard string filtering.
A QSortFilterProxyModel subclass for filtering and sorting browser model items.
QList< QgsMimeDataUtils::Uri > UriList
Represents a QGIS project.
Definition: qgsdataitem.h:83
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:436
void openFile(const QString &fileName, const QString &fileTypeHint=QString())
Emitted when a file needs to be opened.
void connectionsChanged()
Connections changed in the browser.
void refresh()
Refresh browser view model (and view)
Data item that can be used to represent QGIS projects.
Definition: qgsdataitem.h:641
QgsMessageBar * messageBar()
Returns the message bar associated with the dock.
QgsDataItem * dataItem(const QModelIndex &index) const
Returns the data item at the specified proxy index, or nullptr if no item exists at the index...
Q_DECL_DEPRECATED bool addLayerAtIndex(const QModelIndex &index)
Adds the layer corresponding to the specified model index.
CreateChildren() is fast enough to be run in main thread when refreshing items, most root items (wms...
Definition: qgsdataitem.h:212
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Selection has changed.
virtual Capabilities capabilities2() const
Returns the capabilities for the data item.
Definition: qgsdataitem.h:249