Class: QgsDirectoryItem¶
- class qgis.core.QgsDirectoryItem¶
Bases:
QgsDataCollectionItem
A directory: contains subdirectories and layers
QgsDirectoryItem(parent:
QgsDataItem
, name: str, path: str) Constructor forQgsDirectoryItem
, with the specifiedparent
item.The
name
argument specifies the text to show in the model for the item. This is usually the directory name, but in certain cases may differ for special directories (e.g. “Home”). If a non-directory-name text is used, it should be a translated string when appropriate.The
path
argument specifies the directory path in the file system (e.g. “/home/gsherman/stuff”). A valid directory path must be specified.QgsDirectoryItem(parent:
QgsDataItem
, name: str, dirPath: str, path: str, providerKey: str = ‘’) Constructor forQgsDirectoryItem
, with the specifiedparent
item.The
name
argument specifies the text to show in the model for the item. This is usually the directory name, but in certain cases may differ for special directories (e.g. “Home”). If a non-directory-name text is used, it should be a translated string when appropriate.The
dirPath
argument specifies the directory path in the file system (e.g. “/home/gsherman/stuff”). A valid directory path must be specified.The
path
argument gives the item path in the browser tree. Thepath
string can take any form, but is usually the same asdirPath
ordirPath
with a prefix, e.g. “favorites:/home/gsherman/Downloads”). QgsDirectoryItem items pointing to differentdirPaths
should always use a different itempath
.The optional
providerKey
string can be used to specify the key for theQgsDataItemProvider
that created this item.Methods
- rtype:
List[QgsDataItem]
The item is scheduled to be deleted.
Returns the full path to the directory the item represents.
- param other:
- rtype:
bool
Check if the given path is hidden from the browser model
Shared home directory icon.
- rtype:
QIcon
Returns the directory's icon color.
Returns
True
if the directory is currently being monitored for changes and the item auto-refreshed when these occur.- rtype:
List[QgsMimeDataUtils.Uri]
Returns the monitoring setting for this directory item.
Returns the monitoring setting for a directory
path
.Shared open directory icon.
- rtype:
QWidget
Returns
True
if a directorypath
should be monitored by default.Refresh the items from a specified list of child items.
Sets a custom icon
color
to use for the items for the correspondingdirectory
path.Sets the directory's icon
color
.Sets the
monitoring
setting for this directory.- param state:
Will request a repaint of this icon.
- childEvent(self, QChildEvent)¶
- childrenCreated(self)¶
- connectNotify(self, QMetaMethod)¶
- createChildren(self) List[QgsDataItem] ¶
- Return type:
List[QgsDataItem]
- customEvent(self, QEvent)¶
- deferredDelete(self) bool ¶
The item is scheduled to be deleted. E.g. if
deleteLater()
is called when item is in Populating state (createChildren()
running in another thread), thedeferredDelete()
returnsTrue
and item will be deleted once Populating finished. Items with slowreateChildren()
(for example network or database based) may check duringcreateChildren()
ifdeferredDelete()
returnsTrue
and return fromcreateChildren()
immediately because result will be useless.
- dirPath(self) str ¶
Returns the full path to the directory the item represents.
- Return type:
str
- directoryChanged(self)¶
- disconnectNotify(self, QMetaMethod)¶
- equal(self, other: QgsDataItem) bool ¶
- Parameters:
other (QgsDataItem) –
- Return type:
bool
- hasDragEnabled(self) bool ¶
- Return type:
bool
Check if the given path is hidden from the browser model
- Parameters:
path (str) –
- Return type:
bool
- homeDirIcon(fillColor: QColor | Qt.GlobalColor | QGradient = QColor(), strokeColor: QColor | Qt.GlobalColor | QGradient = QColor()) QIcon ¶
Shared home directory icon.
Since QGIS 3.20 the optional
fillColor
andstrokeColor
arguments can be used to specify a fill and stroke color for the icon.New in version 3.4.
- icon(self) QIcon ¶
- Return type:
QIcon
- iconColor(self) QColor ¶
Returns the directory’s icon color.
An invalid color will be returned if the default icon color is used.
See also
New in version 3.20.
- Return type:
QColor
- init(self)¶
- isMonitored(self) bool ¶
Returns
True
if the directory is currently being monitored for changes and the item auto-refreshed when these occur.New in version 3.20.
- Return type:
bool
- isSignalConnected(self, QMetaMethod) bool ¶
- mimeUris(self) List[QgsMimeDataUtils.Uri] ¶
- Return type:
List[QgsMimeDataUtils.Uri]
- monitoring(self) Qgis.BrowserDirectoryMonitoring ¶
Returns the monitoring setting for this directory item.
See also
New in version 3.20.
- Return type:
- monitoringForPath(path: str) Qgis.BrowserDirectoryMonitoring ¶
Returns the monitoring setting for a directory
path
.This method returns the monitoring setting for
path
only. If no explicit monitoring setting is in place for the path then Qgis.BrowserDirectoryMonitoring.Default is returned.This method does not consider the monitoring setting of parent directories.
New in version 3.20.
- Parameters:
path (str) –
- Return type:
- openDirIcon(fillColor: QColor | Qt.GlobalColor | QGradient = QColor(), strokeColor: QColor | Qt.GlobalColor | QGradient = QColor()) QIcon ¶
Shared open directory icon.
Since QGIS 3.20 the optional
fillColor
andstrokeColor
arguments can be used to specify a fill and stroke color for the icon.New in version 3.4.
- paramWidget(self) QWidget ¶
- Return type:
QWidget
- pathShouldByMonitoredByDefault(path: str) bool ¶
Returns
True
if a directorypath
should be monitored by default.In the absence of any other settings this will dictate whether the directory is monitored. This method does not consider an explicit monitoring setting set for the path, which can be determined by calling
monitoringForPath()
.All parent directories will be checked to determine whether they have monitoring manually enabled or disabled. As soon as a parent directory is found which has monitoring manually enabled or disabled then the corresponding value will be returned.
If no explicit setting is in place for a parent directory, then a check will be made to determine whether the path resides on a known slow drive. If so, monitoring is disabled by default and
False
will be returned. Otherwise paths are monitored by default and the function will returnTrue
.See also
See also
New in version 3.20.
- Parameters:
path (str) –
- Return type:
bool
- populate(self, children: Iterable[QgsDataItem])¶
- populate(self, foreground: bool = False) None
- receivers(self, PYQT_SIGNAL) int ¶
- refresh(self, children: Iterable[QgsDataItem])¶
Refresh the items from a specified list of child items.
refresh(self)
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setCustomColor(directory: str, color: QColor | Qt.GlobalColor | QGradient)¶
Sets a custom icon
color
to use for the items for the correspondingdirectory
path.If
color
is an invalid color then the default icon color will be used.New in version 3.20.
- Parameters:
directory (str) –
color (Union[QColor) –
- setIconColor(self, color: QColor | Qt.GlobalColor | QGradient)¶
Sets the directory’s icon
color
.Setting an invalid color will cause the default icon color to be used.
This is a transient property, and will not permanently alter the directory’s colors in future QGIS sessions. Use
setCustomColor()
to permanently set the directory’s color.See also
New in version 3.20.
- Parameters:
color (Union[QColor) –
- setMonitoring(self, monitoring: Qgis.BrowserDirectoryMonitoring)¶
Sets the
monitoring
setting for this directory.This is a persistent setting, which is saved in QSettings.
See also
New in version 3.20.
- Parameters:
monitoring (Qgis.BrowserDirectoryMonitoring) –
- setState(self, state: Qgis.BrowserItemState)¶
- Parameters:
state (Qgis.BrowserItemState) –
- timerEvent(self, QTimerEvent)¶
- updateIcon(self)¶
Will request a repaint of this icon.
New in version 3.0.