QGIS API Documentation 4.1.0-Master (3b8ef1f72a3)
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"
28#include "qgssettingstree.h"
29#include "qgszipitem.h"
30
31#include <QAction>
32#include <QDir>
33#include <QFileSystemWatcher>
34#include <QMenu>
35#include <QMouseEvent>
36#include <QString>
37#include <QTimer>
38
39#include "moc_qgsdirectoryitem.cpp"
40
41using namespace Qt::StringLiterals;
42
44
45//
46// QgsDirectoryItem
47//
48
50 : QgsDataCollectionItem( parent, QDir::toNativeSeparators( name ), path )
51 , mDirPath( path )
52{
53 init( name );
54}
55
56QgsDirectoryItem::QgsDirectoryItem( QgsDataItem *parent, const QString &name, const QString &dirPath, const QString &path, const QString &providerKey )
57 : QgsDataCollectionItem( parent, QDir::toNativeSeparators( name ), path, providerKey )
58 , mDirPath( dirPath )
59{
60 init( name );
61}
62
63void QgsDirectoryItem::init( const QString &dirName )
64{
66 setToolTip( QDir::toNativeSeparators( mDirPath ) );
67
68 QgsSettings settings;
69
70 const QFileInfo fi { mDirPath };
71 mIsDir = fi.isDir();
72 mIsSymLink = fi.isSymLink();
73
74 mMonitoring = monitoringForPath( mDirPath );
75 switch ( mMonitoring )
76 {
79 break;
81 mMonitored = false;
82 break;
84 mMonitored = true;
85 break;
86 }
87
88 settings.beginGroup( u"qgis/browserPathColors"_s );
89 QString settingKey = mDirPath;
90 settingKey.replace( '/', "|||"_L1 );
91 if ( settings.childKeys().contains( settingKey ) )
92 {
93 const QString colorString = settings.value( settingKey ).toString();
94 mIconColor = QColor( colorString );
95 }
96 settings.endGroup();
97
98 // we want directories shown before files
99 setSortKey( u" %1"_s.arg( dirName ) );
100}
101
103{
104 mMonitoring = monitoringForPath( mDirPath );
105 switch ( mMonitoring )
106 {
109 break;
111 mMonitored = false;
112 break;
114 mMonitored = true;
115 break;
116 }
117
118 const QVector<QgsDataItem *> childItems = children();
119 for ( QgsDataItem *child : childItems )
120 {
121 if ( QgsDirectoryItem *dirItem = qobject_cast< QgsDirectoryItem *>( child ) )
122 dirItem->reevaluateMonitoring();
123 }
124
125 createOrDestroyFileSystemWatcher();
126}
127
128void QgsDirectoryItem::createOrDestroyFileSystemWatcher()
129{
130 if ( !mMonitored && mFileSystemWatcher )
131 {
132 mFileSystemWatcher->deleteLater();
133 mFileSystemWatcher = nullptr;
134 }
135 else if ( mMonitored && state() == Qgis::BrowserItemState::Populated && !mFileSystemWatcher )
136 {
137 mFileSystemWatcher = new QFileSystemWatcher( this );
138 mFileSystemWatcher->addPath( mDirPath );
139 connect( mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &QgsDirectoryItem::directoryChanged );
140 }
141}
142
144{
145 return mIconColor;
146}
147
148void QgsDirectoryItem::setIconColor( const QColor &color )
149{
150 if ( color == mIconColor )
151 return;
152
153 mIconColor = color;
154 emit dataChanged( this );
155}
156
157void QgsDirectoryItem::setCustomColor( const QString &directory, const QColor &color )
158{
159 QgsSettings settings;
160 settings.beginGroup( u"qgis/browserPathColors"_s );
161 QString settingKey = directory;
162 settingKey.replace( '/', "|||"_L1 );
163 if ( color.isValid() )
164 settings.setValue( settingKey, color.name( QColor::HexArgb ) );
165 else
166 settings.remove( settingKey );
167 settings.endGroup();
168}
169
171{
172 if ( mDirPath == QDir::homePath() )
173 return homeDirIcon( mIconColor, mIconColor.darker() );
174
175 // still loading? show the spinner
177 return QgsDataItem::icon();
178
179 // symbolic link? use link icon
180 if ( mIsDir && mIsSymLink )
181 {
182 return mIconColor.isValid() ? QgsApplication::getThemeIcon( u"/mIconFolderLinkParams.svg"_s, mIconColor, mIconColor.darker() ) : 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 ) ) || ( fileInfo.isDir() && ( capabilities & Qgis::DataItemProviderCapability::Directories ) ) ) )
332 {
333 continue;
334 }
335
336 QgsDataItem *item = provider->createDataItem( path, this );
337 if ( item )
338 {
339 // 3rd party providers may not correctly set the ItemRepresentsFile capability, so force it here if we
340 // see that the item's path does match the original file path
341 if ( item->path() == path )
343
344 children.append( item );
345 createdItem = true;
346 }
347 }
348
349 if ( !createdItem )
350 {
351 // if item is a QGIS project, and no specific item provider has overridden handling of
352 // project items, then use the default project item behavior
353 if ( fileInfo.suffix().compare( "qgs"_L1, Qt::CaseInsensitive ) == 0 || fileInfo.suffix().compare( "qgz"_L1, Qt::CaseInsensitive ) == 0 )
354 {
355 QgsDataItem *item = new QgsProjectItem( this, fileInfo.completeBaseName(), path );
357 children.append( item );
358 continue;
359 }
360 }
361 }
362 return children;
363}
364
366{
368
369 if ( state == Qgis::BrowserItemState::Populated && mMonitored )
370 {
371 if ( !mFileSystemWatcher )
372 {
373 mFileSystemWatcher = new QFileSystemWatcher( this );
374 mFileSystemWatcher->addPath( mDirPath );
375 connect( mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &QgsDirectoryItem::directoryChanged );
376 }
377 mLastScan = QDateTime::currentDateTime();
378 }
380 {
381 if ( mFileSystemWatcher )
382 {
383 delete mFileSystemWatcher;
384 mFileSystemWatcher = nullptr;
385 }
386 }
387}
388
390{
391 // If the last scan was less than 10 seconds ago, skip this
392 if ( mLastScan.msecsTo( QDateTime::currentDateTime() ) < QgsSettings().value( u"browser/minscaninterval"_s, 10000 ).toInt() )
393 {
394 return;
395 }
397 {
398 // schedule to refresh later, because refresh() simply returns if Populating
399 mRefreshLater = true;
400 }
401 else
402 {
403 // We definintely don't want the temporary files created by sqlite
404 // to re-trigger a refresh in an infinite loop.
405 disconnect( mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &QgsDirectoryItem::directoryChanged );
406 // QFileSystemWhatcher::directoryChanged is emitted when a
407 // file is created and not when it is closed/flushed.
408 //
409 // Delay to give to OS the time to complete writing the file
410 // this happens when a new file appears in the directory and
411 // the item's children thread will try to open the file with
412 // GDAL or OGR even if it is still being written.
413 QTimer::singleShot( 100, this, [this] { refresh(); } );
414 }
415}
416
417bool QgsDirectoryItem::hiddenPath( const QString &path )
418{
419 const QgsSettings settings;
420 const QStringList hiddenItems = settings.value( u"browser/hiddenPaths"_s, QStringList() ).toStringList();
421 const int idx = hiddenItems.indexOf( path );
422 return ( idx > -1 );
423}
424
426{
427 const QgsSettings settings;
428 if ( settings.value( u"qgis/disableMonitorItemUris"_s, QStringList() ).toStringList().contains( path ) )
430 else if ( settings.value( u"qgis/alwaysMonitorItemUris"_s, QStringList() ).toStringList().contains( path ) )
433}
434
436{
437 // check through path's parent directories, to see if any have an explicit
438 // always/never monitor setting. If so, this path will inherit that setting
439 const QString originalPath = QDir::cleanPath( path );
440 QString currentPath = originalPath;
441 QString prevPath;
442 while ( currentPath != prevPath )
443 {
444 prevPath = currentPath;
445 currentPath = QFileInfo( currentPath ).path();
446
447 switch ( monitoringForPath( currentPath ) )
448 {
450 return false;
452 return true;
454 break;
455 }
456 }
457
458 // else if we know that the path is on a slow device, we don't monitor by default
459 // as this can be very expensive and slow down QGIS
460 // Add trailing slash or windows API functions like GetDriveTypeW won't identify
461 // UNC network drives correctly
462 if ( QgsFileUtils::pathIsSlowDevice( path.endsWith( '/' ) ? path : path + '/' ) )
463 return false;
464
465 // paths are monitored by default if no explicit setting is in place, and the user hasn't
466 // completely opted out of all browser monitoring
468}
469
471{
472 QgsDebugMsgLevel( u"mRefreshLater = %1"_s.arg( mRefreshLater ), 3 );
473
474 if ( mRefreshLater )
475 {
476 QgsDebugMsgLevel( u"directory changed during createChildren() -> refresh() again"_s, 3 );
477 mRefreshLater = false;
479 refresh();
480 }
481 else
482 {
484 }
485 // Re-connect the file watcher after all children have been created
486 if ( mFileSystemWatcher && mMonitored )
487 connect( mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &QgsDirectoryItem::directoryChanged );
488}
489
491{
492 //QgsDebugMsg ( mPath + " x " + other->mPath );
493 if ( type() != other->type() )
494 {
495 return false;
496 }
497 const QgsDirectoryItem *otherDirItem = qobject_cast< const QgsDirectoryItem * >( other );
498 if ( !otherDirItem )
499 return false;
500
501 return dirPath() == otherDirItem->dirPath();
502}
503
505{
506 return new QgsDirectoryParamWidget( mPath );
507}
508
510{
512 u.layerType = u"directory"_s;
513 u.name = mName;
514 u.uri = mDirPath;
515 u.filePath = path();
516 return { u };
517}
518
519//
520// QgsDirectoryParamWidget
521//
522QgsDirectoryParamWidget::QgsDirectoryParamWidget( const QString &path, QWidget *parent )
523 : QTreeWidget( parent )
524{
525 setRootIsDecorated( false );
526
527 // name, size, date, permissions, owner, group, type
528 setColumnCount( 7 );
529 QStringList labels;
530 labels << tr( "Name" ) << tr( "Size" ) << tr( "Date" ) << tr( "Permissions" ) << tr( "Owner" ) << tr( "Group" ) << tr( "Type" );
531 setHeaderLabels( labels );
532
533 const QIcon iconDirectory = QgsApplication::getThemeIcon( u"mIconFolder.svg"_s );
534 const QIcon iconFile = QgsApplication::getThemeIcon( u"mIconFile.svg"_s );
535 const QIcon iconDirLink = QgsApplication::getThemeIcon( u"mIconFolderLink.svg"_s );
536 const QIcon iconFileLink = QgsApplication::getThemeIcon( u"mIconFileLink.svg"_s );
537
538 QList<QTreeWidgetItem *> items;
539
540 const QDir dir( path );
541 const QStringList entries = dir.entryList( QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
542 for ( const QString &name : entries )
543 {
544 const QFileInfo fi( dir.absoluteFilePath( name ) );
545 QStringList texts;
546 texts << name;
547 QString size;
548 if ( fi.size() > 1024 )
549 {
550 size = u"%1 KiB"_s.arg( QLocale().toString( fi.size() / 1024.0, 'f', 1 ) );
551 }
552 else if ( fi.size() > 1.048576e6 )
553 {
554 size = u"%1 MiB"_s.arg( QLocale().toString( fi.size() / 1.048576e6, 'f', 1 ) );
555 }
556 else
557 {
558 size = u"%1 B"_s.arg( fi.size() );
559 }
560 texts << size;
561 texts << QLocale().toString( fi.lastModified(), QLocale::ShortFormat );
562 QString perm;
563 perm += fi.permission( QFile::ReadOwner ) ? 'r' : '-';
564 perm += fi.permission( QFile::WriteOwner ) ? 'w' : '-';
565 perm += fi.permission( QFile::ExeOwner ) ? 'x' : '-';
566 // QFile::ReadUser, QFile::WriteUser, QFile::ExeUser
567 perm += fi.permission( QFile::ReadGroup ) ? 'r' : '-';
568 perm += fi.permission( QFile::WriteGroup ) ? 'w' : '-';
569 perm += fi.permission( QFile::ExeGroup ) ? 'x' : '-';
570 perm += fi.permission( QFile::ReadOther ) ? 'r' : '-';
571 perm += fi.permission( QFile::WriteOther ) ? 'w' : '-';
572 perm += fi.permission( QFile::ExeOther ) ? 'x' : '-';
573 texts << perm;
574
575 texts << fi.owner();
576 texts << fi.group();
577
578 QString type;
579 QIcon icon;
580 if ( fi.isDir() && fi.isSymLink() )
581 {
582 type = tr( "folder" );
583 icon = iconDirLink;
584 }
585 else if ( fi.isDir() )
586 {
587 type = tr( "folder" );
588 icon = iconDirectory;
589 }
590 else if ( fi.isFile() && fi.isSymLink() )
591 {
592 type = tr( "file" );
593 icon = iconFileLink;
594 }
595 else if ( fi.isFile() )
596 {
597 type = tr( "file" );
598 icon = iconFile;
599 }
600
601 texts << type;
602
603 QTreeWidgetItem *item = new QTreeWidgetItem( texts );
604 item->setIcon( 0, icon );
605 items << item;
606 }
607
608 addTopLevelItems( items );
609
610 // hide columns that are not requested
611 const QgsSettings settings;
612 const QList<QVariant> lst = settings.value( u"dataitem/directoryHiddenColumns"_s ).toList();
613 for ( const QVariant &colVariant : lst )
614 {
615 setColumnHidden( colVariant.toInt(), true );
616 }
617}
618
620{
621 if ( event->button() == Qt::RightButton )
622 {
623 // show the popup menu
624 QMenu popupMenu;
625
626 QStringList labels;
627 labels << tr( "Name" ) << tr( "Size" ) << tr( "Date" ) << tr( "Permissions" ) << tr( "Owner" ) << tr( "Group" ) << tr( "Type" );
628 for ( int i = 0; i < labels.count(); i++ )
629 {
630 QAction *action = popupMenu.addAction( labels[i], this, &QgsDirectoryParamWidget::showHideColumn );
631 action->setObjectName( QString::number( i ) );
632 action->setCheckable( true );
633 action->setChecked( !isColumnHidden( i ) );
634 }
635
636 popupMenu.exec( event->globalPos() );
637 }
638}
639
641{
642 QAction *action = qobject_cast<QAction *>( sender() );
643 if ( !action )
644 return; // something is wrong
645
646 const int columnIndex = action->objectName().toInt();
647 setColumnHidden( columnIndex, !isColumnHidden( columnIndex ) );
648
649 // save in settings
650 QgsSettings settings;
651 QList<QVariant> lst;
652 for ( int i = 0; i < columnCount(); i++ )
653 {
654 if ( isColumnHidden( i ) )
655 lst.append( QVariant( i ) );
656 }
657 settings.setValue( u"dataitem/directoryHiddenColumns"_s, lst );
658}
659
660//
661// QgsProjectHomeItem
662//
663
664QgsProjectHomeItem::QgsProjectHomeItem( QgsDataItem *parent, const QString &name, const QString &dirPath, const QString &path )
665 : QgsDirectoryItem( parent, name, dirPath, path, u"special:ProjectHome"_s )
666{}
667
669{
671 return QgsDirectoryItem::icon();
672 return QgsApplication::getThemeIcon( u"mIconFolderProject.svg"_s );
673}
674
676{
677 return u" 1"_s;
678}
@ Files
Can provides items which corresponds to files.
Definition qgis.h:1044
@ Directories
Can provides items which corresponds to directories.
Definition qgis.h:1045
BrowserItemState
Browser item states.
Definition qgis.h:985
@ NotPopulated
Children not yet created.
Definition qgis.h:986
@ Populating
Creating children in separate thread (populating or refreshing).
Definition qgis.h:987
@ Populated
Children created.
Definition qgis.h:988
@ ItemRepresentsFile
Item's path() directly represents a file on disk.
Definition qgis.h:1006
BrowserDirectoryMonitoring
Browser directory item monitoring switches.
Definition qgis.h:1091
@ Default
Use default logic to determine whether directory should be monitored.
Definition qgis.h:1092
@ AlwaysMonitor
Always monitor the directory, regardless of the default logic.
Definition qgis.h:1094
@ NeverMonitor
Never monitor the directory, regardless of the default logic.
Definition qgis.h:1093
QFlags< DataItemProviderCapability > DataItemProviderCapabilities
Capabilities for data item providers.
Definition qgis.h:1058
@ Directory
Represents a file directory.
Definition qgis.h:968
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.
static const QgsSettingsEntryBool * settingsMonitorDirectoriesInBrowser
Settings entry for monitor directories in browser.
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.
A boolean settings entry.
static QgsSettingsTreeNode * sTreeQgis
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.