QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 
37 // browser layer properties dialog
38 #include "qgsapplication.h"
39 #include "qgsmapcanvas.h"
40 
41 #include <QDragEnterEvent>
42 
43 QgsBrowserDockWidget::QgsBrowserDockWidget( const QString &name, QgsBrowserModel *browserModel, QWidget *parent )
44  : QgsDockWidget( parent )
45  , mModel( browserModel )
46  , mPropertiesWidgetEnabled( false )
47  , mPropertiesWidgetHeight( 0 )
48 {
49  setupUi( this );
50 
51  mContents->layout()->setContentsMargins( 0, 0, 0, 0 );
52  mContents->layout()->setMargin( 0 );
53  static_cast< QVBoxLayout * >( mContents->layout() )->setSpacing( 0 );
54 
55  setWindowTitle( name );
56 
57  mBrowserView = new QgsDockBrowserTreeView( this );
58  mLayoutBrowser->addWidget( mBrowserView );
59 
60  mWidgetFilter->hide();
61  mLeFilter->setPlaceholderText( tr( "Type here to filter visible items…" ) );
62  // icons from http://www.fatcow.com/free-icons License: CC Attribution 3.0
63 
64  QMenu *menu = new QMenu( this );
65  menu->setSeparatorsCollapsible( false );
66  mBtnFilterOptions->setMenu( menu );
67  QAction *action = new QAction( tr( "Case Sensitive" ), menu );
68  action->setData( "case" );
69  action->setCheckable( true );
70  action->setChecked( false );
71  connect( action, &QAction::toggled, this, &QgsBrowserDockWidget::setCaseSensitive );
72  menu->addAction( action );
73  QActionGroup *group = new QActionGroup( menu );
74  action = new QAction( tr( "Filter Pattern Syntax" ), group );
75  action->setSeparator( true );
76  menu->addAction( action );
77  action = new QAction( tr( "Normal" ), group );
78  action->setData( QgsBrowserProxyModel::Normal );
79  action->setCheckable( true );
80  action->setChecked( true );
81  menu->addAction( action );
82  action = new QAction( tr( "Wildcard(s)" ), group );
83  action->setData( QgsBrowserProxyModel::Wildcards );
84  action->setCheckable( true );
85  menu->addAction( action );
86  action = new QAction( tr( "Regular Expression" ), group );
87  action->setData( QgsBrowserProxyModel::RegularExpression );
88  action->setCheckable( true );
89  menu->addAction( action );
90 
91  connect( mActionRefresh, &QAction::triggered, this, &QgsBrowserDockWidget::refresh );
92  connect( mActionAddLayers, &QAction::triggered, this, &QgsBrowserDockWidget::addSelectedLayers );
93  connect( mActionCollapse, &QAction::triggered, mBrowserView, &QgsDockBrowserTreeView::collapseAll );
94  connect( mActionShowFilter, &QAction::triggered, this, &QgsBrowserDockWidget::showFilterWidget );
95  connect( mActionPropertiesWidget, &QAction::triggered, this, &QgsBrowserDockWidget::enablePropertiesWidget );
96  connect( mLeFilter, &QgsFilterLineEdit::returnPressed, this, &QgsBrowserDockWidget::setFilter );
97  connect( mLeFilter, &QgsFilterLineEdit::cleared, this, &QgsBrowserDockWidget::setFilter );
98  connect( mLeFilter, &QgsFilterLineEdit::textChanged, this, &QgsBrowserDockWidget::setFilter );
99  connect( group, &QActionGroup::triggered, this, &QgsBrowserDockWidget::setFilterSyntax );
100  connect( mBrowserView, &QgsDockBrowserTreeView::customContextMenuRequested, this, &QgsBrowserDockWidget::showContextMenu );
101  connect( mBrowserView, &QgsDockBrowserTreeView::doubleClicked, this, &QgsBrowserDockWidget::itemDoubleClicked );
102  connect( mSplitter, &QSplitter::splitterMoved, this, &QgsBrowserDockWidget::splitterMoved );
103 }
104 
106 {
107  QgsSettings settings;
108  settings.setValue( settingsSection() + "/propertiesWidgetEnabled", mPropertiesWidgetEnabled );
109  //settings.setValue(settingsSection() + "/propertiesWidgetHeight", mPropertiesWidget->size().height() );
110  settings.setValue( settingsSection() + "/propertiesWidgetHeight", mPropertiesWidgetHeight );
111 }
112 
113 void QgsBrowserDockWidget::showEvent( QShowEvent *e )
114 {
115  // delayed initialization of the model
116  if ( !mModel->initialized( ) )
117  {
118  mModel->initialize();
119  }
120  if ( ! mProxyModel )
121  {
122  mProxyModel = new QgsBrowserProxyModel( this );
123  mProxyModel->setBrowserModel( mModel );
124  mBrowserView->setSettingsSection( objectName().toLower() ); // to distinguish 2 or more instances of the browser
125  mBrowserView->setBrowserModel( mModel );
126  mBrowserView->setModel( mProxyModel );
127  mBrowserView->setSortingEnabled( true );
128  mBrowserView->sortByColumn( 0, Qt::AscendingOrder );
129  // provide a horizontal scroll bar instead of using ellipse (...) for longer items
130  mBrowserView->setTextElideMode( Qt::ElideNone );
131  mBrowserView->header()->setSectionResizeMode( 0, QHeaderView::ResizeToContents );
132  mBrowserView->header()->setStretchLastSection( false );
133 
134  // selectionModel is created when model is set on tree
135  connect( mBrowserView->selectionModel(), &QItemSelectionModel::selectionChanged,
137 
138  // Forward the model changed signals to the widget
139  connect( mModel, &QgsBrowserModel::connectionsChanged,
141 
142 
143  // objectName used by settingsSection() is not yet set in constructor
144  QgsSettings settings;
145  mPropertiesWidgetEnabled = settings.value( settingsSection() + "/propertiesWidgetEnabled", false ).toBool();
146  mActionPropertiesWidget->setChecked( mPropertiesWidgetEnabled );
147  mPropertiesWidget->setVisible( false ); // false until item is selected
148 
149  mPropertiesWidgetHeight = settings.value( settingsSection() + "/propertiesWidgetHeight" ).toFloat();
150  QList<int> sizes = mSplitter->sizes();
151  int total = sizes.value( 0 ) + sizes.value( 1 );
152  int height = static_cast<int>( total ) * mPropertiesWidgetHeight;
153  sizes.clear();
154  sizes << total - height << height;
155  mSplitter->setSizes( sizes );
156  }
157 
159 }
160 
161 void QgsBrowserDockWidget::itemDoubleClicked( const QModelIndex &index )
162 {
163  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( index ) );
164  if ( !item )
165  return;
166 
167  if ( item->handleDoubleClick() )
168  return;
169  else
170  addLayerAtIndex( index ); // default double-click handler
171 }
172 
173 void QgsBrowserDockWidget::renameFavorite()
174 {
175  QgsDataItem *dataItem = mModel->dataItem( mProxyModel->mapToSource( mBrowserView->currentIndex() ) );
176  if ( !dataItem )
177  return;
178 
179  QgsFavoriteItem *favorite = qobject_cast< QgsFavoriteItem * >( dataItem );
180  if ( !favorite )
181  return;
182 
183  QgsNewNameDialog dlg( tr( "favorite “%1”" ).arg( favorite->name() ), favorite->name() );
184  dlg.setWindowTitle( tr( "Rename Favorite" ) );
185  if ( dlg.exec() != QDialog::Accepted || dlg.name() == favorite->name() )
186  return;
187 
188  favorite->rename( dlg.name() );
189 }
190 
192 {
193  QModelIndex index = mProxyModel->mapToSource( mBrowserView->indexAt( pt ) );
194  QgsDataItem *item = mModel->dataItem( index );
195  if ( !item )
196  return;
197 
198  QMenu *menu = new QMenu( this );
199 
200  if ( item->type() == QgsDataItem::Directory )
201  {
202  QgsSettings settings;
203 
204  bool inFavDirs = item->parent() && item->parent()->type() == QgsDataItem::Favorites;
205  if ( item->parent() && !inFavDirs )
206  {
207  // only non-root directories can be added as favorites
208  QAction *addAsFavorite = new QAction( tr( "Add as a Favorite" ), this );
209  addAsFavorite->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFavourites.svg" ) ) );
210  menu->addAction( addAsFavorite );
211  connect( addAsFavorite, &QAction::triggered, this, &QgsBrowserDockWidget::addFavorite );
212  }
213  else if ( inFavDirs )
214  {
215  QAction *actionRename = new QAction( tr( "Rename Favorite…" ), this );
216  connect( actionRename, &QAction::triggered, this, &QgsBrowserDockWidget::renameFavorite );
217  menu->addAction( actionRename );
218  menu->addSeparator();
219  menu->addAction( tr( "Remove Favorite" ), this, SLOT( removeFavorite() ) );
220  menu->addSeparator();
221  }
222  menu->addAction( tr( "Properties…" ), this, SLOT( showProperties() ) );
223  menu->addAction( tr( "Hide from Browser" ), this, SLOT( hideItem() ) );
224  QAction *action = menu->addAction( tr( "Fast Scan this Directory" ), this, SLOT( toggleFastScan() ) );
225  action->setCheckable( true );
226  action->setChecked( settings.value( QStringLiteral( "qgis/scanItemsFastScanUris" ),
227  QStringList() ).toStringList().contains( item->path() ) );
228  }
229  else if ( item->type() == QgsDataItem::Layer )
230  {
231  menu->addAction( tr( "Add Selected Layer(s) to Canvas" ), this, SLOT( addSelectedLayers() ) );
232  menu->addAction( tr( "Properties…" ), this, SLOT( showProperties() ) );
233  }
234  else if ( item->type() == QgsDataItem::Favorites )
235  {
236  menu->addAction( tr( "Add a Directory…" ), this, SLOT( addFavoriteDirectory() ) );
237  }
238 
239  const QList<QMenu *> menus = item->menus( menu );
240  QList<QAction *> actions = item->actions( menu );
241 
242  if ( !menus.isEmpty() )
243  {
244  for ( QMenu *mn : menus )
245  {
246  menu->addMenu( mn );
247  }
248  }
249 
250  if ( !actions.isEmpty() )
251  {
252  if ( !menu->actions().isEmpty() )
253  menu->addSeparator();
254  // add action to the menu
255  menu->addActions( actions );
256  }
257 
258  if ( menu->actions().isEmpty() )
259  {
260  delete menu;
261  return;
262  }
263 
264  menu->popup( mBrowserView->mapToGlobal( pt ) );
265 }
266 
268 {
269  QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() );
270  QgsDataItem *item = mModel->dataItem( index );
271  if ( !item )
272  return;
273 
274  QgsDirectoryItem *dirItem = dynamic_cast<QgsDirectoryItem *>( item );
275  if ( !dirItem )
276  return;
277 
278  addFavoriteDirectory( dirItem->dirPath() );
279 }
280 
282 {
283  QString directory = QFileDialog::getExistingDirectory( this, tr( "Add directory to favorites" ) );
284  if ( !directory.isEmpty() )
285  {
286  addFavoriteDirectory( directory );
287  }
288 }
289 
290 void QgsBrowserDockWidget::addFavoriteDirectory( const QString &favDir, const QString &name )
291 {
292  mModel->addFavoriteDirectory( favDir, name );
293 }
294 
296 {
297  mModel->removeFavorite( mProxyModel->mapToSource( mBrowserView->currentIndex() ) );
298 }
299 
301 {
302  refreshModel( QModelIndex() );
303 }
304 
305 void QgsBrowserDockWidget::refreshModel( const QModelIndex &index )
306 {
307  if ( mModel && mProxyModel )
308  {
309  QgsDataItem *item = mModel->dataItem( index );
310  if ( item )
311  {
312  QgsDebugMsgLevel( "path = " + item->path(), 4 );
313  }
314  else
315  {
316  QgsDebugMsgLevel( QStringLiteral( "invalid item" ), 4 );
317  }
318 
319  if ( item && ( item->capabilities2() & QgsDataItem::Fertile ) )
320  {
321  mModel->refresh( index );
322  }
323 
324  for ( int i = 0; i < mModel->rowCount( index ); i++ )
325  {
326  QModelIndex idx = mModel->index( i, 0, index );
327  QModelIndex proxyIdx = mProxyModel->mapFromSource( idx );
328  QgsDataItem *child = mModel->dataItem( idx );
329 
330  // Check also expanded descendants so that the whole expanded path does not get collapsed if one item is collapsed.
331  // Fast items (usually root items) are refreshed so that when collapsed, it is obvious they are if empty (no expand symbol).
332  if ( mBrowserView->isExpanded( proxyIdx ) || mBrowserView->hasExpandedDescendant( proxyIdx ) || ( child && child->capabilities2() & QgsDataItem::Fast ) )
333  {
334  refreshModel( idx );
335  }
336  else
337  {
338  if ( child && ( child->capabilities2() & QgsDataItem::Fertile ) )
339  {
340  child->depopulate();
341  }
342  }
343  }
344  }
345 }
346 
347 void QgsBrowserDockWidget::addLayer( QgsLayerItem *layerItem )
348 {
349  if ( !layerItem )
350  return;
351 
353  list << layerItem->mimeUri();
354  emit handleDropUriList( list );
355 }
356 
357 void QgsBrowserDockWidget::addLayerAtIndex( const QModelIndex &index )
358 {
359  QgsDebugMsg( QStringLiteral( "rowCount() = %1" ).arg( mModel->rowCount( mProxyModel->mapToSource( index ) ) ) );
360  QgsDataItem *item = mModel->dataItem( mProxyModel->mapToSource( index ) );
361 
362  if ( item && item->type() == QgsDataItem::Project )
363  {
364  QgsProjectItem *projectItem = qobject_cast<QgsProjectItem *>( item );
365  if ( projectItem )
366  {
367  QApplication::setOverrideCursor( Qt::WaitCursor );
368  emit openFile( projectItem->path(), QStringLiteral( "project" ) );
369  QApplication::restoreOverrideCursor();
370  }
371  }
372  if ( item && item->type() == QgsDataItem::Layer )
373  {
374  QgsLayerItem *layerItem = qobject_cast<QgsLayerItem *>( item );
375  if ( layerItem )
376  {
377  QApplication::setOverrideCursor( Qt::WaitCursor );
378  addLayer( layerItem );
379  QApplication::restoreOverrideCursor();
380  }
381  }
382 }
383 
385 {
386  QApplication::setOverrideCursor( Qt::WaitCursor );
387 
388  // get a sorted list of selected indexes
389  QModelIndexList list = mBrowserView->selectionModel()->selectedIndexes();
390  std::sort( list.begin(), list.end() );
391 
392  // If any of the layer items are QGIS we just open and exit the loop
393  Q_FOREACH ( const QModelIndex &index, list )
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 void QgsBrowserDockWidget::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
529 {
530  Q_UNUSED( selected );
531  Q_UNUSED( deselected );
532  if ( mPropertiesWidgetEnabled )
533  {
534  setPropertiesWidget();
535  }
536 }
537 
538 void QgsBrowserDockWidget::clearPropertiesWidget()
539 {
540  while ( mPropertiesLayout->count() > 0 )
541  {
542  delete mPropertiesLayout->itemAt( 0 )->widget();
543  }
544  mPropertiesWidget->setVisible( false );
545 }
546 
547 void QgsBrowserDockWidget::setPropertiesWidget()
548 {
549  clearPropertiesWidget();
550  QItemSelectionModel *selectionModel = mBrowserView->selectionModel();
551  if ( selectionModel )
552  {
553  QModelIndexList indexes = selectionModel->selectedIndexes();
554  if ( indexes.size() == 1 )
555  {
556  QModelIndex index = mProxyModel->mapToSource( indexes.value( 0 ) );
557  QgsDataItem *item = mModel->dataItem( index );
558  QgsBrowserPropertiesWidget *propertiesWidget = QgsBrowserPropertiesWidget::createWidget( item, mPropertiesWidget );
559  if ( propertiesWidget )
560  {
561  propertiesWidget->setCondensedMode( true );
562  mPropertiesLayout->addWidget( propertiesWidget );
563  }
564  }
565  }
566  mPropertiesWidget->setVisible( mPropertiesLayout->count() > 0 );
567 }
568 
570 {
571  mPropertiesWidgetEnabled = enable;
572  if ( enable && selectedItemsCount() == 1 )
573  {
574  setPropertiesWidget();
575  }
576  else
577  {
578  clearPropertiesWidget();
579  }
580 }
581 
583 {
584  QList<int> sizes = mSplitter->sizes();
585  float total = sizes.value( 0 ) + sizes.value( 1 );
586  mPropertiesWidgetHeight = total > 0 ? sizes.value( 1 ) / total : 0;
587 }
virtual QList< QMenu * > menus(QWidget *parent)
Returns the list of menus available for this item.
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.
virtual Capabilities capabilities2() const
Returns the capabilities for the data item.
Definition: qgsdataitem.h:248
This class is a composition of two QSettings instances:
Definition: qgssettings.h:58
QgsDataItem * parent() const
Gets item parent.
Definition: qgsdataitem.h:269
int rowCount(const QModelIndex &parent=QModelIndex()) const override
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
void addFavoriteDirectory()
Add directory from file dialog to favorite.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setBrowserModel(QgsBrowserModel *model)
Sets the underlying browser model.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
virtual void depopulate()
Remove children recursively and set as not populated. This is used when refreshing collapsed items...
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.
void setFilter()
Apply filter to the model.
void showContextMenu(QPoint)
Show context menu.
void addFavorite()
Add current item to favorite.
QString dirPath() const
Definition: qgsdataitem.h:600
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QgsDataItem * dataItem(const QModelIndex &idx) const
Returns the data item at the specified index, or a nullptr if no item exists at the index...
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.
QString path() const
Definition: qgsdataitem.h:292
void initialize()
Delayed initialization, needed because the provider registry must be already populated.
void removeFavorite(const QModelIndex &index)
Removes a favorite directory from its corresponding model index.
Type type() const
Definition: qgsdataitem.h:264
void handleDropUriList(const QgsMimeDataUtils::UriList &)
Emitted when drop uri list needs to be handled.
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:571
void showEvent(QShowEvent *event) override
void showProperties()
Show the layer properties.
Base class for all items in the model.
Definition: qgsdataitem.h:49
bool initialized() const
Returns true if the model has been initialized.
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.
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:435
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:629
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.