QGIS API Documentation  3.2.0-Bonn (bc43194)
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 
36 // browser layer properties dialog
37 #include "qgsapplication.h"
38 #include "qgsmapcanvas.h"
39 
40 #include <QDragEnterEvent>
41 
42 QgsBrowserDockWidget::QgsBrowserDockWidget( const QString &name, QgsBrowserModel *browserModel, QWidget *parent )
43  : QgsDockWidget( parent )
44  , mModel( browserModel )
45  , mPropertiesWidgetEnabled( false )
46  , mPropertiesWidgetHeight( 0 )
47 {
48  setupUi( this );
49 
50  mContents->layout()->setContentsMargins( 0, 0, 0, 0 );
51  mContents->layout()->setMargin( 0 );
52  static_cast< QVBoxLayout * >( mContents->layout() )->setSpacing( 0 );
53 
54  setWindowTitle( name );
55 
56  mBrowserView = new QgsDockBrowserTreeView( this );
57  mLayoutBrowser->addWidget( mBrowserView );
58 
59  mWidgetFilter->hide();
60  mLeFilter->setPlaceholderText( tr( "Type here to filter visible items…" ) );
61  // icons from http://www.fatcow.com/free-icons License: CC Attribution 3.0
62 
63  QMenu *menu = new QMenu( this );
64  menu->setSeparatorsCollapsible( false );
65  mBtnFilterOptions->setMenu( menu );
66  QAction *action = new QAction( tr( "Case Sensitive" ), menu );
67  action->setData( "case" );
68  action->setCheckable( true );
69  action->setChecked( false );
70  connect( action, &QAction::toggled, this, &QgsBrowserDockWidget::setCaseSensitive );
71  menu->addAction( action );
72  QActionGroup *group = new QActionGroup( menu );
73  action = new QAction( tr( "Filter Pattern Syntax" ), group );
74  action->setSeparator( true );
75  menu->addAction( action );
76  action = new QAction( tr( "Normal" ), group );
77  action->setData( "normal" );
78  action->setCheckable( true );
79  action->setChecked( true );
80  menu->addAction( action );
81  action = new QAction( tr( "Wildcard(s)" ), group );
82  action->setData( "wildcard" );
83  action->setCheckable( true );
84  menu->addAction( action );
85  action = new QAction( tr( "Regular Expression" ), group );
86  action->setData( "regexp" );
87  action->setCheckable( true );
88  menu->addAction( action );
89 
90  connect( mActionRefresh, &QAction::triggered, this, &QgsBrowserDockWidget::refresh );
91  connect( mActionAddLayers, &QAction::triggered, this, &QgsBrowserDockWidget::addSelectedLayers );
92  connect( mActionCollapse, &QAction::triggered, mBrowserView, &QgsDockBrowserTreeView::collapseAll );
93  connect( mActionShowFilter, &QAction::triggered, this, &QgsBrowserDockWidget::showFilterWidget );
94  connect( mActionPropertiesWidget, &QAction::triggered, this, &QgsBrowserDockWidget::enablePropertiesWidget );
95  connect( mLeFilter, &QgsFilterLineEdit::returnPressed, this, &QgsBrowserDockWidget::setFilter );
96  connect( mLeFilter, &QgsFilterLineEdit::cleared, this, &QgsBrowserDockWidget::setFilter );
97  connect( mLeFilter, &QgsFilterLineEdit::textChanged, this, &QgsBrowserDockWidget::setFilter );
98  connect( group, &QActionGroup::triggered, this, &QgsBrowserDockWidget::setFilterSyntax );
99  connect( mBrowserView, &QgsDockBrowserTreeView::customContextMenuRequested, this, &QgsBrowserDockWidget::showContextMenu );
100  connect( mBrowserView, &QgsDockBrowserTreeView::doubleClicked, this, &QgsBrowserDockWidget::itemDoubleClicked );
101  connect( mSplitter, &QSplitter::splitterMoved, this, &QgsBrowserDockWidget::splitterMoved );
102 }
103 
105 {
106  QgsSettings settings;
107  settings.setValue( settingsSection() + "/propertiesWidgetEnabled", mPropertiesWidgetEnabled );
108  //settings.setValue(settingsSection() + "/propertiesWidgetHeight", mPropertiesWidget->size().height() );
109  settings.setValue( settingsSection() + "/propertiesWidgetHeight", mPropertiesWidgetHeight );
110 }
111 
112 void QgsBrowserDockWidget::showEvent( QShowEvent *e )
113 {
114  // delayed initialization of the model
115  if ( !mModel->initialized( ) )
116  {
117  mModel->initialize();
118  }
119  if ( ! mProxyModel )
120  {
121  mProxyModel = new QgsBrowserTreeFilterProxyModel( this );
122  mProxyModel->setBrowserModel( mModel );
123  mBrowserView->setSettingsSection( objectName().toLower() ); // to distinguish 2 or more instances of the browser
124  mBrowserView->setBrowserModel( mModel );
125  mBrowserView->setModel( mProxyModel );
126  mBrowserView->setSortingEnabled( true );
127  mBrowserView->sortByColumn( 0, Qt::AscendingOrder );
128  // provide a horizontal scroll bar instead of using ellipse (...) for longer items
129  mBrowserView->setTextElideMode( Qt::ElideNone );
130  mBrowserView->header()->setSectionResizeMode( 0, QHeaderView::ResizeToContents );
131  mBrowserView->header()->setStretchLastSection( false );
132 
133  // selectionModel is created when model is set on tree
134  connect( mBrowserView->selectionModel(), &QItemSelectionModel::selectionChanged,
136 
137  // Forward the model changed signals to the widget
138  connect( mModel, &QgsBrowserModel::connectionsChanged,
140 
141 
142  // objectName used by settingsSection() is not yet set in constructor
143  QgsSettings settings;
144  mPropertiesWidgetEnabled = settings.value( settingsSection() + "/propertiesWidgetEnabled", false ).toBool();
145  mActionPropertiesWidget->setChecked( mPropertiesWidgetEnabled );
146  mPropertiesWidget->setVisible( false ); // false until item is selected
147 
148  mPropertiesWidgetHeight = settings.value( settingsSection() + "/propertiesWidgetHeight" ).toFloat();
149  QList<int> sizes = mSplitter->sizes();
150  int total = sizes.value( 0 ) + sizes.value( 1 );
151  int height = ( int )total * mPropertiesWidgetHeight;
152  sizes.clear();
153  sizes << total - height << height;
154  mSplitter->setSizes( sizes );
155  }
156 
158 }
159 
160 void QgsBrowserDockWidget::itemDoubleClicked( const QModelIndex &index )
161 {
162  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( index ) );
163  if ( !item )
164  return;
165 
166  if ( item->handleDoubleClick() )
167  return;
168  else
169  addLayerAtIndex( index ); // default double-click handler
170 }
171 
172 void QgsBrowserDockWidget::renameFavorite()
173 {
174  QgsDataItem *dataItem = mModel->dataItem( mProxyModel->mapToSource( mBrowserView->currentIndex() ) );
175  if ( !dataItem )
176  return;
177 
178  QgsFavoriteItem *favorite = qobject_cast< QgsFavoriteItem * >( dataItem );
179  if ( !favorite )
180  return;
181 
182  QgsNewNameDialog dlg( tr( "favorite “%1”" ).arg( favorite->name() ), favorite->name() );
183  dlg.setWindowTitle( tr( "Rename Favorite" ) );
184  if ( dlg.exec() != QDialog::Accepted || dlg.name() == favorite->name() )
185  return;
186 
187  favorite->rename( dlg.name() );
188 }
189 
191 {
192  QModelIndex index = mProxyModel->mapToSource( mBrowserView->indexAt( pt ) );
193  QgsDataItem *item = mModel->dataItem( index );
194  if ( !item )
195  return;
196 
197  QMenu *menu = new QMenu( this );
198 
199  if ( item->type() == QgsDataItem::Directory )
200  {
201  QgsSettings settings;
202 
203  bool inFavDirs = item->parent() && item->parent()->type() == QgsDataItem::Favorites;
204  if ( item->parent() && !inFavDirs )
205  {
206  // only non-root directories can be added as favorites
207  menu->addAction( tr( "Add as a Favorite" ), this, SLOT( addFavorite() ) );
208  }
209  else if ( inFavDirs )
210  {
211  QAction *actionRename = new QAction( tr( "Rename Favorite…" ), this );
212  connect( actionRename, &QAction::triggered, this, &QgsBrowserDockWidget::renameFavorite );
213  menu->addAction( actionRename );
214  menu->addSeparator();
215  menu->addAction( tr( "Remove Favorite" ), this, SLOT( removeFavorite() ) );
216  menu->addSeparator();
217  }
218  menu->addAction( tr( "Properties…" ), this, SLOT( showProperties() ) );
219  menu->addAction( tr( "Hide from Browser" ), this, SLOT( hideItem() ) );
220  QAction *action = menu->addAction( tr( "Fast Scan this Directory" ), this, SLOT( toggleFastScan() ) );
221  action->setCheckable( true );
222  action->setChecked( settings.value( QStringLiteral( "qgis/scanItemsFastScanUris" ),
223  QStringList() ).toStringList().contains( item->path() ) );
224  }
225  else if ( item->type() == QgsDataItem::Layer )
226  {
227  menu->addAction( tr( "Add Selected Layer(s) to Canvas" ), this, SLOT( addSelectedLayers() ) );
228  menu->addAction( tr( "Properties…" ), this, SLOT( showProperties() ) );
229  }
230  else if ( item->type() == QgsDataItem::Favorites )
231  {
232  menu->addAction( tr( "Add a Directory…" ), this, SLOT( addFavoriteDirectory() ) );
233  }
234 
235  const QList<QMenu *> menus = item->menus( menu );
236  QList<QAction *> actions = item->actions( menu );
237 
238  if ( !menus.isEmpty() )
239  {
240  for ( QMenu *mn : menus )
241  {
242  menu->addMenu( mn );
243  }
244  }
245 
246  if ( !actions.isEmpty() )
247  {
248  if ( !menu->actions().isEmpty() )
249  menu->addSeparator();
250  // add action to the menu
251  menu->addActions( actions );
252  }
253 
254  if ( menu->actions().isEmpty() )
255  {
256  delete menu;
257  return;
258  }
259 
260  menu->popup( mBrowserView->mapToGlobal( pt ) );
261 }
262 
264 {
265  QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() );
266  QgsDataItem *item = mModel->dataItem( index );
267  if ( !item )
268  return;
269 
270  QgsDirectoryItem *dirItem = dynamic_cast<QgsDirectoryItem *>( item );
271  if ( !dirItem )
272  return;
273 
274  addFavoriteDirectory( dirItem->dirPath() );
275 }
276 
278 {
279  QString directory = QFileDialog::getExistingDirectory( this, tr( "Add directory to favorites" ) );
280  if ( !directory.isEmpty() )
281  {
282  addFavoriteDirectory( directory );
283  }
284 }
285 
286 void QgsBrowserDockWidget::addFavoriteDirectory( const QString &favDir, const QString &name )
287 {
288  mModel->addFavoriteDirectory( favDir, name );
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  QgsDebugMsg( "path = " + item->path() );
309  }
310  else
311  {
312  QgsDebugMsg( "invalid item" );
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 void QgsBrowserDockWidget::addLayerAtIndex( const QModelIndex &index )
354 {
355  QgsDebugMsg( QString( "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  }
368  if ( item && item->type() == QgsDataItem::Layer )
369  {
370  QgsLayerItem *layerItem = qobject_cast<QgsLayerItem *>( item );
371  if ( layerItem )
372  {
373  QApplication::setOverrideCursor( Qt::WaitCursor );
374  addLayer( layerItem );
375  QApplication::restoreOverrideCursor();
376  }
377  }
378 }
379 
381 {
382  QApplication::setOverrideCursor( Qt::WaitCursor );
383 
384  // get a sorted list of selected indexes
385  QModelIndexList list = mBrowserView->selectionModel()->selectedIndexes();
386  std::sort( list.begin(), list.end() );
387 
388  // If any of the layer items are QGIS we just open and exit the loop
389  Q_FOREACH ( const QModelIndex &index, list )
390  {
391  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( index ) );
392  if ( item && item->type() == QgsDataItem::Project )
393  {
394  QgsProjectItem *projectItem = qobject_cast<QgsProjectItem *>( item );
395  if ( projectItem )
396  emit openFile( projectItem->path(), QStringLiteral( "project" ) );
397 
398  QApplication::restoreOverrideCursor();
399  return;
400  }
401  }
402 
403  // add items in reverse order so they are in correct order in the layers dock
404  for ( int i = list.size() - 1; i >= 0; i-- )
405  {
406  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( list[i] ) );
407  if ( item && item->type() == QgsDataItem::Layer )
408  {
409  QgsLayerItem *layerItem = qobject_cast<QgsLayerItem *>( item );
410  if ( layerItem )
411  addLayer( layerItem );
412  }
413  }
414 
415  QApplication::restoreOverrideCursor();
416 }
417 
419 {
420  QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() );
421  QgsDataItem *item = mModel->dataItem( index );
422  if ( ! item )
423  return;
424 
425  if ( item->type() == QgsDataItem::Directory )
426  {
427  mModel->hidePath( item );
428  }
429 }
430 
432 {
433  QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() );
434  QgsDataItem *item = mModel->dataItem( index );
435  if ( ! item )
436  return;
437 
438  if ( item->type() == QgsDataItem::Layer || item->type() == QgsDataItem::Directory )
439  {
440  QgsBrowserPropertiesDialog *dialog = new QgsBrowserPropertiesDialog( settingsSection(), this );
441  dialog->setItem( item );
442  dialog->show();
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::Directory )
454  {
455  QgsSettings settings;
456  QStringList fastScanDirs = settings.value( QStringLiteral( "qgis/scanItemsFastScanUris" ),
457  QStringList() ).toStringList();
458  int idx = fastScanDirs.indexOf( item->path() );
459  if ( idx != -1 )
460  {
461  fastScanDirs.removeAt( idx );
462  }
463  else
464  {
465  fastScanDirs << item->path();
466  }
467  settings.setValue( QStringLiteral( "qgis/scanItemsFastScanUris" ), fastScanDirs );
468  }
469 }
470 
472 {
473  mWidgetFilter->setVisible( visible );
474  if ( ! visible )
475  {
476  mLeFilter->setText( QString() );
477  setFilter();
478  }
479  else
480  {
481  mLeFilter->setFocus();
482  }
483 }
484 
486 {
487  QString filter = mLeFilter->text();
488  if ( mProxyModel )
489  mProxyModel->setFilter( filter );
490 }
491 
493 {
494  if ( mModel )
495  mModel->updateProjectHome();
496 }
497 
499 {
500  if ( !action || ! mProxyModel )
501  return;
502  mProxyModel->setFilterSyntax( action->data().toString() );
503 }
504 
505 void QgsBrowserDockWidget::setCaseSensitive( bool caseSensitive )
506 {
507  if ( ! mProxyModel )
508  return;
509  mProxyModel->setCaseSensitive( caseSensitive );
510 }
511 
512 int QgsBrowserDockWidget::selectedItemsCount()
513 {
514  QItemSelectionModel *selectionModel = mBrowserView->selectionModel();
515  if ( selectionModel )
516  {
517  return selectionModel->selectedIndexes().size();
518  }
519  return 0;
520 }
521 
522 void QgsBrowserDockWidget::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
523 {
524  Q_UNUSED( selected );
525  Q_UNUSED( deselected );
526  if ( mPropertiesWidgetEnabled )
527  {
528  setPropertiesWidget();
529  }
530 }
531 
532 void QgsBrowserDockWidget::clearPropertiesWidget()
533 {
534  while ( mPropertiesLayout->count() > 0 )
535  {
536  delete mPropertiesLayout->itemAt( 0 )->widget();
537  }
538  mPropertiesWidget->setVisible( false );
539 }
540 
541 void QgsBrowserDockWidget::setPropertiesWidget()
542 {
543  clearPropertiesWidget();
544  QItemSelectionModel *selectionModel = mBrowserView->selectionModel();
545  if ( selectionModel )
546  {
547  QModelIndexList indexes = selectionModel->selectedIndexes();
548  if ( indexes.size() == 1 )
549  {
550  QModelIndex index = mProxyModel->mapToSource( indexes.value( 0 ) );
551  QgsDataItem *item = mModel->dataItem( index );
552  QgsBrowserPropertiesWidget *propertiesWidget = QgsBrowserPropertiesWidget::createWidget( item, mPropertiesWidget );
553  if ( propertiesWidget )
554  {
555  propertiesWidget->setCondensedMode( true );
556  mPropertiesLayout->addWidget( propertiesWidget );
557  }
558  }
559  }
560  mPropertiesWidget->setVisible( mPropertiesLayout->count() > 0 );
561 }
562 
564 {
565  mPropertiesWidgetEnabled = enable;
566  if ( enable && selectedItemsCount() == 1 )
567  {
568  setPropertiesWidget();
569  }
570  else
571  {
572  clearPropertiesWidget();
573  }
574 }
575 
577 {
578  QList<int> sizes = mSplitter->sizes();
579  float total = sizes.value( 0 ) + sizes.value( 1 );
580  mPropertiesWidgetHeight = total > 0 ? sizes.value( 1 ) / total : 0;
581 }
virtual QList< QMenu * > menus(QWidget *parent)
Returns the list of menus available for this item.
QString path() const
Definition: qgsdataitem.h:266
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
void addFavoriteDirectory()
Add directory from file dialog to favorite.
Type type() const
Definition: qgsdataitem.h:238
virtual void depopulate()
Remove children recursively and set as not populated. This is used when refreshing collapsed items...
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.
QgsDataItem * parent() const
Gets item parent.
Definition: qgsdataitem.h:243
void showContextMenu(QPoint)
Show context menu.
void addFavorite()
Add current item to favorite.
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 initialize()
Delayed initialization, needed because the provider registry must be already populated.
QgsDataItem * dataItem(const QModelIndex &idx) const
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.
void setFilterSyntax(QAction *)
Sets filter syntax.
A directory: contains subdirectories and layers.
Definition: qgsdataitem.h:531
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.
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.
New name, for example new layer name dialog.
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 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
Definition: qgsdataitem.h:560
void refresh(const QString &path)
Refresh item specified by path.
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:409
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:589
void addLayerAtIndex(const QModelIndex &index)
Add layer at index.
CreateChildren() is fast enough to be run in main thread when refreshing items, most root items (wms...
Definition: qgsdataitem.h:212
Represents a favorite item.
Definition: qgsdataitem.h:82
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Selection has changed.
virtual Capabilities capabilities2() const
Definition: qgsdataitem.h:224