QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsdirectoryitem.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsddirectoryitem.cpp
3  -------------------
4  begin : 2011-04-01
5  copyright : (C) 2011 Radim Blazek
6  email : radim dot blazek at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "qgsdirectoryitem.h"
19 #include "qgssettings.h"
20 #include "qgsapplication.h"
21 #include "qgsdataitemprovider.h"
23 #include "qgsdataprovider.h"
24 #include "qgszipitem.h"
25 #include "qgsprojectitem.h"
26 #include "qgsfileutils.h"
27 #include <QFileSystemWatcher>
28 #include <QDir>
29 #include <QMouseEvent>
30 #include <QTimer>
31 #include <QMenu>
32 #include <QAction>
33 
34 //
35 // QgsDirectoryItem
36 //
37 
38 QgsDirectoryItem::QgsDirectoryItem( QgsDataItem *parent, const QString &name, const QString &path )
39  : QgsDataCollectionItem( parent, QDir::toNativeSeparators( name ), path )
40  , mDirPath( path )
41 {
42  init();
43 }
44 
45 QgsDirectoryItem::QgsDirectoryItem( QgsDataItem *parent, const QString &name,
46  const QString &dirPath, const QString &path,
47  const QString &providerKey )
48  : QgsDataCollectionItem( parent, QDir::toNativeSeparators( name ), path, providerKey )
49  , mDirPath( dirPath )
50 {
51  init();
52 }
53 
55 {
57  setToolTip( QDir::toNativeSeparators( mDirPath ) );
58 
59  QgsSettings settings;
60 
61  mMonitoring = monitoringForPath( mDirPath );
62  switch ( mMonitoring )
63  {
66  break;
68  mMonitored = false;
69  break;
71  mMonitored = true;
72  break;
73  }
74 
75  settings.beginGroup( QStringLiteral( "qgis/browserPathColors" ) );
76  QString settingKey = mDirPath;
77  settingKey.replace( '/', QLatin1String( "|||" ) );
78  if ( settings.childKeys().contains( settingKey ) )
79  {
80  const QString colorString = settings.value( settingKey ).toString();
81  mIconColor = QColor( colorString );
82  }
83  settings.endGroup();
84 }
85 
87 {
88  mMonitoring = monitoringForPath( mDirPath );
89  switch ( mMonitoring )
90  {
93  break;
95  mMonitored = false;
96  break;
98  mMonitored = true;
99  break;
100  }
101 
102  const QVector<QgsDataItem *> childItems = children();
103  for ( QgsDataItem *child : childItems )
104  {
105  if ( QgsDirectoryItem *dirItem = qobject_cast< QgsDirectoryItem *>( child ) )
106  dirItem->reevaluateMonitoring();
107  }
108 
109  createOrDestroyFileSystemWatcher();
110 }
111 
112 void QgsDirectoryItem::createOrDestroyFileSystemWatcher()
113 {
114  if ( !mMonitored && mFileSystemWatcher )
115  {
116  mFileSystemWatcher->deleteLater();
117  mFileSystemWatcher = nullptr;
118  }
119  else if ( mMonitored && state() == Qgis::BrowserItemState::Populated && !mFileSystemWatcher )
120  {
121  mFileSystemWatcher = new QFileSystemWatcher( this );
122  mFileSystemWatcher->addPath( mDirPath );
123  connect( mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &QgsDirectoryItem::directoryChanged );
124  }
125 }
126 
128 {
129  return mIconColor;
130 }
131 
132 void QgsDirectoryItem::setIconColor( const QColor &color )
133 {
134  if ( color == mIconColor )
135  return;
136 
137  mIconColor = color;
138  emit dataChanged( this );
139 }
140 
141 void QgsDirectoryItem::setCustomColor( const QString &directory, const QColor &color )
142 {
143  QgsSettings settings;
144  settings.beginGroup( QStringLiteral( "qgis/browserPathColors" ) );
145  QString settingKey = directory;
146  settingKey.replace( '/', QLatin1String( "|||" ) );
147  if ( color.isValid() )
148  settings.setValue( settingKey, color.name( QColor::HexArgb ) );
149  else
150  settings.remove( settingKey );
151  settings.endGroup();
152 }
153 
155 {
156  if ( mDirPath == QDir::homePath() )
157  return homeDirIcon( mIconColor, mIconColor.darker() );
158 
159  // still loading? show the spinner
161  return QgsDataItem::icon();
162 
163  // symbolic link? use link icon
164  QFileInfo fi( mDirPath );
165  if ( fi.isDir() && fi.isSymLink() )
166  {
167  return mIconColor.isValid()
168  ? QgsApplication::getThemeIcon( QStringLiteral( "/mIconFolderLinkParams.svg" ), mIconColor, mIconColor.darker() )
169  : QgsApplication::getThemeIcon( QStringLiteral( "/mIconFolderLink.svg" ) );
170  }
171 
172  // loaded? show the open dir icon
174  return openDirIcon( mIconColor, mIconColor.darker() );
175 
176  // show the closed dir icon
177  return iconDir( mIconColor, mIconColor.darker() );
178 }
179 
181 {
182  return mMonitoring;
183 }
184 
186 {
187  mMonitoring = monitoring;
188 
189  QgsSettings settings;
190  QStringList noMonitorDirs = settings.value( QStringLiteral( "qgis/disableMonitorItemUris" ), QStringList() ).toStringList();
191  QStringList alwaysMonitorDirs = settings.value( QStringLiteral( "qgis/alwaysMonitorItemUris" ), QStringList() ).toStringList();
192 
193  switch ( mMonitoring )
194  {
196  {
197  // remove disable/always setting for this path, so that default behavior is used
198  noMonitorDirs.removeAll( mDirPath );
199  settings.setValue( QStringLiteral( "qgis/disableMonitorItemUris" ), noMonitorDirs );
200 
201  alwaysMonitorDirs.removeAll( mDirPath );
202  settings.setValue( QStringLiteral( "qgis/alwaysMonitorItemUris" ), alwaysMonitorDirs );
203 
205  break;
206  }
207 
209  {
210  if ( !noMonitorDirs.contains( mDirPath ) )
211  {
212  noMonitorDirs.append( mDirPath );
213  settings.setValue( QStringLiteral( "qgis/disableMonitorItemUris" ), noMonitorDirs );
214  }
215 
216  alwaysMonitorDirs.removeAll( mDirPath );
217  settings.setValue( QStringLiteral( "qgis/alwaysMonitorItemUris" ), alwaysMonitorDirs );
218 
219  mMonitored = false;
220  break;
221  }
222 
224  {
225  noMonitorDirs.removeAll( mDirPath );
226  settings.setValue( QStringLiteral( "qgis/disableMonitorItemUris" ), noMonitorDirs );
227 
228  if ( !alwaysMonitorDirs.contains( mDirPath ) )
229  {
230  alwaysMonitorDirs.append( mDirPath );
231  settings.setValue( QStringLiteral( "qgis/alwaysMonitorItemUris" ), alwaysMonitorDirs );
232  }
233 
234  mMonitored = true;
235  break;
236  }
237  }
238 
239  const QVector<QgsDataItem *> childItems = children();
240  for ( QgsDataItem *child : childItems )
241  {
242  if ( QgsDirectoryItem *dirItem = qobject_cast< QgsDirectoryItem *>( child ) )
243  dirItem->reevaluateMonitoring();
244  }
245 
246  createOrDestroyFileSystemWatcher();
247 }
248 
249 QVector<QgsDataItem *> QgsDirectoryItem::createChildren()
250 {
251  QVector<QgsDataItem *> children;
252  QDir dir( mDirPath );
253 
254  const QList<QgsDataItemProvider *> providers = QgsApplication::dataItemProviderRegistry()->providers();
255 
256  QStringList entries = dir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
257  const auto constEntries = entries;
258  for ( const QString &subdir : constEntries )
259  {
260  if ( mRefreshLater )
261  {
263  return children;
264  }
265 
266  QString subdirPath = dir.absoluteFilePath( subdir );
267 
268  QgsDebugMsgLevel( QStringLiteral( "creating subdir: %1" ).arg( subdirPath ), 2 );
269 
270  QString path = mPath + '/' + subdir; // may differ from subdirPath
272  continue;
273 
274  bool handledByProvider = false;
275  for ( QgsDataItemProvider *provider : providers )
276  {
277  if ( provider->handlesDirectoryPath( path ) )
278  {
279  handledByProvider = true;
280  break;
281  }
282  }
283  if ( handledByProvider )
284  continue;
285 
286  QgsDirectoryItem *item = new QgsDirectoryItem( this, subdir, subdirPath, path );
287 
288  // we want directories shown before files
289  item->setSortKey( QStringLiteral( " %1" ).arg( subdir ) );
290 
291  // propagate signals up to top
292 
293  children.append( item );
294  }
295 
296  QStringList fileEntries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files, QDir::Name );
297  const auto constFileEntries = fileEntries;
298  for ( const QString &name : constFileEntries )
299  {
300  if ( mRefreshLater )
301  {
303  return children;
304  }
305 
306  QString path = dir.absoluteFilePath( name );
307  QFileInfo fileInfo( path );
308 
309  if ( fileInfo.suffix().compare( QLatin1String( "zip" ), Qt::CaseInsensitive ) == 0 ||
310  fileInfo.suffix().compare( QLatin1String( "tar" ), Qt::CaseInsensitive ) == 0 )
311  {
312  QgsDataItem *item = QgsZipItem::itemFromPath( this, path, name, mPath + '/' + name );
313  if ( item )
314  {
315  children.append( item );
316  continue;
317  }
318  }
319 
320  bool createdItem = false;
321  for ( QgsDataItemProvider *provider : providers )
322  {
323  int capabilities = provider->capabilities();
324 
325  if ( !( ( fileInfo.isFile() && ( capabilities & QgsDataProvider::File ) ) ||
326  ( fileInfo.isDir() && ( capabilities & QgsDataProvider::Dir ) ) ) )
327  {
328  continue;
329  }
330 
331  QgsDataItem *item = provider->createDataItem( path, this );
332  if ( item )
333  {
334  children.append( item );
335  createdItem = true;
336  }
337  }
338 
339  if ( !createdItem )
340  {
341  // if item is a QGIS project, and no specific item provider has overridden handling of
342  // project items, then use the default project item behavior
343  if ( fileInfo.suffix().compare( QLatin1String( "qgs" ), Qt::CaseInsensitive ) == 0 ||
344  fileInfo.suffix().compare( QLatin1String( "qgz" ), Qt::CaseInsensitive ) == 0 )
345  {
346  QgsDataItem *item = new QgsProjectItem( this, fileInfo.completeBaseName(), path );
347  children.append( item );
348  continue;
349  }
350  }
351 
352  }
353  return children;
354 }
355 
357 {
359 
360  if ( state == Qgis::BrowserItemState::Populated && mMonitored )
361  {
362  if ( !mFileSystemWatcher )
363  {
364  mFileSystemWatcher = new QFileSystemWatcher( this );
365  mFileSystemWatcher->addPath( mDirPath );
366  connect( mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &QgsDirectoryItem::directoryChanged );
367  }
368  mLastScan = QDateTime::currentDateTime();
369  }
371  {
372  if ( mFileSystemWatcher )
373  {
374  delete mFileSystemWatcher;
375  mFileSystemWatcher = nullptr;
376  }
377  }
378 }
379 
381 {
382  // If the last scan was less than 10 seconds ago, skip this
383  if ( mLastScan.msecsTo( QDateTime::currentDateTime() ) < QgsSettings().value( QStringLiteral( "browser/minscaninterval" ), 10000 ).toInt() )
384  {
385  return;
386  }
388  {
389  // schedule to refresh later, because refresh() simply returns if Populating
390  mRefreshLater = true;
391  }
392  else
393  {
394  // We definintely don't want the temporary files created by sqlite
395  // to re-trigger a refresh in an infinite loop.
396  disconnect( mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &QgsDirectoryItem::directoryChanged );
397  // QFileSystemWhatcher::directoryChanged is emitted when a
398  // file is created and not when it is closed/flushed.
399  //
400  // Delay to give to OS the time to complete writing the file
401  // this happens when a new file appears in the directory and
402  // the item's children thread will try to open the file with
403  // GDAL or OGR even if it is still being written.
404  QTimer::singleShot( 100, this, [ = ] { refresh(); } );
405  }
406 }
407 
408 bool QgsDirectoryItem::hiddenPath( const QString &path )
409 {
410  QgsSettings settings;
411  QStringList hiddenItems = settings.value( QStringLiteral( "browser/hiddenPaths" ),
412  QStringList() ).toStringList();
413  int idx = hiddenItems.indexOf( path );
414  return ( idx > -1 );
415 }
416 
418 {
419  QgsSettings settings;
420  if ( settings.value( QStringLiteral( "qgis/disableMonitorItemUris" ), QStringList() ).toStringList().contains( path ) )
422  else if ( settings.value( QStringLiteral( "qgis/alwaysMonitorItemUris" ), QStringList() ).toStringList().contains( path ) )
425 }
426 
428 {
429  // check through path's parent directories, to see if any have an explicit
430  // always/never monitor setting. If so, this path will inherit that setting
431  const QString originalPath = QDir::cleanPath( path );
432  QString currentPath = originalPath;
433  QString prevPath;
434  while ( currentPath != prevPath )
435  {
436  prevPath = currentPath;
437  currentPath = QFileInfo( currentPath ).path();
438 
439  switch ( monitoringForPath( currentPath ) )
440  {
442  return false;
444  return true;
446  break;
447  }
448  }
449 
450  // else if we know that the path is on a slow device, we don't monitor by default
451  // as this can be very expensive and slow down QGIS
453  return false;
454 
455  // paths are monitored by default if no explicit setting is in place, and the user hasn't
456  // completely opted out of all browser monitoring
457  return QgsSettings().value( QStringLiteral( "/qgis/monitorDirectoriesInBrowser" ), true ).toBool();
458 }
459 
461 {
462  QgsDebugMsgLevel( QStringLiteral( "mRefreshLater = %1" ).arg( mRefreshLater ), 3 );
463 
464  if ( mRefreshLater )
465  {
466  QgsDebugMsgLevel( QStringLiteral( "directory changed during createChidren() -> refresh() again" ), 3 );
467  mRefreshLater = false;
469  refresh();
470  }
471  else
472  {
474  }
475  // Re-connect the file watcher after all children have been created
476  if ( mFileSystemWatcher && mMonitored )
477  connect( mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &QgsDirectoryItem::directoryChanged );
478 }
479 
481 {
482  //QgsDebugMsg ( mPath + " x " + other->mPath );
483  if ( type() != other->type() )
484  {
485  return false;
486  }
487  return ( path() == other->path() );
488 }
489 
491 {
492  return new QgsDirectoryParamWidget( mPath );
493 }
494 
496 {
498  u.layerType = QStringLiteral( "directory" );
499  u.name = mName;
500  u.uri = mDirPath;
501  return { u };
502 }
503 
504 //
505 // QgsDirectoryParamWidget
506 //
507 QgsDirectoryParamWidget::QgsDirectoryParamWidget( const QString &path, QWidget *parent )
508  : QTreeWidget( parent )
509 {
510  setRootIsDecorated( false );
511 
512  // name, size, date, permissions, owner, group, type
513  setColumnCount( 7 );
514  QStringList labels;
515  labels << tr( "Name" ) << tr( "Size" ) << tr( "Date" ) << tr( "Permissions" ) << tr( "Owner" ) << tr( "Group" ) << tr( "Type" );
516  setHeaderLabels( labels );
517 
518  QIcon iconDirectory = QgsApplication::getThemeIcon( QStringLiteral( "mIconFolder.svg" ) );
519  QIcon iconFile = QgsApplication::getThemeIcon( QStringLiteral( "mIconFile.svg" ) );
520  QIcon iconDirLink = QgsApplication::getThemeIcon( QStringLiteral( "mIconFolderLink.svg" ) );
521  QIcon iconFileLink = QgsApplication::getThemeIcon( QStringLiteral( "mIconFileLink.svg" ) );
522 
523  QList<QTreeWidgetItem *> items;
524 
525  QDir dir( path );
526  QStringList entries = dir.entryList( QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
527  const auto constEntries = entries;
528  for ( const QString &name : constEntries )
529  {
530  QFileInfo fi( dir.absoluteFilePath( name ) );
531  QStringList texts;
532  texts << name;
533  QString size;
534  if ( fi.size() > 1024 )
535  {
536  size = QStringLiteral( "%1 KiB" ).arg( QString::number( fi.size() / 1024.0, 'f', 1 ) );
537  }
538  else if ( fi.size() > 1.048576e6 )
539  {
540  size = QStringLiteral( "%1 MiB" ).arg( QString::number( fi.size() / 1.048576e6, 'f', 1 ) );
541  }
542  else
543  {
544  size = QStringLiteral( "%1 B" ).arg( fi.size() );
545  }
546  texts << size;
547  texts << QLocale().toString( fi.lastModified(), QLocale::ShortFormat );
548  QString perm;
549  perm += fi.permission( QFile::ReadOwner ) ? 'r' : '-';
550  perm += fi.permission( QFile::WriteOwner ) ? 'w' : '-';
551  perm += fi.permission( QFile::ExeOwner ) ? 'x' : '-';
552  // QFile::ReadUser, QFile::WriteUser, QFile::ExeUser
553  perm += fi.permission( QFile::ReadGroup ) ? 'r' : '-';
554  perm += fi.permission( QFile::WriteGroup ) ? 'w' : '-';
555  perm += fi.permission( QFile::ExeGroup ) ? 'x' : '-';
556  perm += fi.permission( QFile::ReadOther ) ? 'r' : '-';
557  perm += fi.permission( QFile::WriteOther ) ? 'w' : '-';
558  perm += fi.permission( QFile::ExeOther ) ? 'x' : '-';
559  texts << perm;
560 
561  texts << fi.owner();
562  texts << fi.group();
563 
564  QString type;
565  QIcon icon;
566  if ( fi.isDir() && fi.isSymLink() )
567  {
568  type = tr( "folder" );
569  icon = iconDirLink;
570  }
571  else if ( fi.isDir() )
572  {
573  type = tr( "folder" );
574  icon = iconDirectory;
575  }
576  else if ( fi.isFile() && fi.isSymLink() )
577  {
578  type = tr( "file" );
579  icon = iconFileLink;
580  }
581  else if ( fi.isFile() )
582  {
583  type = tr( "file" );
584  icon = iconFile;
585  }
586 
587  texts << type;
588 
589  QTreeWidgetItem *item = new QTreeWidgetItem( texts );
590  item->setIcon( 0, icon );
591  items << item;
592  }
593 
594  addTopLevelItems( items );
595 
596  // hide columns that are not requested
597  QgsSettings settings;
598  QList<QVariant> lst = settings.value( QStringLiteral( "dataitem/directoryHiddenColumns" ) ).toList();
599  const auto constLst = lst;
600  for ( const QVariant &colVariant : constLst )
601  {
602  setColumnHidden( colVariant.toInt(), true );
603  }
604 }
605 
607 {
608  if ( event->button() == Qt::RightButton )
609  {
610  // show the popup menu
611  QMenu popupMenu;
612 
613  QStringList labels;
614  labels << tr( "Name" ) << tr( "Size" ) << tr( "Date" ) << tr( "Permissions" ) << tr( "Owner" ) << tr( "Group" ) << tr( "Type" );
615  for ( int i = 0; i < labels.count(); i++ )
616  {
617  QAction *action = popupMenu.addAction( labels[i], this, &QgsDirectoryParamWidget::showHideColumn );
618  action->setObjectName( QString::number( i ) );
619  action->setCheckable( true );
620  action->setChecked( !isColumnHidden( i ) );
621  }
622 
623  popupMenu.exec( event->globalPos() );
624  }
625 }
626 
628 {
629  QAction *action = qobject_cast<QAction *>( sender() );
630  if ( !action )
631  return; // something is wrong
632 
633  int columnIndex = action->objectName().toInt();
634  setColumnHidden( columnIndex, !isColumnHidden( columnIndex ) );
635 
636  // save in settings
637  QgsSettings settings;
638  QList<QVariant> lst;
639  for ( int i = 0; i < columnCount(); i++ )
640  {
641  if ( isColumnHidden( i ) )
642  lst.append( QVariant( i ) );
643  }
644  settings.setValue( QStringLiteral( "dataitem/directoryHiddenColumns" ), lst );
645 }
646 
647 //
648 // QgsProjectHomeItem
649 //
650 
651 QgsProjectHomeItem::QgsProjectHomeItem( QgsDataItem *parent, const QString &name, const QString &dirPath, const QString &path )
652  : QgsDirectoryItem( parent, name, dirPath, path, QStringLiteral( "special:ProjectHome" ) )
653 {
654 }
655 
657 {
659  return QgsDirectoryItem::icon();
660  return QgsApplication::getThemeIcon( QStringLiteral( "mIconFolderProject.svg" ) );
661 }
662 
664 {
665  return QStringLiteral( " 1" );
666 }
667 
668 
BrowserItemState
Browser item states.
Definition: qgis.h:249
@ NotPopulated
Children not yet created.
@ Populating
Creating children in separate thread (populating or refreshing)
@ Populated
Children created.
BrowserDirectoryMonitoring
Browser directory item monitoring switches.
Definition: qgis.h:303
@ Default
Use default logic to determine whether directory should be monitored.
@ AlwaysMonitor
Always monitor the directory, regardless of the default logic.
@ NeverMonitor
Never monitor the directory, regardless of the default logic.
@ Directory
Represents a file directory.
static QgsDataItemProviderRegistry * dataItemProviderRegistry()
Returns the application's data item provider registry, which keeps a list of data item providers that...
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
A Collection: logical collection of layers or subcollections, e.g.
static QIcon homeDirIcon(const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Shared home directory icon.
static QIcon iconDir(const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Returns the standard browser directory icon.
static QIcon openDirIcon(const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Shared open directory icon.
QList< QgsDataItemProvider * > providers() const
Returns the list of available providers.
This is the interface for those who want to add custom data items to the browser tree.
Base class for all items in the model.
Definition: qgsdataitem.h:46
void setSortKey(const QVariant &key)
Sets a custom sorting key for the item.
QString mName
Definition: qgsdataitem.h:441
Qgis::BrowserItemType mType
Definition: qgsdataitem.h:436
void setToolTip(const QString &msg)
Definition: qgsdataitem.h:398
void dataChanged(QgsDataItem *item)
QString mPath
Definition: qgsdataitem.h:447
QVector< QgsDataItem * > children() const
Definition: qgsdataitem.h:329
virtual void deleteLater()
Safely delete the item:
Qgis::BrowserItemType type() const
Definition: qgsdataitem.h:316
Qgis::BrowserItemState state() const
virtual void childrenCreated()
QString name() const
Returns the name of the item (the displayed text for the item).
Definition: qgsdataitem.h:337
QString path() const
Definition: qgsdataitem.h:346
virtual QIcon icon()
virtual void setState(Qgis::BrowserItemState state)
Set item state.
virtual void refresh()
A directory: contains subdirectories and layers.
QVector< QgsDataItem * > createChildren() override
Create children.
Q_DECL_DEPRECATED QWidget * paramWidget() override
Returns source widget from data item for QgsBrowserPropertiesWidget.
static Qgis::BrowserDirectoryMonitoring monitoringForPath(const QString &path)
Returns the monitoring setting for a directory path.
QgsMimeDataUtils::UriList mimeUris() const override
Returns mime URIs for the data item, most data providers will only return a single URI but some data ...
Qgis::BrowserDirectoryMonitoring monitoring() const
Returns the monitoring setting for this directory item.
static void setCustomColor(const QString &directory, const QColor &color)
Sets a custom icon color to use for the items for the corresponding directory path.
bool equal(const QgsDataItem *other) override
Returns true if this item is equal to another item (by testing item type and path).
void setMonitoring(Qgis::BrowserDirectoryMonitoring monitoring)
Sets the monitoring setting for this directory.
QColor iconColor() const
Returns the directory's icon color.
void childrenCreated() override
void setIconColor(const QColor &color)
Sets the directory's icon color.
QgsDirectoryItem(QgsDataItem *parent, const QString &name, const QString &path)
Constructor for QgsDirectoryItem, with the specified parent item.
void reevaluateMonitoring()
Re-evaluate whether the directory item should be monitored for changes.
static bool hiddenPath(const QString &path)
Check if the given path is hidden from the browser model.
void setState(Qgis::BrowserItemState state) override
Set item state.
static bool pathShouldByMonitoredByDefault(const QString &path)
Returns true if a directory path should be monitored by default.
QIcon icon() override
Browser parameter widget implementation for directory items.
void mousePressEvent(QMouseEvent *event) override
QgsDirectoryParamWidget(const QString &path, QWidget *parent=nullptr)
static bool pathIsSlowDevice(const QString &path)
Returns true if the specified path is assumed to reside on a slow device, e.g.
QList< QgsMimeDataUtils::Uri > UriList
QIcon icon() override
QVariant sortKey() const override
Returns the sorting key for the item.
QgsProjectHomeItem(QgsDataItem *parent, const QString &name, const QString &dirPath, const QString &path)
Constructor for QgsProjectHomeItem.
Data item that can be used to represent QGIS projects.
static QgsDataItem * itemFromPath(QgsDataItem *parent, const QString &path, const QString &name)
Creates a new data item from the specified path.
Definition: qgszipitem.cpp:134
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QString uri
Identifier of the data source recognized by its providerKey.
QString name
Human readable name to be used e.g. in layer tree.
QString layerType
Type of URI.