QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 "qgsbrowserguimodel.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, QgsBrowserGuiModel *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  static_cast< QVBoxLayout * >( mContents->layout() )->setSpacing( 0 );
58 
59  setWindowTitle( name );
60 
61  mBrowserView = new QgsDockBrowserTreeView( this );
62  mLayoutBrowser->addWidget( mBrowserView );
63 
64  mWidgetFilter->hide();
65  mLeFilter->setPlaceholderText( tr( "Type here to filter visible items…" ) );
66  // icons from http://www.fatcow.com/free-icons License: CC Attribution 3.0
67 
68  QMenu *menu = new QMenu( this );
69  menu->setSeparatorsCollapsible( false );
70  mBtnFilterOptions->setMenu( menu );
71  QAction *action = new QAction( tr( "Case Sensitive" ), menu );
72  action->setData( "case" );
73  action->setCheckable( true );
74  action->setChecked( false );
75  connect( action, &QAction::toggled, this, &QgsBrowserDockWidget::setCaseSensitive );
76  menu->addAction( action );
77  QActionGroup *group = new QActionGroup( menu );
78  action = new QAction( tr( "Filter Pattern Syntax" ), group );
79  action->setSeparator( true );
80  menu->addAction( action );
81  action = new QAction( tr( "Normal" ), group );
82  action->setData( QgsBrowserProxyModel::Normal );
83  action->setCheckable( true );
84  action->setChecked( true );
85  menu->addAction( action );
86  action = new QAction( tr( "Wildcard(s)" ), group );
87  action->setData( QgsBrowserProxyModel::Wildcards );
88  action->setCheckable( true );
89  menu->addAction( action );
90  action = new QAction( tr( "Regular Expression" ), group );
91  action->setData( QgsBrowserProxyModel::RegularExpression );
92  action->setCheckable( true );
93  menu->addAction( action );
94 
95  mBrowserView->setExpandsOnDoubleClick( false );
96 
97  connect( mActionRefresh, &QAction::triggered, this, &QgsBrowserDockWidget::refresh );
98  connect( mActionAddLayers, &QAction::triggered, this, &QgsBrowserDockWidget::addSelectedLayers );
99  connect( mActionCollapse, &QAction::triggered, mBrowserView, &QgsDockBrowserTreeView::collapseAll );
100  connect( mActionShowFilter, &QAction::triggered, this, &QgsBrowserDockWidget::showFilterWidget );
101  connect( mActionPropertiesWidget, &QAction::triggered, this, &QgsBrowserDockWidget::enablePropertiesWidget );
102  connect( mLeFilter, &QgsFilterLineEdit::returnPressed, this, &QgsBrowserDockWidget::setFilter );
103  connect( mLeFilter, &QgsFilterLineEdit::cleared, this, &QgsBrowserDockWidget::setFilter );
104  connect( mLeFilter, &QgsFilterLineEdit::textChanged, this, &QgsBrowserDockWidget::setFilter );
105  connect( group, &QActionGroup::triggered, this, &QgsBrowserDockWidget::setFilterSyntax );
106  connect( mBrowserView, &QgsDockBrowserTreeView::customContextMenuRequested, this, &QgsBrowserDockWidget::showContextMenu );
107  connect( mBrowserView, &QgsDockBrowserTreeView::doubleClicked, this, &QgsBrowserDockWidget::itemDoubleClicked );
108  connect( mSplitter, &QSplitter::splitterMoved, this, &QgsBrowserDockWidget::splitterMoved );
109 }
110 
112 {
113  QgsSettings settings;
114  settings.setValue( settingsSection() + "/propertiesWidgetEnabled", mPropertiesWidgetEnabled );
115  //settings.setValue(settingsSection() + "/propertiesWidgetHeight", mPropertiesWidget->size().height() );
116  settings.setValue( settingsSection() + "/propertiesWidgetHeight", mPropertiesWidgetHeight );
117 }
118 
119 void QgsBrowserDockWidget::showEvent( QShowEvent *e )
120 {
121  // delayed initialization of the model
122  if ( !mModel->initialized( ) )
123  {
124  mModel->initialize();
125  }
126  if ( ! mProxyModel )
127  {
128  mProxyModel = new QgsBrowserProxyModel( this );
129  mProxyModel->setBrowserModel( mModel );
130  mProxyModel->setHiddenDataItemProviderKeyFilter( mDisabledDataItemsKeys );
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  mModel->setMessageBar( bar );
285 }
286 
288 {
289  return mMessageBar;
290 }
291 
292 void QgsBrowserDockWidget::setDisabledDataItemsKeys( const QStringList &filter )
293 {
294  mDisabledDataItemsKeys = filter;
295 
296  if ( !mProxyModel )
297  return;
298 
299  mProxyModel->setHiddenDataItemProviderKeyFilter( mDisabledDataItemsKeys );
300 }
301 
303 {
304  mModel->removeFavorite( mProxyModel->mapToSource( mBrowserView->currentIndex() ) );
305 }
306 
308 {
309  refreshModel( QModelIndex() );
310 }
311 
312 void QgsBrowserDockWidget::refreshModel( const QModelIndex &index )
313 {
314  if ( mModel && mProxyModel )
315  {
316  QgsDataItem *item = mModel->dataItem( index );
317  if ( item )
318  {
319  QgsDebugMsgLevel( "path = " + item->path(), 4 );
320  }
321  else
322  {
323  QgsDebugMsgLevel( QStringLiteral( "invalid item" ), 4 );
324  }
325 
326  if ( item && ( item->capabilities2() & QgsDataItem::Fertile ) )
327  {
328  mModel->refresh( index );
329  }
330 
331  for ( int i = 0; i < mModel->rowCount( index ); i++ )
332  {
333  QModelIndex idx = mModel->index( i, 0, index );
334  QModelIndex proxyIdx = mProxyModel->mapFromSource( idx );
335  QgsDataItem *child = mModel->dataItem( idx );
336 
337  // Check also expanded descendants so that the whole expanded path does not get collapsed if one item is collapsed.
338  // Fast items (usually root items) are refreshed so that when collapsed, it is obvious they are if empty (no expand symbol).
339  if ( mBrowserView->isExpanded( proxyIdx ) || mBrowserView->hasExpandedDescendant( proxyIdx ) || ( child && child->capabilities2() & QgsDataItem::Fast ) )
340  {
341  refreshModel( idx );
342  }
343  else
344  {
345  if ( child && ( child->capabilities2() & QgsDataItem::Fertile ) )
346  {
347  child->depopulate();
348  }
349  }
350  }
351  }
352 }
353 
354 void QgsBrowserDockWidget::addLayer( QgsLayerItem *layerItem )
355 {
356  if ( !layerItem )
357  return;
358 
360  list << layerItem->mimeUri();
361  emit handleDropUriList( list );
362 }
363 
364 bool QgsBrowserDockWidget::addLayerAtIndex( const QModelIndex &index )
365 {
366  QgsDebugMsg( QStringLiteral( "rowCount() = %1" ).arg( mModel->rowCount( mProxyModel->mapToSource( index ) ) ) );
367  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( index ) );
368 
369  if ( item && item->type() == QgsDataItem::Project )
370  {
371  QgsProjectItem *projectItem = qobject_cast<QgsProjectItem *>( item );
372  if ( projectItem )
373  {
374  QApplication::setOverrideCursor( Qt::WaitCursor );
375  emit openFile( projectItem->path(), QStringLiteral( "project" ) );
376  QApplication::restoreOverrideCursor();
377  }
378  return true;
379  }
380  else if ( item && item->type() == QgsDataItem::Layer )
381  {
382  QgsLayerItem *layerItem = qobject_cast<QgsLayerItem *>( item );
383  if ( layerItem )
384  {
385  QApplication::setOverrideCursor( Qt::WaitCursor );
386  addLayer( layerItem );
387  QApplication::restoreOverrideCursor();
388  }
389  return true;
390  }
391  return false;
392 }
393 
395 {
396  QApplication::setOverrideCursor( Qt::WaitCursor );
397 
398  // get a sorted list of selected indexes
399  QModelIndexList list = mBrowserView->selectionModel()->selectedIndexes();
400  std::sort( list.begin(), list.end() );
401 
402  // If any of the layer items are QGIS we just open and exit the loop
403  const auto constList = list;
404  for ( const QModelIndex &index : constList )
405  {
406  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( index ) );
407  if ( item && item->type() == QgsDataItem::Project )
408  {
409  QgsProjectItem *projectItem = qobject_cast<QgsProjectItem *>( item );
410  if ( projectItem )
411  emit openFile( projectItem->path(), QStringLiteral( "project" ) );
412 
413  QApplication::restoreOverrideCursor();
414  return;
415  }
416  }
417 
418  // add items in reverse order so they are in correct order in the layers dock
419  for ( int i = list.size() - 1; i >= 0; i-- )
420  {
421  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( list[i] ) );
422  if ( item && item->type() == QgsDataItem::Layer )
423  {
424  QgsLayerItem *layerItem = qobject_cast<QgsLayerItem *>( item );
425  if ( layerItem )
426  addLayer( layerItem );
427  }
428  }
429 
430  QApplication::restoreOverrideCursor();
431 }
432 
434 {
435  QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() );
436  QgsDataItem *item = mModel->dataItem( index );
437  if ( ! item )
438  return;
439 
440  if ( item->type() == QgsDataItem::Directory )
441  {
442  mModel->hidePath( item );
443  }
444 }
445 
447 {
448  QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() );
449  QgsDataItem *item = mModel->dataItem( index );
450  if ( ! item )
451  return;
452 
453  if ( item->type() == QgsDataItem::Layer || item->type() == QgsDataItem::Directory )
454  {
455  QgsBrowserPropertiesDialog *dialog = new QgsBrowserPropertiesDialog( settingsSection(), this );
456  dialog->setAttribute( Qt::WA_DeleteOnClose );
457  dialog->setItem( item, createContext() );
458  dialog->show();
459  }
460 }
461 
463 {
464  QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() );
465  QgsDataItem *item = mModel->dataItem( index );
466  if ( ! item )
467  return;
468 
469  if ( item->type() == QgsDataItem::Directory )
470  {
471  QgsSettings settings;
472  QStringList fastScanDirs = settings.value( QStringLiteral( "qgis/scanItemsFastScanUris" ),
473  QStringList() ).toStringList();
474  int idx = fastScanDirs.indexOf( item->path() );
475  if ( idx != -1 )
476  {
477  fastScanDirs.removeAt( idx );
478  }
479  else
480  {
481  fastScanDirs << item->path();
482  }
483  settings.setValue( QStringLiteral( "qgis/scanItemsFastScanUris" ), fastScanDirs );
484  }
485 }
486 
488 {
489  mWidgetFilter->setVisible( visible );
490  if ( ! visible )
491  {
492  mLeFilter->setText( QString() );
493  setFilter();
494  }
495  else
496  {
497  mLeFilter->setFocus();
498  }
499 }
500 
502 {
503  QString filter = mLeFilter->text();
504  if ( mProxyModel )
505  mProxyModel->setFilterString( filter );
506 }
507 
509 {
510  if ( mModel )
511  mModel->updateProjectHome();
512 }
513 
515 {
516  if ( !action || ! mProxyModel )
517  return;
518 
519  mProxyModel->setFilterSyntax( static_cast< QgsBrowserProxyModel::FilterSyntax >( action->data().toInt() ) );
520 }
521 
522 void QgsBrowserDockWidget::setCaseSensitive( bool caseSensitive )
523 {
524  if ( ! mProxyModel )
525  return;
526  mProxyModel->setFilterCaseSensitivity( caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive );
527 }
528 
529 int QgsBrowserDockWidget::selectedItemsCount()
530 {
531  QItemSelectionModel *selectionModel = mBrowserView->selectionModel();
532  if ( selectionModel )
533  {
534  return selectionModel->selectedIndexes().size();
535  }
536  return 0;
537 }
538 
539 QgsDataItemGuiContext QgsBrowserDockWidget::createContext()
540 {
541  QgsDataItemGuiContext context;
542  context.setMessageBar( mMessageBar );
543  return context;
544 }
545 
546 void QgsBrowserDockWidget::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
547 {
548  Q_UNUSED( selected )
549  Q_UNUSED( deselected )
550  if ( mPropertiesWidgetEnabled )
551  {
552  setPropertiesWidget();
553  }
554 }
555 
556 void QgsBrowserDockWidget::clearPropertiesWidget()
557 {
558  while ( mPropertiesLayout->count() > 0 )
559  {
560  delete mPropertiesLayout->itemAt( 0 )->widget();
561  }
562  mPropertiesWidget->setVisible( false );
563 }
564 
565 void QgsBrowserDockWidget::setPropertiesWidget()
566 {
567  clearPropertiesWidget();
568  QItemSelectionModel *selectionModel = mBrowserView->selectionModel();
569  if ( selectionModel )
570  {
571  QModelIndexList indexes = selectionModel->selectedIndexes();
572  if ( indexes.size() == 1 )
573  {
574  QModelIndex index = mProxyModel->mapToSource( indexes.value( 0 ) );
575  QgsDataItem *item = mModel->dataItem( index );
576  QgsDataItemGuiContext context = createContext();
577  QgsBrowserPropertiesWidget *propertiesWidget = QgsBrowserPropertiesWidget::createWidget( item, context, mPropertiesWidget );
578  if ( propertiesWidget )
579  {
580  propertiesWidget->setCondensedMode( true );
581  mPropertiesLayout->addWidget( propertiesWidget );
582  }
583  }
584  }
585  mPropertiesWidget->setVisible( mPropertiesLayout->count() > 0 );
586 }
587 
589 {
590  mPropertiesWidgetEnabled = enable;
591  if ( enable && selectedItemsCount() == 1 )
592  {
593  setPropertiesWidget();
594  }
595  else
596  {
597  clearPropertiesWidget();
598  }
599 }
600 
601 void QgsBrowserDockWidget::setActiveIndex( const QModelIndex &index )
602 {
603  if ( index.isValid() )
604  {
605  QModelIndex proxyIndex = mProxyModel->mapFromSource( index );
606  mBrowserView->expand( proxyIndex );
607  mBrowserView->setCurrentIndex( proxyIndex );
608  }
609 }
610 
612 {
613  QList<int> sizes = mSplitter->sizes();
614  float total = sizes.value( 0 ) + sizes.value( 1 );
615  mPropertiesWidgetHeight = total > 0 ? sizes.value( 1 ) / total : 0;
616 }
QgsBrowserDockWidget::setMessageBar
void setMessageBar(QgsMessageBar *bar)
Sets a message bar to use alongside the dock widget.
Definition: qgsbrowserdockwidget.cpp:281
qgsdataitemguiproviderregistry.h
QgsBrowserModel::refresh
void refresh(const QString &path)
Refresh item specified by path.
Definition: qgsbrowsermodel.cpp:687
QgsDataItemGuiProvider
Abstract base class for providers which affect how QgsDataItem items behave within the application GU...
Definition: qgsdataitemguiprovider.h:86
QgsBrowserModel::connectionsChanged
void connectionsChanged(const QString &providerKey)
Emitted when connections for the specified providerKey have changed in the browser.
qgsrasterlayer.h
QgsBrowserDockWidget::showFilterWidget
void showFilterWidget(bool visible)
Show/hide filter widget.
Definition: qgsbrowserdockwidget.cpp:487
QgsBrowserDockWidget::showProperties
void showProperties()
Show the layer properties.
Definition: qgsbrowserdockwidget.cpp:446
QgsBrowserModel::initialize
void initialize()
Delayed initialization, needed because the provider registry must be already populated.
Definition: qgsbrowsermodel.cpp:223
qgsbrowsertreeview.h
QgsDataItem::path
QString path() const
Definition: qgsdataitem.h:333
QgsSettings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Definition: qgssettings.cpp:174
qgsnewnamedialog.h
qgsmapcanvas.h
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QgsDataItem::capabilities2
virtual Capabilities capabilities2() const
Returns the capabilities for the data item.
Definition: qgsdataitem.h:287
QgsBrowserDockWidget::setActiveIndex
void setActiveIndex(const QModelIndex &index)
Sets the selection to index and expand it.
Definition: qgsbrowserdockwidget.cpp:601
qgsgui.h
qgsdataitemguiprovider.h
QgsBrowserDockWidget::setFilterSyntax
void setFilterSyntax(QAction *)
Sets filter syntax.
Definition: qgsbrowserdockwidget.cpp:514
QgsDataItemGuiProviderRegistry::providers
QList< QgsDataItemGuiProvider * > providers() const
Returns the list of available providers.
Definition: qgsdataitemguiproviderregistry.h:51
QgsSettings
This class is a composition of two QSettings instances:
Definition: qgssettings.h:62
QgsBrowserDockWidget::~QgsBrowserDockWidget
~QgsBrowserDockWidget() override
Definition: qgsbrowserdockwidget.cpp:111
qgsbrowserdockwidget.h
QgsMimeDataUtils::UriList
QList< QgsMimeDataUtils::Uri > UriList
Definition: qgsmimedatautils.h:156
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QgsBrowserDockWidget::toggleFastScan
Q_DECL_DEPRECATED void toggleFastScan()
Toggle fast scan.
Definition: qgsbrowserdockwidget.cpp:462
QgsDataItem::Directory
@ Directory
Definition: qgsdataitem.h:80
QgsBrowserDockWidget::updateProjectHome
void updateProjectHome()
Update project home directory.
Definition: qgsbrowserdockwidget.cpp:508
QgsDockWidget::showEvent
void showEvent(QShowEvent *event) override
Definition: qgsdockwidget.cpp:90
QgsDataItem::Fertile
@ Fertile
Can create children. Even items without this capability may have children, but cannot create them,...
Definition: qgsdataitem.h:246
QgsDataItem::depopulate
virtual void depopulate()
Remove children recursively and set as not populated. This is used when refreshing collapsed items.
Definition: qgsdataitem.cpp:518
QgsBrowserProxyModel::setBrowserModel
void setBrowserModel(QgsBrowserModel *model)
Sets the underlying browser model.
Definition: qgsbrowserproxymodel.cpp:28
QgsBrowserDockWidget::splitterMoved
void splitterMoved()
Splitter has been moved.
Definition: qgsbrowserdockwidget.cpp:611
QgsDirectoryItem::dirPath
QString dirPath() const
Returns the full path to the directory the item represents.
Definition: qgsdataitem.h:788
QgsBrowserProxyModel
A QSortFilterProxyModel subclass for filtering and sorting browser model items.
Definition: qgsbrowserproxymodel.h:33
qgsapplication.h
QgsBrowserProxyModel::setFilterCaseSensitivity
void setFilterCaseSensitivity(Qt::CaseSensitivity sensitivity)
Sets whether item filtering should be case sensitive.
Definition: qgsbrowserproxymodel.cpp:66
Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:797
QgsDataItem::type
Type type() const
Definition: qgsdataitem.h:303
QgsBrowserModel::updateProjectHome
void updateProjectHome()
Definition: qgsbrowsermodel.cpp:63
QgsBrowserProxyModel::RegularExpression
@ RegularExpression
Regular expression filtering.
Definition: qgsbrowserproxymodel.h:42
QgsBrowserModel::removeFavorite
void removeFavorite(const QModelIndex &index)
Removes a favorite directory from its corresponding model index.
Definition: qgsbrowsermodel.cpp:711
QgsProjectItem
Data item that can be used to represent QGIS projects.
Definition: qgsdataitem.h:818
QgsDirectoryItem
A directory: contains subdirectories and layers.
Definition: qgsdataitem.h:743
QgsBrowserDockWidget::setCaseSensitive
void setCaseSensitive(bool caseSensitive)
Sets filter case sensitivity.
Definition: qgsbrowserdockwidget.cpp:522
QgsBrowserDockWidget::messageBar
QgsMessageBar * messageBar()
Returns the message bar associated with the dock.
Definition: qgsbrowserdockwidget.cpp:287
QgsBrowserDockWidget::connectionsChanged
void connectionsChanged()
Connections changed in the browser.
QgsBrowserProxyModel::Wildcards
@ Wildcards
Wildcard filtering.
Definition: qgsbrowserproxymodel.h:41
QgsBrowserDockWidget::addFavorite
Q_DECL_DEPRECATED void addFavorite()
Add current item to favorite.
Definition: qgsbrowserdockwidget.cpp:249
QgsBrowserDockWidget::enablePropertiesWidget
void enablePropertiesWidget(bool enable)
Enable/disable properties widget.
Definition: qgsbrowserdockwidget.cpp:588
QgsMessageBar
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
QgsDataItem::handleDoubleClick
virtual bool handleDoubleClick()
Called when a user double clicks on the item.
Definition: qgsdataitem.cpp:747
QgsBrowserProxyModel::setHiddenDataItemProviderKeyFilter
void setHiddenDataItemProviderKeyFilter(const QStringList &hiddenItemsFilter)
Sets a filter to hide data items based on QgsDataItem::providerKey() associated with the item.
Definition: qgsbrowserproxymodel.cpp:282
QgsDataItem::Project
@ Project
Represents a QGIS project.
Definition: qgsdataitem.h:84
QgsDataItemGuiContext
Encapsulates the context in which a QgsDataItem is shown within the application GUI.
Definition: qgsdataitemguiprovider.h:41
QgsSettings::setValue
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Definition: qgssettings.cpp:289
QgsBrowserDockWidget::removeFavorite
Q_DECL_DEPRECATED void removeFavorite()
Remove from favorite.
Definition: qgsbrowserdockwidget.cpp:302
QgsBrowserModel::hidePath
void hidePath(QgsDataItem *item)
Hide the given path in the browser model.
Definition: qgsbrowsermodel.cpp:728
QgsBrowserDockWidget::setFilter
void setFilter()
Apply filter to the model.
Definition: qgsbrowserdockwidget.cpp:501
QgsBrowserDockWidget::openFile
void openFile(const QString &fileName, const QString &fileTypeHint=QString())
Emitted when a file needs to be opened.
QgsBrowserDockWidget::showEvent
void showEvent(QShowEvent *event) override
Show event override.
Definition: qgsbrowserdockwidget.cpp:119
QgsBrowserProxyModel::setFilterSyntax
void setFilterSyntax(FilterSyntax syntax)
Sets the filter syntax.
Definition: qgsbrowserproxymodel.cpp:40
QgsBrowserProxyModel::Normal
@ Normal
Standard string filtering.
Definition: qgsbrowserproxymodel.h:40
QgsDataItem::actions
virtual QList< QAction * > actions(QWidget *parent)
Returns the list of actions available for this item.
Definition: qgsdataitem.cpp:741
qgsvectorlayer.h
QgsGui::dataItemGuiProviderRegistry
static QgsDataItemGuiProviderRegistry * dataItemGuiProviderRegistry()
Returns the global data item GUI provider registry, used for tracking providers which affect the brow...
Definition: qgsgui.cpp:124
QgsBrowserDockWidget::refresh
void refresh()
Refresh browser view model (and view)
Definition: qgsbrowserdockwidget.cpp:307
QgsBrowserDockWidget::selectionChanged
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Selection has changed.
Definition: qgsbrowserdockwidget.cpp:546
QgsBrowserDockWidget::setDisabledDataItemsKeys
void setDisabledDataItemsKeys(const QStringList &filter)
Sets the customization for data items based on item's data provider key.
Definition: qgsbrowserdockwidget.cpp:292
QgsDataItemGuiContext::setMessageBar
void setMessageBar(QgsMessageBar *bar)
Sets the associated message bar.
Definition: qgsdataitemguiprovider.cpp:32
QgsGui::instance
static QgsGui * instance()
Returns a pointer to the singleton instance.
Definition: qgsgui.cpp:63
QgsBrowserModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: qgsbrowsermodel.cpp:350
QgsBrowserDockWidget::QgsBrowserDockWidget
QgsBrowserDockWidget(const QString &name, QgsBrowserGuiModel *browserModel, QWidget *parent=nullptr)
Constructor for QgsBrowserDockWidget.
Definition: qgsbrowserdockwidget.cpp:48
QgsBrowserProxyModel::dataItem
QgsDataItem * dataItem(const QModelIndex &index) const
Returns the data item at the specified proxy index, or nullptr if no item exists at the index.
Definition: qgsbrowserproxymodel.cpp:34
qgsbrowserdockwidget_p.h
QgsBrowserDockWidget::addLayerAtIndex
Q_DECL_DEPRECATED bool addLayerAtIndex(const QModelIndex &index)
Adds the layer corresponding to the specified model index.
Definition: qgsbrowserdockwidget.cpp:364
QgsBrowserModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: qgsbrowsermodel.cpp:514
qgsbrowserguimodel.h
qgssettings.h
QgsDockWidget
QgsDockWidget subclass with more fine-grained control over how the widget is closed or opened.
Definition: qgsdockwidget.h:32
QgsDataItem::Layer
@ Layer
Definition: qgsdataitem.h:81
QgsBrowserModel::addFavoriteDirectory
void addFavoriteDirectory(const QString &directory, const QString &name=QString())
Adds a directory to the favorites group.
Definition: qgsbrowsermodel.cpp:705
qgsbrowserproxymodel.h
QgsLayerItem
Item that represents a layer that can be opened with one of the providers.
Definition: qgsdataitem.h:507
QgsFilterLineEdit::cleared
void cleared()
Emitted when the widget is cleared.
QgsDataItem::Fast
@ Fast
CreateChildren() is fast enough to be run in main thread when refreshing items, most root items (wms,...
Definition: qgsdataitem.h:247
QgsBrowserDockWidget::handleDropUriList
void handleDropUriList(const QgsMimeDataUtils::UriList &)
Emitted when drop uri list needs to be handled.
QgsDataItem::menus
virtual QList< QMenu * > menus(QWidget *parent)
Returns the list of menus available for this item.
Definition: qgsdataitem.cpp:793
qgslogger.h
QgsBrowserDockWidget::addSelectedLayers
void addSelectedLayers()
Add selected layers to the project.
Definition: qgsbrowserdockwidget.cpp:394
QgsDataItem
Base class for all items in the model.
Definition: qgsdataitem.h:51
Q_NOWARN_DEPRECATED_PUSH
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:796
qgswindowmanagerinterface.h
QgsBrowserDockWidget::hideItem
void hideItem()
Hide current item.
Definition: qgsbrowserdockwidget.cpp:433
QgsBrowserModel::dataItem
QgsDataItem * dataItem(const QModelIndex &idx) const
Returns the data item at the specified index, or nullptr if no item exists at the index.
Definition: qgsbrowsermodel.cpp:658
QgsBrowserModel::initialized
bool initialized() const
Returns true if the model has been initialized.
Definition: qgsbrowsermodel.h:170
QgsBrowserProxyModel::FilterSyntax
FilterSyntax
Filter syntax options.
Definition: qgsbrowserproxymodel.h:39
QgsBrowserGuiModel
A model for showing available data sources and other items in a structured tree.
Definition: qgsbrowserguimodel.h:38
QgsBrowserProxyModel::setFilterString
void setFilterString(const QString &filter)
Sets the filter string to use when filtering items in the model.
Definition: qgsbrowserproxymodel.cpp:53
qgsproject.h
QgsLayerItem::mimeUri
QgsMimeDataUtils::Uri mimeUri() const override
Returns mime URI for the data item.
Definition: qgsdataitem.cpp:932
QgsBrowserGuiModel::setMessageBar
void setMessageBar(QgsMessageBar *bar)
Sets message bar that will be passed in QgsDataItemGuiContext to data items.
Definition: qgsbrowserguimodel.cpp:140
QgsBrowserDockWidget::showContextMenu
void showContextMenu(QPoint)
Show context menu.
Definition: qgsbrowserdockwidget.cpp:194
QgsBrowserDockWidget::addFavoriteDirectory
Q_DECL_DEPRECATED void addFavoriteDirectory()
Add directory from file dialog to favorite.
Definition: qgsbrowserdockwidget.cpp:265