Class: QgsFavoritesItem

class qgis.core.QgsFavoritesItem

Bases: QgsDataCollectionItem

Contains various Favorites directories

New in version 3.0.

QgsFavoritesItem(parent: QgsDataItem, name: str, path: str = ‘’) Constructor for QgsFavoritesItem. Accepts a path argument specifying the file path associated with the item.

Methods

addDirectory

Adds a new directory to the favorites group.

childEvent

connectNotify

createChildren

rtype:

List[QgsDataItem]

customEvent

deferredDelete

The item is scheduled to be deleted.

disconnectNotify

homeDirIcon

Shared home directory icon.

iconFavorites

Icon for favorites group

isSignalConnected

openDirIcon

Shared open directory icon.

populate

receivers

refresh

Refresh the items from a specified list of child items.

removeDirectory

Removes an existing directory from the favorites group.

renameFavorite

Renames the stored favorite with corresponding path a new name.

sender

senderSignalIndex

sortKey

rtype:

Any

timerEvent

updateIcon

Will request a repaint of this icon.

addDirectory(self, directory: str, name: str = '')

Adds a new directory to the favorites group.

If name is specified, it will be used as the favorite’s name. Otherwise the name will be set to match directory.

Parameters:
  • directory (str) –

  • name (str = '') –

childEvent(self, QChildEvent)
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), the deferredDelete() returns True and item will be deleted once Populating finished. Items with slow reateChildren() (for example network or database based) may check during createChildren() if deferredDelete() returns True and return from createChildren() immediately because result will be useless.

disconnectNotify(self, QMetaMethod)
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 and strokeColor arguments can be used to specify a fill and stroke color for the icon.

New in version 3.4.

iconFavorites() QIcon

Icon for favorites group

Return type:

QIcon

isSignalConnected(self, QMetaMethod) bool
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 and strokeColor arguments can be used to specify a fill and stroke color for the icon.

New in version 3.4.

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)

removeDirectory(self, item: QgsDirectoryItem)

Removes an existing directory from the favorites group.

See also

addDirectory()

Parameters:

item (QgsDirectoryItem) –

renameFavorite(self, path: str, name: str)

Renames the stored favorite with corresponding path a new name.

Parameters:
  • path (str) –

  • name (str) –

sender(self) QObject
senderSignalIndex(self) int
sortKey(self) Any
Return type:

Any

timerEvent(self, QTimerEvent)
updateIcon(self)

Will request a repaint of this icon.

New in version 3.0.