QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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  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  mProxyModel->setHiddenDataItemProviderKeyFilter( mDisabledDataItemsKeys );
132  mBrowserView->setSettingsSection( objectName().toLower() ); // to distinguish 2 or more instances of the browser
133  mBrowserView->setBrowserModel( mModel );
134  mBrowserView->setModel( mProxyModel );
135  mBrowserView->setSortingEnabled( true );
136  mBrowserView->sortByColumn( 0, Qt::AscendingOrder );
137  // provide a horizontal scroll bar instead of using ellipse (...) for longer items
138  mBrowserView->setTextElideMode( Qt::ElideNone );
139  mBrowserView->header()->setSectionResizeMode( 0, QHeaderView::ResizeToContents );
140  mBrowserView->header()->setStretchLastSection( false );
141 
142  // selectionModel is created when model is set on tree
143  connect( mBrowserView->selectionModel(), &QItemSelectionModel::selectionChanged,
145 
146  // Forward the model changed signals to the widget
147  connect( mModel, &QgsBrowserModel::connectionsChanged,
149 
150 
151  // objectName used by settingsSection() is not yet set in constructor
152  QgsSettings settings;
153  mPropertiesWidgetEnabled = settings.value( settingsSection() + "/propertiesWidgetEnabled", false ).toBool();
154  mActionPropertiesWidget->setChecked( mPropertiesWidgetEnabled );
155  mPropertiesWidget->setVisible( false ); // false until item is selected
156 
157  mPropertiesWidgetHeight = settings.value( settingsSection() + "/propertiesWidgetHeight" ).toFloat();
158  QList<int> sizes = mSplitter->sizes();
159  int total = sizes.value( 0 ) + sizes.value( 1 );
160  int height = static_cast<int>( total * mPropertiesWidgetHeight );
161  sizes.clear();
162  sizes << total - height << height;
163  mSplitter->setSizes( sizes );
164  }
165 
167 }
168 
169 void QgsBrowserDockWidget::itemDoubleClicked( const QModelIndex &index )
170 {
171  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( index ) );
172  if ( !item )
173  return;
174 
175  QgsDataItemGuiContext context = createContext();
176 
177  const QList< QgsDataItemGuiProvider * > providers = QgsGui::instance()->dataItemGuiProviderRegistry()->providers();
178  for ( QgsDataItemGuiProvider *provider : providers )
179  {
180  if ( provider->handleDoubleClick( item, context ) )
181  return;
182  }
183 
184  // if no providers overrode the double-click handling for this item, we give the item itself a chance
185  if ( !item->handleDoubleClick() )
186  {
187  // double-click not handled by browser model, so use as default view expand behavior
188  if ( mBrowserView->isExpanded( index ) )
189  mBrowserView->collapse( index );
190  else
191  mBrowserView->expand( index );
192  }
193 }
194 
196 {
197  QModelIndex index = mProxyModel->mapToSource( mBrowserView->indexAt( pt ) );
198  QgsDataItem *item = mModel->dataItem( index );
199  if ( !item )
200  return;
201 
202  const QModelIndexList selection = mBrowserView->selectionModel()->selectedIndexes();
203  QList< QgsDataItem * > selectedItems;
204  selectedItems.reserve( selection.size() );
205  for ( const QModelIndex &selectedIndex : selection )
206  {
207  QgsDataItem *selectedItem = mProxyModel->dataItem( selectedIndex );
208  if ( selectedItem )
209  selectedItems << selectedItem;
210  }
211 
212  QMenu *menu = new QMenu( this );
213 
214  const QList<QMenu *> menus = item->menus( menu );
215  QList<QAction *> actions = item->actions( menu );
216 
217  if ( !menus.isEmpty() )
218  {
219  for ( QMenu *mn : menus )
220  {
221  menu->addMenu( mn );
222  }
223  }
224 
225  if ( !actions.isEmpty() )
226  {
227  if ( !menu->actions().isEmpty() )
228  menu->addSeparator();
229  // add action to the menu
230  menu->addActions( actions );
231  }
232 
233  QgsDataItemGuiContext context = createContext();
234 
235  const QList< QgsDataItemGuiProvider * > providers = QgsGui::instance()->dataItemGuiProviderRegistry()->providers();
236  for ( QgsDataItemGuiProvider *provider : providers )
237  {
238  provider->populateContextMenu( item, menu, selectedItems, context );
239  }
240 
241  if ( menu->actions().isEmpty() )
242  {
243  delete menu;
244  return;
245  }
246 
247  menu->popup( mBrowserView->mapToGlobal( pt ) );
248 }
249 
251 {
252  QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() );
253  QgsDataItem *item = mModel->dataItem( index );
254  if ( !item )
255  return;
256 
257  QgsDirectoryItem *dirItem = qobject_cast<QgsDirectoryItem *>( item );
258  if ( !dirItem )
259  return;
260 
262  addFavoriteDirectory( dirItem->dirPath() );
264 }
265 
267 {
268  QString directory = QFileDialog::getExistingDirectory( this, tr( "Add directory to favorites" ) );
269  if ( !directory.isEmpty() )
270  {
272  addFavoriteDirectory( directory );
274  }
275 }
276 
277 void QgsBrowserDockWidget::addFavoriteDirectory( const QString &favDir, const QString &name )
278 {
279  mModel->addFavoriteDirectory( favDir, name );
280 }
281 
283 {
284  mMessageBar = bar;
285  mModel->setMessageBar( bar );
286 }
287 
289 {
290  return mMessageBar;
291 }
292 
293 void QgsBrowserDockWidget::setDisabledDataItemsKeys( const QStringList &filter )
294 {
295  mDisabledDataItemsKeys = filter;
296 
297  if ( !mProxyModel )
298  return;
299 
300  mProxyModel->setHiddenDataItemProviderKeyFilter( mDisabledDataItemsKeys );
301 }
302 
304 {
305  mModel->removeFavorite( mProxyModel->mapToSource( mBrowserView->currentIndex() ) );
306 }
307 
309 {
310  refreshModel( QModelIndex() );
311 }
312 
313 void QgsBrowserDockWidget::refreshModel( const QModelIndex &index )
314 {
315  if ( mModel && mProxyModel )
316  {
317  QgsDataItem *item = mModel->dataItem( index );
318  if ( item )
319  {
320  QgsDebugMsgLevel( "path = " + item->path(), 4 );
321  }
322  else
323  {
324  QgsDebugMsgLevel( QStringLiteral( "invalid item" ), 4 );
325  }
326 
327  if ( item && ( item->capabilities2() & QgsDataItem::Fertile ) )
328  {
329  mModel->refresh( index );
330  }
331 
332  for ( int i = 0; i < mModel->rowCount( index ); i++ )
333  {
334  QModelIndex idx = mModel->index( i, 0, index );
335  QModelIndex proxyIdx = mProxyModel->mapFromSource( idx );
336  QgsDataItem *child = mModel->dataItem( idx );
337 
338  // Check also expanded descendants so that the whole expanded path does not get collapsed if one item is collapsed.
339  // Fast items (usually root items) are refreshed so that when collapsed, it is obvious they are if empty (no expand symbol).
340  if ( mBrowserView->isExpanded( proxyIdx ) || mBrowserView->hasExpandedDescendant( proxyIdx ) || ( child && child->capabilities2() & QgsDataItem::Fast ) )
341  {
342  refreshModel( idx );
343  }
344  else
345  {
346  if ( child && ( child->capabilities2() & QgsDataItem::Fertile ) )
347  {
348  child->depopulate();
349  }
350  }
351  }
352  }
353 }
354 
355 void QgsBrowserDockWidget::addLayer( QgsLayerItem *layerItem )
356 {
357  if ( !layerItem )
358  return;
359 
361  list << layerItem->mimeUri();
362  emit handleDropUriList( list );
363 }
364 
365 bool QgsBrowserDockWidget::addLayerAtIndex( const QModelIndex &index )
366 {
367  QgsDebugMsg( QStringLiteral( "rowCount() = %1" ).arg( mModel->rowCount( mProxyModel->mapToSource( index ) ) ) );
368  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( index ) );
369 
370  if ( item && item->type() == QgsDataItem::Project )
371  {
372  QgsProjectItem *projectItem = qobject_cast<QgsProjectItem *>( item );
373  if ( projectItem )
374  {
375  QApplication::setOverrideCursor( Qt::WaitCursor );
376  emit openFile( projectItem->path(), QStringLiteral( "project" ) );
377  QApplication::restoreOverrideCursor();
378  }
379  return true;
380  }
381  else if ( item && item->type() == QgsDataItem::Layer )
382  {
383  QgsLayerItem *layerItem = qobject_cast<QgsLayerItem *>( item );
384  if ( layerItem )
385  {
386  QApplication::setOverrideCursor( Qt::WaitCursor );
387  addLayer( layerItem );
388  QApplication::restoreOverrideCursor();
389  }
390  return true;
391  }
392  return false;
393 }
394 
396 {
397  QApplication::setOverrideCursor( Qt::WaitCursor );
398 
399  // get a sorted list of selected indexes
400  QModelIndexList list = mBrowserView->selectionModel()->selectedIndexes();
401  std::sort( list.begin(), list.end() );
402 
403  // If any of the layer items are QGIS we just open and exit the loop
404  const auto constList = list;
405  for ( const QModelIndex &index : constList )
406  {
407  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( index ) );
408  if ( item && item->type() == QgsDataItem::Project )
409  {
410  QgsProjectItem *projectItem = qobject_cast<QgsProjectItem *>( item );
411  if ( projectItem )
412  emit openFile( projectItem->path(), QStringLiteral( "project" ) );
413 
414  QApplication::restoreOverrideCursor();
415  return;
416  }
417  }
418 
419  // add items in reverse order so they are in correct order in the layers dock
420  for ( int i = list.size() - 1; i >= 0; i-- )
421  {
422  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( list[i] ) );
423  if ( item && item->type() == QgsDataItem::Layer )
424  {
425  QgsLayerItem *layerItem = qobject_cast<QgsLayerItem *>( item );
426  if ( layerItem )
427  addLayer( layerItem );
428  }
429  }
430 
431  QApplication::restoreOverrideCursor();
432 }
433 
435 {
436  QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() );
437  QgsDataItem *item = mModel->dataItem( index );
438  if ( ! item )
439  return;
440 
441  if ( item->type() == QgsDataItem::Directory )
442  {
443  mModel->hidePath( item );
444  }
445 }
446 
448 {
449  QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() );
450  QgsDataItem *item = mModel->dataItem( index );
451  if ( ! item )
452  return;
453 
454  if ( item->type() == QgsDataItem::Layer || item->type() == QgsDataItem::Directory )
455  {
456  QgsBrowserPropertiesDialog *dialog = new QgsBrowserPropertiesDialog( settingsSection(), this );
457  dialog->setAttribute( Qt::WA_DeleteOnClose );
458  dialog->setItem( item, createContext() );
459  dialog->show();
460  }
461 }
462 
464 {
465  QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() );
466  QgsDataItem *item = mModel->dataItem( index );
467  if ( ! item )
468  return;
469 
470  if ( item->type() == QgsDataItem::Directory )
471  {
472  QgsSettings settings;
473  QStringList fastScanDirs = settings.value( QStringLiteral( "qgis/scanItemsFastScanUris" ),
474  QStringList() ).toStringList();
475  int idx = fastScanDirs.indexOf( item->path() );
476  if ( idx != -1 )
477  {
478  fastScanDirs.removeAt( idx );
479  }
480  else
481  {
482  fastScanDirs << item->path();
483  }
484  settings.setValue( QStringLiteral( "qgis/scanItemsFastScanUris" ), fastScanDirs );
485  }
486 }
487 
489 {
490  mWidgetFilter->setVisible( visible );
491  if ( ! visible )
492  {
493  mLeFilter->setText( QString() );
494  setFilter();
495  }
496  else
497  {
498  mLeFilter->setFocus();
499  }
500 }
501 
503 {
504  QString filter = mLeFilter->text();
505  if ( mProxyModel )
506  mProxyModel->setFilterString( filter );
507 }
508 
510 {
511  if ( mModel )
512  mModel->updateProjectHome();
513 }
514 
516 {
517  if ( !action || ! mProxyModel )
518  return;
519 
520  mProxyModel->setFilterSyntax( static_cast< QgsBrowserProxyModel::FilterSyntax >( action->data().toInt() ) );
521 }
522 
523 void QgsBrowserDockWidget::setCaseSensitive( bool caseSensitive )
524 {
525  if ( ! mProxyModel )
526  return;
527  mProxyModel->setFilterCaseSensitivity( caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive );
528 }
529 
530 int QgsBrowserDockWidget::selectedItemsCount()
531 {
532  QItemSelectionModel *selectionModel = mBrowserView->selectionModel();
533  if ( selectionModel )
534  {
535  return selectionModel->selectedIndexes().size();
536  }
537  return 0;
538 }
539 
540 QgsDataItemGuiContext QgsBrowserDockWidget::createContext()
541 {
542  QgsDataItemGuiContext context;
543  context.setMessageBar( mMessageBar );
544  return context;
545 }
546 
547 void QgsBrowserDockWidget::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
548 {
549  Q_UNUSED( selected )
550  Q_UNUSED( deselected )
551  if ( mPropertiesWidgetEnabled )
552  {
553  setPropertiesWidget();
554  }
555 }
556 
557 void QgsBrowserDockWidget::clearPropertiesWidget()
558 {
559  while ( mPropertiesLayout->count() > 0 )
560  {
561  delete mPropertiesLayout->itemAt( 0 )->widget();
562  }
563  mPropertiesWidget->setVisible( false );
564 }
565 
566 void QgsBrowserDockWidget::setPropertiesWidget()
567 {
568  clearPropertiesWidget();
569  QItemSelectionModel *selectionModel = mBrowserView->selectionModel();
570  if ( selectionModel )
571  {
572  QModelIndexList indexes = selectionModel->selectedIndexes();
573  if ( indexes.size() == 1 )
574  {
575  QModelIndex index = mProxyModel->mapToSource( indexes.value( 0 ) );
576  QgsDataItem *item = mModel->dataItem( index );
577  QgsDataItemGuiContext context = createContext();
578  QgsBrowserPropertiesWidget *propertiesWidget = QgsBrowserPropertiesWidget::createWidget( item, context, mPropertiesWidget );
579  if ( propertiesWidget )
580  {
581  propertiesWidget->setCondensedMode( true );
582  mPropertiesLayout->addWidget( propertiesWidget );
583  }
584  }
585  }
586  mPropertiesWidget->setVisible( mPropertiesLayout->count() > 0 );
587 }
588 
590 {
591  mPropertiesWidgetEnabled = enable;
592  if ( enable && selectedItemsCount() == 1 )
593  {
594  setPropertiesWidget();
595  }
596  else
597  {
598  clearPropertiesWidget();
599  }
600 }
601 
602 void QgsBrowserDockWidget::setActiveIndex( const QModelIndex &index )
603 {
604  if ( index.isValid() )
605  {
606  QModelIndex proxyIndex = mProxyModel->mapFromSource( index );
607  mBrowserView->expand( proxyIndex );
608  mBrowserView->setCurrentIndex( proxyIndex );
609  }
610 }
611 
613 {
614  QList<int> sizes = mSplitter->sizes();
615  float total = sizes.value( 0 ) + sizes.value( 1 );
616  mPropertiesWidgetHeight = total > 0 ? sizes.value( 1 ) / total : 0;
617 }
QgsBrowserDockWidget::setMessageBar
void setMessageBar(QgsMessageBar *bar)
Sets a message bar to use alongside the dock widget.
Definition: qgsbrowserdockwidget.cpp:282
qgsdataitemguiproviderregistry.h
QgsBrowserModel::refresh
void refresh(const QString &path)
Refresh item specified by path.
Definition: qgsbrowsermodel.cpp:686
QgsDataItemGuiProvider
Definition: qgsdataitemguiprovider.h:84
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:488
QgsBrowserDockWidget::showProperties
void showProperties()
Show the layer properties.
Definition: qgsbrowserdockwidget.cpp:447
QgsBrowserModel::initialize
void initialize()
Delayed initialization, needed because the provider registry must be already populated.
Definition: qgsbrowsermodel.cpp:222
qgsbrowsertreeview.h
QgsDataItem::path
QString path() const
Definition: qgsdataitem.h:327
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:283
QgsBrowserDockWidget::setActiveIndex
void setActiveIndex(const QModelIndex &index)
Sets the selection to index and expand it.
Definition: qgsbrowserdockwidget.cpp:602
qgsgui.h
qgsdataitemguiprovider.h
QgsBrowserDockWidget::setFilterSyntax
void setFilterSyntax(QAction *)
Sets filter syntax.
Definition: qgsbrowserdockwidget.cpp:515
QgsDataItemGuiProviderRegistry::providers
QList< QgsDataItemGuiProvider * > providers() const
Returns the list of available providers.
Definition: qgsdataitemguiproviderregistry.h:51
QgsSettings
Definition: qgssettings.h:61
QgsBrowserDockWidget::~QgsBrowserDockWidget
~QgsBrowserDockWidget() override
Definition: qgsbrowserdockwidget.cpp:112
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:463
QgsDataItem::Directory
@ Directory
Definition: qgsdataitem.h:79
QgsBrowserDockWidget::updateProjectHome
void updateProjectHome()
Update project home directory.
Definition: qgsbrowserdockwidget.cpp:509
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:242
QgsDataItem::depopulate
virtual void depopulate()
Remove children recursively and set as not populated. This is used when refreshing collapsed items.
Definition: qgsdataitem.cpp:350
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:612
QgsDirectoryItem::dirPath
QString dirPath() const
Returns the full path to the directory the item represents.
Definition: qgsdataitem.h:717
QgsBrowserProxyModel
Definition: qgsbrowserproxymodel.h:32
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:752
QgsDataItem::type
Type type() const
Definition: qgsdataitem.h:299
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:710
QgsProjectItem
Definition: qgsdataitem.h:746
QgsDirectoryItem
Definition: qgsdataitem.h:671
QgsBrowserDockWidget::setCaseSensitive
void setCaseSensitive(bool caseSensitive)
Sets filter case sensitivity.
Definition: qgsbrowserdockwidget.cpp:523
QgsBrowserDockWidget::messageBar
QgsMessageBar * messageBar()
Returns the message bar associated with the dock.
Definition: qgsbrowserdockwidget.cpp:288
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:250
QgsBrowserDockWidget::enablePropertiesWidget
void enablePropertiesWidget(bool enable)
Enable/disable properties widget.
Definition: qgsbrowserdockwidget.cpp:589
QgsMessageBar
Definition: qgsmessagebar.h:60
QgsDataItem::handleDoubleClick
virtual bool handleDoubleClick()
Called when a user double clicks on the item.
Definition: qgsdataitem.cpp:579
QgsBrowserProxyModel::setHiddenDataItemProviderKeyFilter
void setHiddenDataItemProviderKeyFilter(const QStringList &hiddenItemsFilter)
Sets a filter to hide data items based on on item's data item provider key.
Definition: qgsbrowserproxymodel.cpp:282
QgsDataItem::Project
@ Project
Represents a QGIS project.
Definition: qgsdataitem.h:83
QgsDataItemGuiContext
Definition: qgsdataitemguiprovider.h:39
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:303
QgsBrowserModel::hidePath
void hidePath(QgsDataItem *item)
Hide the given path in the browser model.
Definition: qgsbrowsermodel.cpp:727
QgsBrowserDockWidget::setFilter
void setFilter()
Apply filter to the model.
Definition: qgsbrowserdockwidget.cpp:502
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:120
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:573
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:118
QgsBrowserDockWidget::refresh
void refresh()
Refresh browser view model (and view)
Definition: qgsbrowserdockwidget.cpp:308
QgsBrowserDockWidget::selectionChanged
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Selection has changed.
Definition: qgsbrowserdockwidget.cpp:547
QgsBrowserDockWidget::setDisabledDataItemsKeys
void setDisabledDataItemsKeys(const QStringList &filter)
Sets the customization for data items based on item's data provider key.
Definition: qgsbrowserdockwidget.cpp:293
QgsDataItemGuiContext::setMessageBar
void setMessageBar(QgsMessageBar *bar)
Sets the associated message bar.
Definition: qgsdataitemguiprovider.cpp:27
QgsGui::instance
static QgsGui * instance()
Returns a pointer to the singleton instance.
Definition: qgsgui.cpp:62
QgsBrowserModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: qgsbrowsermodel.cpp:349
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:365
QgsBrowserModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: qgsbrowsermodel.cpp:513
qgsbrowserguimodel.h
qgssettings.h
QgsDockWidget
Definition: qgsdockwidget.h:31
QgsDataItem::Layer
@ Layer
Definition: qgsdataitem.h:80
QgsBrowserModel::addFavoriteDirectory
void addFavoriteDirectory(const QString &directory, const QString &name=QString())
Adds a directory to the favorites group.
Definition: qgsbrowsermodel.cpp:704
qgsbrowserproxymodel.h
QgsLayerItem
Definition: qgsdataitem.h:499
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:243
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:625
qgslogger.h
QgsBrowserDockWidget::addSelectedLayers
void addSelectedLayers()
Add selected layers to the project.
Definition: qgsbrowserdockwidget.cpp:395
QgsDataItem
Definition: qgsdataitem.h:49
Q_NOWARN_DEPRECATED_PUSH
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:751
qgswindowmanagerinterface.h
QgsBrowserDockWidget::hideItem
void hideItem()
Hide current item.
Definition: qgsbrowserdockwidget.cpp:434
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:657
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:38
QgsBrowserGuiModel
Definition: qgsbrowserguimodel.h:37
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:762
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:195
QgsBrowserDockWidget::addFavoriteDirectory
Q_DECL_DEPRECATED void addFavoriteDirectory()
Add directory from file dialog to favorite.
Definition: qgsbrowserdockwidget.cpp:266