QGIS API Documentation 3.99.0-Master (8e76e220402)
Loading...
Searching...
No Matches
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
20#include "qgsapplication.h"
21#include "qgsdataitemprovider.h"
23#include "qgsfileutils.h"
24#include "qgsgdalutils.h"
25#include "qgsprojectitem.h"
26#include "qgssettings.h"
27#include "qgszipitem.h"
28
29#include <QAction>
30#include <QDir>
31#include <QFileSystemWatcher>
32#include <QMenu>
33#include <QMouseEvent>
34#include <QString>
35#include <QTimer>
36
37#include "moc_qgsdirectoryitem.cpp"
38
39using namespace Qt::StringLiterals;
40
41//
42// QgsDirectoryItem
43//
44
46 : QgsDataCollectionItem( parent, QDir::toNativeSeparators( name ), path )
47 , mDirPath( path )
48{
49 init( name );
50}
51
53 const QString &dirPath, const QString &path,
54 const QString &providerKey )
55 : QgsDataCollectionItem( parent, QDir::toNativeSeparators( name ), path, providerKey )
56 , mDirPath( dirPath )
57{
58 init( name );
59}
60
61void QgsDirectoryItem::init( const QString &dirName )
62{
64 setToolTip( QDir::toNativeSeparators( mDirPath ) );
65
66 QgsSettings settings;
67
68 const QFileInfo fi { mDirPath };
69 mIsDir = fi.isDir();
70 mIsSymLink = fi.isSymLink();
71
72 mMonitoring = monitoringForPath( mDirPath );
73 switch ( mMonitoring )
74 {
77 break;
79 mMonitored = false;
80 break;
82 mMonitored = true;
83 break;
84 }
85
86 settings.beginGroup( u"qgis/browserPathColors"_s );
87 QString settingKey = mDirPath;
88 settingKey.replace( '/', "|||"_L1 );
89 if ( settings.childKeys().contains( settingKey ) )
90 {
91 const QString colorString = settings.value( settingKey ).toString();
92 mIconColor = QColor( colorString );
93 }
94 settings.endGroup();
95
96 // we want directories shown before files
97 setSortKey( u" %1"_s.arg( dirName ) );
98}
99
101{
102 mMonitoring = monitoringForPath( mDirPath );
103 switch ( mMonitoring )
104 {
107 break;
109 mMonitored = false;
110 break;
112 mMonitored = true;
113 break;
114 }
115
116 const QVector<QgsDataItem *> childItems = children();
117 for ( QgsDataItem *child : childItems )
118 {
119 if ( QgsDirectoryItem *dirItem = qobject_cast< QgsDirectoryItem *>( child ) )
120 dirItem->reevaluateMonitoring();
121 }
122
123 createOrDestroyFileSystemWatcher();
124}
125
126void QgsDirectoryItem::createOrDestroyFileSystemWatcher()
127{
128 if ( !mMonitored && mFileSystemWatcher )
129 {
130 mFileSystemWatcher->deleteLater();
131 mFileSystemWatcher = nullptr;
132 }
133 else if ( mMonitored && state() == Qgis::BrowserItemState::Populated && !mFileSystemWatcher )
134 {
135 mFileSystemWatcher = new QFileSystemWatcher( this );
136 mFileSystemWatcher->addPath( mDirPath );
137 connect( mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &QgsDirectoryItem::directoryChanged );
138 }
139}
140
142{
143 return mIconColor;
144}
145
146void QgsDirectoryItem::setIconColor( const QColor &color )
147{
148 if ( color == mIconColor )
149 return;
150
151 mIconColor = color;
152 emit dataChanged( this );
153}
154
155void QgsDirectoryItem::setCustomColor( const QString &directory, const QColor &color )
156{
157 QgsSettings settings;
158 settings.beginGroup( u"qgis/browserPathColors"_s );
159 QString settingKey = directory;
160 settingKey.replace( '/', "|||"_L1 );
161 if ( color.isValid() )
162 settings.setValue( settingKey, color.name( QColor::HexArgb ) );
163 else
164 settings.remove( settingKey );
165 settings.endGroup();
166}
167
169{
170 if ( mDirPath == QDir::homePath() )
171 return homeDirIcon( mIconColor, mIconColor.darker() );
172
173 // still loading? show the spinner
175 return QgsDataItem::icon();
176
177 // symbolic link? use link icon
178 if ( mIsDir && mIsSymLink )
179 {
180 return mIconColor.isValid()
181 ? QgsApplication::getThemeIcon( u"/mIconFolderLinkParams.svg"_s, mIconColor, mIconColor.darker() )
182 : QgsApplication::getThemeIcon( u"/mIconFolderLink.svg"_s );
183 }
184
185 // loaded? show the open dir icon
187 return openDirIcon( mIconColor, mIconColor.darker() );
188
189 // show the closed dir icon
190 return iconDir( mIconColor, mIconColor.darker() );
191}
192
194{
195 return mMonitoring;
196}
197
199{
200 mMonitoring = monitoring;
201
202 QgsSettings settings;
203 QStringList noMonitorDirs = settings.value( u"qgis/disableMonitorItemUris"_s, QStringList() ).toStringList();
204 QStringList alwaysMonitorDirs = settings.value( u"qgis/alwaysMonitorItemUris"_s, QStringList() ).toStringList();
205
206 switch ( mMonitoring )
207 {
209 {
210 // remove disable/always setting for this path, so that default behavior is used
211 noMonitorDirs.removeAll( mDirPath );
212 settings.setValue( u"qgis/disableMonitorItemUris"_s, noMonitorDirs );
213
214 alwaysMonitorDirs.removeAll( mDirPath );
215 settings.setValue( u"qgis/alwaysMonitorItemUris"_s, alwaysMonitorDirs );
216
218 break;
219 }
220
222 {
223 if ( !noMonitorDirs.contains( mDirPath ) )
224 {
225 noMonitorDirs.append( mDirPath );
226 settings.setValue( u"qgis/disableMonitorItemUris"_s, noMonitorDirs );
227 }
228
229 alwaysMonitorDirs.removeAll( mDirPath );
230 settings.setValue( u"qgis/alwaysMonitorItemUris"_s, alwaysMonitorDirs );
231
232 mMonitored = false;
233 break;
234 }
235
237 {
238 noMonitorDirs.removeAll( mDirPath );
239 settings.setValue( u"qgis/disableMonitorItemUris"_s, noMonitorDirs );
240
241 if ( !alwaysMonitorDirs.contains( mDirPath ) )
242 {
243 alwaysMonitorDirs.append( mDirPath );
244 settings.setValue( u"qgis/alwaysMonitorItemUris"_s, alwaysMonitorDirs );
245 }
246
247 mMonitored = true;
248 break;
249 }
250 }
251
252 const QVector<QgsDataItem *> childItems = children();
253 for ( QgsDataItem *child : childItems )
254 {
255 if ( QgsDirectoryItem *dirItem = qobject_cast< QgsDirectoryItem *>( child ) )
256 dirItem->reevaluateMonitoring();
257 }
258
259 createOrDestroyFileSystemWatcher();
260}
261
262QVector<QgsDataItem *> QgsDirectoryItem::createChildren()
263{
264 QVector<QgsDataItem *> children;
265 const QDir dir( mDirPath );
266
267 const QList<QgsDataItemProvider *> providers = QgsApplication::dataItemProviderRegistry()->providers();
268
269 const QStringList entries = dir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
270 for ( const QString &subdir : entries )
271 {
272 if ( mRefreshLater )
273 {
275 return children;
276 }
277
278 const QString subdirPath = dir.absoluteFilePath( subdir );
279
280 QgsDebugMsgLevel( u"creating subdir: %1"_s.arg( subdirPath ), 2 );
281
282 const QString path = mPath + ( mPath.endsWith( '/' ) ? QString() : u"/"_s ) + subdir; // may differ from subdirPath
284 continue;
285
286 bool handledByProvider = false;
287 for ( QgsDataItemProvider *provider : providers )
288 {
289 if ( provider->handlesDirectoryPath( subdirPath ) )
290 {
291 handledByProvider = true;
292 break;
293 }
294 }
295 if ( handledByProvider )
296 continue;
297
298 QgsDirectoryItem *item = new QgsDirectoryItem( this, subdir, subdirPath, path );
299
300 // propagate signals up to top
301
302 children.append( item );
303 }
304
305 const QStringList fileEntries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files, QDir::Name );
306 for ( const QString &name : fileEntries )
307 {
308 if ( mRefreshLater )
309 {
311 return children;
312 }
313
314 const QString path = dir.absoluteFilePath( name );
315 const QFileInfo fileInfo( path );
316
317 if ( QgsGdalUtils::isVsiArchiveFileExtension( fileInfo.suffix() ) )
318 {
319 if ( QgsDataItem *item = QgsZipItem::itemFromPath( this, path, name, path ) )
320 {
321 children.append( item );
322 continue;
323 }
324 }
325
326 bool createdItem = false;
327 for ( QgsDataItemProvider *provider : providers )
328 {
329 const Qgis::DataItemProviderCapabilities capabilities = provider->capabilities();
330
331 if ( !( ( fileInfo.isFile() && ( capabilities & Qgis::DataItemProviderCapability::Files ) ) ||
332 ( fileInfo.isDir() && ( capabilities & Qgis::DataItemProviderCapability::Directories ) ) ) )
333 {
334 continue;
335 }
336
337 QgsDataItem *item = provider->createDataItem( path, this );
338 if ( item )
339 {
340 // 3rd party providers may not correctly set the ItemRepresentsFile capability, so force it here if we
341 // see that the item's path does match the original file path
342 if ( item->path() == path )
344
345 children.append( item );
346 createdItem = true;
347 }
348 }
349
350 if ( !createdItem )
351 {
352 // if item is a QGIS project, and no specific item provider has overridden handling of
353 // project items, then use the default project item behavior
354 if ( fileInfo.suffix().compare( "qgs"_L1, Qt::CaseInsensitive ) == 0 ||
355 fileInfo.suffix().compare( "qgz"_L1, Qt::CaseInsensitive ) == 0 )
356 {
357 QgsDataItem *item = new QgsProjectItem( this, fileInfo.completeBaseName(), path );
359 children.append( item );
360 continue;
361 }
362 }
363
364 }
365 return children;
366}
367
369{
371
372 if ( state == Qgis::BrowserItemState::Populated && mMonitored )
373 {
374 if ( !mFileSystemWatcher )
375 {
376 mFileSystemWatcher = new QFileSystemWatcher( this );
377 mFileSystemWatcher->addPath( mDirPath );
378 connect( mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &QgsDirectoryItem::directoryChanged );
379 }
380 mLastScan = QDateTime::currentDateTime();
381 }
383 {
384 if ( mFileSystemWatcher )
385 {
386 delete mFileSystemWatcher;
387 mFileSystemWatcher = nullptr;
388 }
389 }
390}
391
393{
394 // If the last scan was less than 10 seconds ago, skip this
395 if ( mLastScan.msecsTo( QDateTime::currentDateTime() ) < QgsSettings().value( u"browser/minscaninterval"_s, 10000 ).toInt() )
396 {
397 return;
398 }
400 {
401 // schedule to refresh later, because refresh() simply returns if Populating
402 mRefreshLater = true;
403 }
404 else
405 {
406 // We definintely don't want the temporary files created by sqlite
407 // to re-trigger a refresh in an infinite loop.
408 disconnect( mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &QgsDirectoryItem::directoryChanged );
409 // QFileSystemWhatcher::directoryChanged is emitted when a
410 // file is created and not when it is closed/flushed.
411 //
412 // Delay to give to OS the time to complete writing the file
413 // this happens when a new file appears in the directory and
414 // the item's children thread will try to open the file with
415 // GDAL or OGR even if it is still being written.
416 QTimer::singleShot( 100, this, [this] { refresh(); } );
417 }
418}
419
420bool QgsDirectoryItem::hiddenPath( const QString &path )
421{
422 const QgsSettings settings;
423 const QStringList hiddenItems = settings.value( u"browser/hiddenPaths"_s,
424 QStringList() ).toStringList();
425 const int idx = hiddenItems.indexOf( path );
426 return ( idx > -1 );
427}
428
430{
431 const QgsSettings settings;
432 if ( settings.value( u"qgis/disableMonitorItemUris"_s, QStringList() ).toStringList().contains( path ) )
434 else if ( settings.value( u"qgis/alwaysMonitorItemUris"_s, QStringList() ).toStringList().contains( path ) )
437}
438
440{
441 // check through path's parent directories, to see if any have an explicit
442 // always/never monitor setting. If so, this path will inherit that setting
443 const QString originalPath = QDir::cleanPath( path );
444 QString currentPath = originalPath;
445 QString prevPath;
446 while ( currentPath != prevPath )
447 {
448 prevPath = currentPath;
449 currentPath = QFileInfo( currentPath ).path();
450
451 switch ( monitoringForPath( currentPath ) )
452 {
454 return false;
456 return true;
458 break;
459 }
460 }
461
462 // else if we know that the path is on a slow device, we don't monitor by default
463 // as this can be very expensive and slow down QGIS
464 // Add trailing slash or windows API functions like GetDriveTypeW won't identify
465 // UNC network drives correctly
466 if ( QgsFileUtils::pathIsSlowDevice( path.endsWith( '/' ) ? path : path + '/' ) )
467 return false;
468
469 // paths are monitored by default if no explicit setting is in place, and the user hasn't
470 // completely opted out of all browser monitoring
471 return QgsSettings().value( u"/qgis/monitorDirectoriesInBrowser"_s, true ).toBool();
472}
473
475{
476 QgsDebugMsgLevel( u"mRefreshLater = %1"_s.arg( mRefreshLater ), 3 );
477
478 if ( mRefreshLater )
479 {
480 QgsDebugMsgLevel( u"directory changed during createChildren() -> refresh() again"_s, 3 );
481 mRefreshLater = false;
483 refresh();
484 }
485 else
486 {
488 }
489 // Re-connect the file watcher after all children have been created
490 if ( mFileSystemWatcher && mMonitored )
491 connect( mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &QgsDirectoryItem::directoryChanged );
492}
493
495{
496 //QgsDebugMsg ( mPath + " x " + other->mPath );
497 if ( type() != other->type() )
498 {
499 return false;
500 }
501 const QgsDirectoryItem *otherDirItem = qobject_cast< const QgsDirectoryItem * >( other );
502 if ( !otherDirItem )
503 return false;
504
505 return dirPath() == otherDirItem->dirPath();
506}
507
509{
510 return new QgsDirectoryParamWidget( mPath );
511}
512
514{
516 u.layerType = u"directory"_s;
517 u.name = mName;
518 u.uri = mDirPath;
519 u.filePath = path();
520 return { u };
521}
522
523//
524// QgsDirectoryParamWidget
525//
526QgsDirectoryParamWidget::QgsDirectoryParamWidget( const QString &path, QWidget *parent )
527 : QTreeWidget( parent )
528{
529 setRootIsDecorated( false );
530
531 // name, size, date, permissions, owner, group, type
532 setColumnCount( 7 );
533 QStringList labels;
534 labels << tr( "Name" ) << tr( "Size" ) << tr( "Date" ) << tr( "Permissions" ) << tr( "Owner" ) << tr( "Group" ) << tr( "Type" );
535 setHeaderLabels( labels );
536
537 const QIcon iconDirectory = QgsApplication::getThemeIcon( u"mIconFolder.svg"_s );
538 const QIcon iconFile = QgsApplication::getThemeIcon( u"mIconFile.svg"_s );
539 const QIcon iconDirLink = QgsApplication::getThemeIcon( u"mIconFolderLink.svg"_s );
540 const QIcon iconFileLink = QgsApplication::getThemeIcon( u"mIconFileLink.svg"_s );
541
542 QList<QTreeWidgetItem *> items;
543
544 const QDir dir( path );
545 const QStringList entries = dir.entryList( QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
546 for ( const QString &name : entries )
547 {
548 const QFileInfo fi( dir.absoluteFilePath( name ) );
549 QStringList texts;
550 texts << name;
551 QString size;
552 if ( fi.size() > 1024 )
553 {
554 size = u"%1 KiB"_s.arg( QLocale().toString( fi.size() / 1024.0, 'f', 1 ) );
555 }
556 else if ( fi.size() > 1.048576e6 )
557 {
558 size = u"%1 MiB"_s.arg( QLocale().toString( fi.size() / 1.048576e6, 'f', 1 ) );
559 }
560 else
561 {
562 size = u"%1 B"_s.arg( fi.size() );
563 }
564 texts << size;
565 texts << QLocale().toString( fi.lastModified(), QLocale::ShortFormat );
566 QString perm;
567 perm += fi.permission( QFile::ReadOwner ) ? 'r' : '-';
568 perm += fi.permission( QFile::WriteOwner ) ? 'w' : '-';
569 perm += fi.permission( QFile::ExeOwner ) ? 'x' : '-';
570 // QFile::ReadUser, QFile::WriteUser, QFile::ExeUser
571 perm += fi.permission( QFile::ReadGroup ) ? 'r' : '-';
572 perm += fi.permission( QFile::WriteGroup ) ? 'w' : '-';
573 perm += fi.permission( QFile::ExeGroup ) ? 'x' : '-';
574 perm += fi.permission( QFile::ReadOther ) ? 'r' : '-';
575 perm += fi.permission( QFile::WriteOther ) ? 'w' : '-';
576 perm += fi.permission( QFile::ExeOther ) ? 'x' : '-';
577 texts << perm;
578
579 texts << fi.owner();
580 texts << fi.group();
581
582 QString type;
583 QIcon icon;
584 if ( fi.isDir() && fi.isSymLink() )
585 {
586 type = tr( "folder" );
587 icon = iconDirLink;
588 }
589 else if ( fi.isDir() )
590 {
591 type = tr( "folder" );
592 icon = iconDirectory;
593 }
594 else if ( fi.isFile() && fi.isSymLink() )
595 {
596 type = tr( "file" );
597 icon = iconFileLink;
598 }
599 else if ( fi.isFile() )
600 {
601 type = tr( "file" );
602 icon = iconFile;
603 }
604
605 texts << type;
606
607 QTreeWidgetItem *item = new QTreeWidgetItem( texts );
608 item->setIcon( 0, icon );
609 items << item;
610 }
611
612 addTopLevelItems( items );
613
614 // hide columns that are not requested
615 const QgsSettings settings;
616 const QList<QVariant> lst = settings.value( u"dataitem/directoryHiddenColumns"_s ).toList();
617 for ( const QVariant &colVariant : lst )
618 {
619 setColumnHidden( colVariant.toInt(), true );
620 }
621}
622
624{
625 if ( event->button() == Qt::RightButton )
626 {
627 // show the popup menu
628 QMenu popupMenu;
629
630 QStringList labels;
631 labels << tr( "Name" ) << tr( "Size" ) << tr( "Date" ) << tr( "Permissions" ) << tr( "Owner" ) << tr( "Group" ) << tr( "Type" );
632 for ( int i = 0; i < labels.count(); i++ )
633 {
634 QAction *action = popupMenu.addAction( labels[i], this, &QgsDirectoryParamWidget::showHideColumn );
635 action->setObjectName( QString::number( i ) );
636 action->setCheckable( true );
637 action->setChecked( !isColumnHidden( i ) );
638 }
639
640 popupMenu.exec( event->globalPos() );
641 }
642}
643
645{
646 QAction *action = qobject_cast<QAction *>( sender() );
647 if ( !action )
648 return; // something is wrong
649
650 const int columnIndex = action->objectName().toInt();
651 setColumnHidden( columnIndex, !isColumnHidden( columnIndex ) );
652
653 // save in settings
654 QgsSettings settings;
655 QList<QVariant> lst;
656 for ( int i = 0; i < columnCount(); i++ )
657 {
658 if ( isColumnHidden( i ) )
659 lst.append( QVariant( i ) );
660 }
661 settings.setValue( u"dataitem/directoryHiddenColumns"_s, lst );
662}
663
664//
665// QgsProjectHomeItem
666//
667
668QgsProjectHomeItem::QgsProjectHomeItem( QgsDataItem *parent, const QString &name, const QString &dirPath, const QString &path )
669 : QgsDirectoryItem( parent, name, dirPath, path, u"special:ProjectHome"_s )
670{
671}
672
674{
676 return QgsDirectoryItem::icon();
677 return QgsApplication::getThemeIcon( u"mIconFolderProject.svg"_s );
678}
679
681{
682 return u" 1"_s;
683}
684
685
@ Files
Can provides items which corresponds to files.
Definition qgis.h:997
@ Directories
Can provides items which corresponds to directories.
Definition qgis.h:998
BrowserItemState
Browser item states.
Definition qgis.h:957
@ NotPopulated
Children not yet created.
Definition qgis.h:958
@ Populating
Creating children in separate thread (populating or refreshing).
Definition qgis.h:959
@ Populated
Children created.
Definition qgis.h:960
@ ItemRepresentsFile
Item's path() directly represents a file on disk.
Definition qgis.h:978
BrowserDirectoryMonitoring
Browser directory item monitoring switches.
Definition qgis.h:1044
@ Default
Use default logic to determine whether directory should be monitored.
Definition qgis.h:1045
@ AlwaysMonitor
Always monitor the directory, regardless of the default logic.
Definition qgis.h:1047
@ NeverMonitor
Never monitor the directory, regardless of the default logic.
Definition qgis.h:1046
QFlags< DataItemProviderCapability > DataItemProviderCapabilities
Capabilities for data item providers.
Definition qgis.h:1011
@ Directory
Represents a file directory.
Definition qgis.h:940
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.
static QIcon homeDirIcon(const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Shared home directory icon.
QgsDataCollectionItem(QgsDataItem *parent, const QString &name, const QString &path=QString(), const QString &providerKey=QString())
Constructor for QgsDataCollectionItem, with the specified parent item.
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.
Interface for providers that add custom data items to the browser tree.
void setSortKey(const QVariant &key)
Sets a custom sorting key for the item.
QString mName
Qgis::BrowserItemType mType
void setToolTip(const QString &msg)
void dataChanged(QgsDataItem *item)
Emitted when data changes for an item.
QString mPath
QVector< QgsDataItem * > children() const
virtual void deleteLater()
Safely delete the item:
Qgis::BrowserItemType type() const
QgsDataItem(Qgis::BrowserItemType type, QgsDataItem *parent, const QString &name, const QString &path, const QString &providerKey=QString())
Constructor for QgsDataItem, with the specified parent item.
Qgis::BrowserItemState state() const
virtual void childrenCreated()
QString name() const
Returns the name of the item (the displayed text for the item).
QString path() const
virtual QIcon icon()
virtual void setState(Qgis::BrowserItemState state)
Set item state.
virtual void setCapabilities(Qgis::BrowserItemCapabilities capabilities)
Sets the capabilities for the data item.
virtual void refresh()
QgsDataItem * parent() const
Gets item parent.
QString providerKey() const
Returns the provider key that created this item (e.g.
virtual Qgis::BrowserItemCapabilities capabilities2() const
Returns the capabilities for the data item.
QVector< QgsDataItem * > createChildren() override
Create children.
Q_DECL_DEPRECATED QWidget * paramWidget() override
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).
QString dirPath() const
Returns the full path to the directory the item represents.
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.
static bool isVsiArchiveFileExtension(const QString &extension)
Returns true if a file extension is a supported archive style container (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.
Stores settings for use within QGIS.
Definition qgssettings.h:68
void endGroup()
Resets the group to what it was before the corresponding beginGroup() call.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void beginGroup(const QString &prefix, QgsSettings::Section section=QgsSettings::NoSection)
Appends prefix to the current group.
QStringList childKeys() const
Returns a list of all top-level keys that can be read using the QSettings object.
void remove(const QString &key, QgsSettings::Section section=QgsSettings::NoSection)
Removes the setting key and any sub-settings of key in a section.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
static QgsDataItem * itemFromPath(QgsDataItem *parent, const QString &path, const QString &name)
Creates a new data item from the specified path.
#define QgsDebugMsgLevel(str, level)
Definition qgslogger.h:63
QString filePath
Path to file, if uri is associated with a file.
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.