QGIS API Documentation  2.99.0-Master (7d4f81d)
qgsbrowsermodel.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsbrowsermodel.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 <QDir>
16 #include <QApplication>
17 #include <QStyle>
18 #include <QtConcurrentMap>
19 #include <QUrl>
20 
21 #include "qgis.h"
22 #include "qgsapplication.h"
23 #include "qgsdataitemprovider.h"
25 #include "qgsdataprovider.h"
26 #include "qgsmimedatautils.h"
27 #include "qgslogger.h"
28 #include "qgsproviderregistry.h"
29 #include "qgsbrowsermodel.h"
30 #include "qgsproject.h"
31 #include "qgssettings.h"
32 
34  : mItem( item )
35 {
36 }
37 
38 // sort function for QList<QgsDataItem*>, e.g. sorted/grouped provider listings
39 static bool cmpByDataItemName_( QgsDataItem *a, QgsDataItem *b )
40 {
41  return QString::localeAwareCompare( a->name(), b->name() ) < 0;
42 }
43 
45  : QAbstractItemModel( parent )
46  , mFavorites( nullptr )
47  , mProjectHome( nullptr )
48 {
51  addRootItems();
52 }
53 
55 {
57 }
58 
60 {
61  QString home = QgsProject::instance()->homePath();
62  if ( mProjectHome && mProjectHome->path() == home )
63  return;
64 
65  int idx = mRootItems.indexOf( mProjectHome );
66 
67  // using layoutAboutToBeChanged() was messing expanded items
68  if ( idx >= 0 )
69  {
70  beginRemoveRows( QModelIndex(), idx, idx );
71  mRootItems.remove( idx );
72  endRemoveRows();
73  }
74  delete mProjectHome;
75  mProjectHome = home.isNull() ? nullptr : new QgsDirectoryItem( nullptr, tr( "Project home" ), home, "project:" + home );
76  if ( mProjectHome )
77  {
79 
80  beginInsertRows( QModelIndex(), 0, 0 );
81  mRootItems.insert( 0, mProjectHome );
82  endInsertRows();
83  }
84 }
85 
87 {
89 
90  // give the home directory a prominent second place
91  QgsDirectoryItem *item = new QgsDirectoryItem( nullptr, tr( "Home" ), QDir::homePath(), "home:" + QDir::homePath() );
92  QStyle *style = QApplication::style();
93  QIcon homeIcon( style->standardPixmap( QStyle::SP_DirHomeIcon ) );
94  item->setIcon( homeIcon );
95  connectItem( item );
96  mRootItems << item;
97 
98  // add favorite directories
99  mFavorites = new QgsFavoritesItem( nullptr, tr( "Favorites" ) );
100  if ( mFavorites )
101  {
104  }
105 
106  // add drives
107  Q_FOREACH ( const QFileInfo &drive, QDir::drives() )
108  {
109  QString path = drive.absolutePath();
110 
111  if ( QgsDirectoryItem::hiddenPath( path ) )
112  continue;
113 
114  QgsDirectoryItem *item = new QgsDirectoryItem( nullptr, path, path );
115 
116  connectItem( item );
117  mRootItems << item;
118  }
119 
120 #ifdef Q_OS_MAC
121  QString path = QString( "/Volumes" );
122  QgsDirectoryItem *vols = new QgsDirectoryItem( nullptr, path, path );
123  connectItem( vols );
124  mRootItems << vols;
125 #endif
126 
127  // container for displaying providers as sorted groups (by QgsDataProvider::DataCapability enum)
128  QMap<int, QgsDataItem *> providerMap;
129 
130  Q_FOREACH ( QgsDataItemProvider *pr, QgsApplication::dataItemProviderRegistry()->providers() )
131  {
132  int capabilities = pr->capabilities();
133  if ( capabilities == QgsDataProvider::NoDataCapabilities )
134  {
135  QgsDebugMsgLevel( pr->name() + " does not have any dataCapabilities", 4 );
136  continue;
137  }
138 
139  QgsDataItem *item = pr->createDataItem( QLatin1String( "" ), nullptr ); // empty path -> top level
140  if ( item )
141  {
142  // Forward the signal from the root items to the model (and then to the app)
144  QgsDebugMsgLevel( "Add new top level item : " + item->name(), 4 );
145  connectItem( item );
146  providerMap.insertMulti( capabilities, item );
147  }
148  }
149 
150  // add as sorted groups by QgsDataProvider::DataCapability enum
151  Q_FOREACH ( int key, providerMap.uniqueKeys() )
152  {
153  QList<QgsDataItem *> providerGroup = providerMap.values( key );
154  if ( providerGroup.size() > 1 )
155  {
156  std::sort( providerGroup.begin(), providerGroup.end(), cmpByDataItemName_ );
157  }
158 
159  Q_FOREACH ( QgsDataItem *ditem, providerGroup )
160  {
161  mRootItems << ditem;
162  }
163  }
164 }
165 
167 {
168  Q_FOREACH ( QgsDataItem *item, mRootItems )
169  {
170  delete item;
171  }
172 
173  mRootItems.clear();
174 }
175 
176 
177 Qt::ItemFlags QgsBrowserModel::flags( const QModelIndex &index ) const
178 {
179  if ( !index.isValid() )
180  return Qt::ItemFlags();
181 
182  Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
183 
184  QgsDataItem *ptr = reinterpret_cast< QgsDataItem * >( index.internalPointer() );
185  if ( ptr->hasDragEnabled() )
186  flags |= Qt::ItemIsDragEnabled;
187 
188  if ( ptr->acceptDrop() )
189  flags |= Qt::ItemIsDropEnabled;
190  return flags;
191 }
192 
193 QVariant QgsBrowserModel::data( const QModelIndex &index, int role ) const
194 {
195  if ( !index.isValid() )
196  return QVariant();
197 
198  QgsDataItem *item = dataItem( index );
199  if ( !item )
200  {
201  return QVariant();
202  }
203  else if ( role == Qt::DisplayRole )
204  {
205  return item->name();
206  }
207  else if ( role == Qt::ToolTipRole )
208  {
209  return item->toolTip();
210  }
211  else if ( role == Qt::DecorationRole && index.column() == 0 )
212  {
213  return item->icon();
214  }
215  else if ( role == QgsBrowserModel::PathRole )
216  {
217  return item->path();
218  }
219  else if ( role == QgsBrowserModel::CommentRole )
220  {
221  if ( item->type() == QgsDataItem::Layer )
222  {
223  QgsLayerItem *lyrItem = qobject_cast<QgsLayerItem *>( item );
224  return lyrItem->comments();
225  }
226  return QVariant();
227  }
228  else
229  {
230  // unsupported role
231  return QVariant();
232  }
233 }
234 
235 QVariant QgsBrowserModel::headerData( int section, Qt::Orientation orientation, int role ) const
236 {
237  Q_UNUSED( section );
238  if ( orientation == Qt::Horizontal && role == Qt::DisplayRole )
239  {
240  return QVariant( "header" );
241  }
242 
243  return QVariant();
244 }
245 
246 int QgsBrowserModel::rowCount( const QModelIndex &parent ) const
247 {
248  //QgsDebugMsg(QString("isValid = %1 row = %2 column = %3").arg(parent.isValid()).arg(parent.row()).arg(parent.column()));
249 
250  if ( !parent.isValid() )
251  {
252  // root item: its children are top level items
253  return mRootItems.count(); // mRoot
254  }
255  else
256  {
257  // ordinary item: number of its children
258  QgsDataItem *item = dataItem( parent );
259  //if ( item ) QgsDebugMsg(QString("path = %1 rowCount = %2").arg(item->path()).arg(item->rowCount()) );
260  return item ? item->rowCount() : 0;
261  }
262 }
263 
264 bool QgsBrowserModel::hasChildren( const QModelIndex &parent ) const
265 {
266  if ( !parent.isValid() )
267  return true; // root item: its children are top level items
268 
269  QgsDataItem *item = dataItem( parent );
270  return item && item->hasChildren();
271 }
272 
273 int QgsBrowserModel::columnCount( const QModelIndex &parent ) const
274 {
275  Q_UNUSED( parent );
276  return 1;
277 }
278 
279 QModelIndex QgsBrowserModel::findPath( const QString &path, Qt::MatchFlag matchFlag )
280 {
281  return findPath( this, path, matchFlag );
282 }
283 
284 QModelIndex QgsBrowserModel::findPath( QAbstractItemModel *model, const QString &path, Qt::MatchFlag matchFlag )
285 {
286  if ( !model )
287  return QModelIndex();
288 
289  QModelIndex index; // starting from root
290  bool foundChild = true;
291 
292  while ( foundChild )
293  {
294  foundChild = false; // assume that the next child item will not be found
295 
296  for ( int i = 0; i < model->rowCount( index ); i++ )
297  {
298  QModelIndex idx = model->index( i, 0, index );
299 
300  QString itemPath = model->data( idx, PathRole ).toString();
301  if ( itemPath == path )
302  {
303  QgsDebugMsgLevel( "Arrived " + itemPath, 4 );
304  return idx; // we have found the item we have been looking for
305  }
306 
307  // paths are slash separated identifier
308  if ( path.startsWith( itemPath + '/' ) )
309  {
310  foundChild = true;
311  index = idx;
312  break;
313  }
314  }
315  }
316 
317  if ( matchFlag == Qt::MatchStartsWith )
318  return index;
319 
320  QgsDebugMsgLevel( "path not found", 4 );
321  return QModelIndex(); // not found
322 }
323 
325 {
326  // TODO: put items creating currently children in threads to deleteLater (does not seem urget because reload() is not used in QGIS)
327  beginResetModel();
328  removeRootItems();
329  addRootItems();
330  endResetModel();
331 }
332 
333 QModelIndex QgsBrowserModel::index( int row, int column, const QModelIndex &parent ) const
334 {
335  if ( column < 0 || column >= columnCount() || row < 0 )
336  return QModelIndex();
337 
338  QgsDataItem *p = dataItem( parent );
339  const QVector<QgsDataItem *> &items = p ? p->children() : mRootItems;
340  QgsDataItem *item = items.value( row, nullptr );
341  return item ? createIndex( row, column, item ) : QModelIndex();
342 }
343 
344 QModelIndex QgsBrowserModel::parent( const QModelIndex &index ) const
345 {
346  QgsDataItem *item = dataItem( index );
347  if ( !item )
348  return QModelIndex();
349 
350  return findItem( item->parent() );
351 }
352 
354 {
355  const QVector<QgsDataItem *> &items = parent ? parent->children() : mRootItems;
356 
357  for ( int i = 0; i < items.size(); i++ )
358  {
359  if ( items[i] == item )
360  return createIndex( i, 0, item );
361 
362  QModelIndex childIndex = findItem( item, items[i] );
363  if ( childIndex.isValid() )
364  return childIndex;
365  }
366 
367  return QModelIndex();
368 }
369 
371 {
372  QgsDebugMsgLevel( "parent mPath = " + parent->path(), 3 );
373  QModelIndex idx = findItem( parent );
374  if ( !idx.isValid() )
375  return;
376  QgsDebugMsgLevel( "valid", 3 );
377  beginInsertRows( idx, first, last );
378  QgsDebugMsgLevel( "end", 3 );
379 }
381 {
382  QgsDebugMsgLevel( "Entered", 3 );
383  endInsertRows();
384 }
386 {
387  QgsDebugMsgLevel( "parent mPath = " + parent->path(), 3 );
388  QModelIndex idx = findItem( parent );
389  if ( !idx.isValid() )
390  return;
391  beginRemoveRows( idx, first, last );
392 }
394 {
395  QgsDebugMsgLevel( "Entered", 3 );
396  endRemoveRows();
397 }
399 {
400  QgsDebugMsgLevel( "Entered", 3 );
401  QModelIndex idx = findItem( item );
402  if ( !idx.isValid() )
403  return;
404  emit dataChanged( idx, idx );
405 }
407 {
408  if ( !item )
409  return;
410  QModelIndex idx = findItem( item );
411  if ( !idx.isValid() )
412  return;
413  QgsDebugMsgLevel( QString( "item %1 state changed %2 -> %3" ).arg( item->path() ).arg( oldState ).arg( item->state() ), 4 );
414  emit stateChanged( idx, oldState );
415 }
416 
418 {
419  connect( item, &QgsDataItem::beginInsertItems,
421  connect( item, &QgsDataItem::endInsertItems,
423  connect( item, &QgsDataItem::beginRemoveItems,
425  connect( item, &QgsDataItem::endRemoveItems,
427  connect( item, &QgsDataItem::dataChanged,
429  connect( item, &QgsDataItem::stateChanged,
431 
432  // if it's a collection item, also forwards connectionsChanged
433  QgsDataCollectionItem *collectionItem = dynamic_cast<QgsDataCollectionItem *>( item );
434  if ( collectionItem )
436 }
437 
438 QStringList QgsBrowserModel::mimeTypes() const
439 {
440  QStringList types;
441  // In theory the mime type convention is: application/x-vnd.<vendor>.<application>.<type>
442  // but it seems a bit over formalized. Would be an application/x-qgis-uri better?
443  types << QStringLiteral( "application/x-vnd.qgis.qgis.uri" );
444  return types;
445 }
446 
447 QMimeData *QgsBrowserModel::mimeData( const QModelIndexList &indexes ) const
448 {
450  Q_FOREACH ( const QModelIndex &index, indexes )
451  {
452  if ( index.isValid() )
453  {
454  QgsDataItem *ptr = reinterpret_cast< QgsDataItem * >( index.internalPointer() );
455  if ( ptr->type() == QgsDataItem::Project )
456  {
457  QMimeData *mimeData = new QMimeData();
458  QUrl url = QUrl::fromLocalFile( ptr->path() );
459  QList<QUrl> urls;
460  urls << url;
461  mimeData->setUrls( urls );
462  return mimeData;
463  }
464 
465  QgsMimeDataUtils::Uri uri = ptr->mimeUri();
466  if ( uri.isValid() )
467  lst.append( uri );
468  }
469  }
470  return QgsMimeDataUtils::encodeUriList( lst );
471 }
472 
473 bool QgsBrowserModel::dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent )
474 {
475  Q_UNUSED( row );
476  Q_UNUSED( column );
477 
478  QgsDataItem *destItem = dataItem( parent );
479  if ( !destItem )
480  {
481  QgsDebugMsgLevel( "DROP PROBLEM!", 4 );
482  return false;
483  }
484 
485  return destItem->handleDrop( data, action );
486 }
487 
488 QgsDataItem *QgsBrowserModel::dataItem( const QModelIndex &idx ) const
489 {
490  void *v = idx.internalPointer();
491  QgsDataItem *d = reinterpret_cast<QgsDataItem *>( v );
492  Q_ASSERT( !v || d );
493  return d;
494 }
495 
496 bool QgsBrowserModel::canFetchMore( const QModelIndex &parent ) const
497 {
498  QgsDataItem *item = dataItem( parent );
499  // if ( item )
500  // QgsDebugMsg( QString( "path = %1 canFetchMore = %2" ).arg( item->path() ).arg( item && ! item->isPopulated() ) );
501  return ( item && item->state() == QgsDataItem::NotPopulated );
502 }
503 
504 void QgsBrowserModel::fetchMore( const QModelIndex &parent )
505 {
506  QgsDataItem *item = dataItem( parent );
507 
508  if ( !item || item->state() == QgsDataItem::Populating || item->state() == QgsDataItem::Populated )
509  return;
510 
511  QgsDebugMsgLevel( "path = " + item->path(), 4 );
512 
513  item->populate();
514 }
515 
516 /* Refresh dir path */
517 void QgsBrowserModel::refresh( const QString &path )
518 {
519  QModelIndex index = findPath( path );
520  refresh( index );
521 }
522 
523 /* Refresh item */
524 void QgsBrowserModel::refresh( const QModelIndex &index )
525 {
526  QgsDataItem *item = dataItem( index );
527  if ( !item || item->state() == QgsDataItem::Populating )
528  return;
529 
530  QgsDebugMsgLevel( "Refresh " + item->path(), 4 );
531 
532  item->refresh();
533 }
534 
535 void QgsBrowserModel::addFavoriteDirectory( const QString &directory )
536 {
537  Q_ASSERT( mFavorites );
538  mFavorites->addDirectory( directory );
539 }
540 
541 void QgsBrowserModel::removeFavorite( const QModelIndex &index )
542 {
543  QgsDirectoryItem *item = dynamic_cast<QgsDirectoryItem *>( dataItem( index ) );
544  if ( !item )
545  return;
546 
547  mFavorites->removeDirectory( item );
548 }
549 
551 {
552  QgsSettings settings;
553  QStringList hiddenItems = settings.value( QStringLiteral( "browser/hiddenPaths" ),
554  QStringList() ).toStringList();
555  int idx = hiddenItems.indexOf( item->path() );
556  if ( idx != -1 )
557  {
558  hiddenItems.removeAt( idx );
559  }
560  else
561  {
562  hiddenItems << item->path();
563  }
564  settings.setValue( QStringLiteral( "browser/hiddenPaths" ), hiddenItems );
565  if ( item->parent() )
566  {
567  item->parent()->deleteChildItem( item );
568  }
569  else
570  {
571  int i = mRootItems.indexOf( item );
572  emit beginRemoveRows( QModelIndex(), i, i );
573  mRootItems.remove( i );
574  item->deleteLater();
575  emit endRemoveRows();
576  }
577 }
A Collection: logical collection of layers or subcollections, e.g.
Definition: qgsdataitem.h:419
void beginInsertItems(QgsDataItem *parent, int first, int last)
QString path() const
Definition: qgsdataitem.h:214
bool canFetchMore(const QModelIndex &parent) const override
QString name() const
Definition: qgsdataitem.h:212
void connectionsChanged()
Connections changed in the browser, forwarded to the widget and used to notify the provider dialogs o...
void dataChanged(QgsDataItem *item)
QString toolTip() const
Definition: qgsdataitem.h:226
void hidePath(QgsDataItem *item)
Hide the given path in the browser model.
QgsBrowserModel(QObject *parent=nullptr)
This class is a composition of two QSettings instances:
Definition: qgssettings.h:54
virtual QgsDataItem * createDataItem(const QString &path, QgsDataItem *parentItem)=0
Create a new instance of QgsDataItem (or null) for given path and parent item.
void addDirectory(const QString &directory)
Adds a new directory to the favorites group.
void connectionsChanged()
Emitted when the provider&#39;s connections of the child items have changed This signal is normally forwa...
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
Provides the number of rows of data exposed by the model.
void fetchMore(const QModelIndex &parent) override
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Used to supply item data to views and delegates.
virtual bool handleDrop(const QMimeData *, Qt::DropAction)
Attempts to process the mime data dropped on this item.
Definition: qgsdataitem.h:153
QModelIndex findPath(const QString &path, Qt::MatchFlag matchFlag=Qt::MatchExactly)
Return index of item with given path.
void beginRemoveItems(QgsDataItem *parent, int first, int last)
virtual QIcon icon()
void connectItem(QgsDataItem *item)
Type type() const
Definition: qgsdataitem.h:201
static QMimeData * encodeUriList(const UriList &layers)
void setIcon(const QIcon &icon)
Definition: qgsdataitem.h:222
bool isValid() const
Returns whether the object contains valid data.
void itemStateChanged(QgsDataItem *item, QgsDataItem::State oldState)
virtual QStringList mimeTypes() const override
Returns a list of mime that can describe model indexes.
bool hasChildren(const QModelIndex &parent=QModelIndex()) const override
void endRemoveItems()
State state() const
Item path used to access path in the tree, see QgsDataItem::mPath.
QString homePath
Definition: qgsproject.h:84
QgsDirectoryItem * mProjectHome
void setValue(const QString &key, const QVariant &value, const QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
static void deleteLater(QVector< QgsDataItem *> &items)
QgsDataItem * parent() const
Get item parent.
Definition: qgsdataitem.h:205
QgsFavoritesItem * mFavorites
void beginRemoveItems(QgsDataItem *parent, int first, int last)
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:38
virtual QModelIndex parent(const QModelIndex &index) const override
Returns the parent of the model item with the given index.
QVector< QgsDataItem * > mRootItems
void readProject(const QDomDocument &)
emitted when project is being read
Children not yet created.
Definition: qgsdataitem.h:99
Creating children in separate thread (populating or refreshing)
Definition: qgsdataitem.h:100
QgsDataItem * dataItem(const QModelIndex &idx) const
void removeFavorite(const QModelIndex &index)
Removes a favorite directory from its corresponding model index.
virtual bool hasDragEnabled() const
Returns true if the item may be dragged.
Definition: qgsdataitem.h:161
virtual int capabilities()=0
Return combination of flags from QgsDataProvider::DataCapabilities.
virtual QgsMimeDataUtils::Uri mimeUri() const
Return mime URI for the data item.
Definition: qgsdataitem.h:168
QgsBrowserWatcher(QgsDataItem *item)
bool hasChildren()
static bool hiddenPath(const QString &path)
Check if the given path is hidden from the browser model.
void reload()
Reload the whole model.
A directory: contains subdirectories and layers.
Definition: qgsdataitem.h:435
Base class for all items in the model.
Definition: qgsdataitem.h:47
QVector< QgsDataItem * > children() const
Definition: qgsdataitem.h:210
QModelIndex findItem(QgsDataItem *item, QgsDataItem *parent=nullptr) const
void writeProject(QDomDocument &)
emitted when project is being written
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Provides views with information to show in their headers.
void beginInsertItems(QgsDataItem *parent, int first, int last)
Contains various Favorites directories.
Definition: qgsdataitem.h:541
void removeDirectory(QgsDirectoryItem *item)
Removes an existing directory from the favorites group.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), const Section section=NoSection) const
Returns the value for setting key.
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Returns the index of the item in the model specified by the given row, column and parent index...
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:379
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const override
Provides the number of columns of data exposed by the model.
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Handles the data supplied by a drag and drop operation that ended with the given action.
void stateChanged(const QModelIndex &index, QgsDataItem::State oldState)
Emitted when item children fetch was finished.
void refresh(const QString &path)
Refresh item specified by path.
QList< QgsMimeDataUtils::Uri > UriList
void endInsertItems()
virtual QMimeData * mimeData(const QModelIndexList &indexes) const override
Returns an object that contains serialized items of data corresponding to the list of indexes specifi...
Represents a QGIS project.
Definition: qgsdataitem.h:82
Item that represents a layer that can be opened with one of the providers.
Definition: qgsdataitem.h:328
virtual void deleteChildItem(QgsDataItem *child)
Removes and deletes a child item, emitting relevant signals to the model.
virtual QString name()=0
Human-readable name of the provider name.
void itemDataChanged(QgsDataItem *item)
void addFavoriteDirectory(const QString &directory)
Adds a directory to the favorites group.
virtual Qt::ItemFlags flags(const QModelIndex &index) const override
Used by other components to obtain information about each item provided by the model.
virtual void populate(const QVector< QgsDataItem *> &children)
Children created.
Definition: qgsdataitem.h:101
virtual bool acceptDrop()
Returns whether the item accepts drag and dropped layers - e.g.
Definition: qgsdataitem.h:147
virtual QString comments() const
Returns comments of the layer.
Definition: qgsdataitem.h:383
void addRootItems()
Populates the model.
static QgsDataItemProviderRegistry * dataItemProviderRegistry()
Returns the application&#39;s data item provider registry, which keeps a list of data item providers that...
virtual void refresh(const QVector< QgsDataItem *> &children)
Refresh the items from a specified list of child items.
This is the interface for those who want to add custom data items to the browser tree.
void stateChanged(QgsDataItem *item, QgsDataItem::State oldState)