Class: QgsBrowserModel¶
-
class
qgis.core.
QgsBrowserModel
(parent: QObject = None)¶ Bases:
PyQt5.QtCore.QAbstractItemModel
Constructor for QgsBrowserModel, with the specified
parent
object.Note
QgsBrowserModel models are not initially populated and use a deferred initialization approach. After constructing a QgsBrowserModel, a call must be made to initialize() in order to populate the model.
A model for showing available data sources and other items in a structured tree.
QgsBrowserModel is the foundation for the QGIS browser panel, and includes items for the different data providers and folders accessible to users.
QgsBrowserModel models are not initially populated and use a deferred initialization approach. After constructing a QgsBrowserModel, a call must be made to initialize() in order to populate the model.
Enums
Methods
Adds a
directory
to the favorites group.Populates the model
Deprecated since version Deprecated: since QGIS 3.4 – this method has no effect, and is dangerous to call in earlier QGIS versions. Any usage should be removed (and will have no harmful side-effects!).
Returns the data item at the specified index, or a None if no item exists at the index.
Returns a map of the root drive items shown in the browser.
Returns the model index corresponding to the specified data
item
.Returns index of item with given path.
Returns index of layer item with given uri.
Hide the given path in the browser model
Delayed initialization, needed because the provider registry must be already populated.
Returns true if the model has been initialized.
Refresh item specified by path
Refreshes the list of drive items, removing any corresponding to removed drives and adding newly added drives.
Reload the whole model
Removes a favorite directory from its corresponding model index.
Signals
Connections changed in the browser, forwarded to the widget and used to notify the provider dialogs of a changed connection [signal]
Emitted when item children fetch was finished [signal]
Attributes
-
CommentRole
= 257¶
-
class
ItemDataRole
¶ Bases:
int
-
PathRole
= 256¶
-
SortRole
= 258¶
-
addFavoriteDirectory
(self, directory: str, name: str = '')¶ Adds a
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 matchdirectory
.See also
New in version 3.0.
-
addRootItems
(self)¶ Populates the model
-
beginInsertColumns
()¶
-
beginInsertItems
(self, parent: QgsDataItem, first: int, last: int)¶
-
beginInsertRows
()¶
-
beginMoveColumns
()¶
-
beginMoveRows
()¶
-
beginRemoveColumns
()¶
-
beginRemoveItems
(self, parent: QgsDataItem, first: int, last: int)¶
-
beginRemoveRows
()¶
-
beginResetModel
()¶
-
canFetchMore
(self, parent: QModelIndex) → bool¶
-
changePersistentIndex
()¶
-
changePersistentIndexList
()¶
-
childEvent
()¶
-
columnCount
(self, parent: QModelIndex = QModelIndex()) → int¶
-
connectItem
(self, item: QgsDataItem)¶ Deprecated since version Deprecated: since QGIS 3.4 – this method has no effect, and is dangerous to call in earlier QGIS versions. Any usage should be removed (and will have no harmful side-effects!).
-
connectNotify
()¶
-
connectionsChanged
¶ Connections changed in the browser, forwarded to the widget and used to notify the provider dialogs of a changed connection [signal]
-
createIndex
()¶
-
customEvent
()¶
-
data
(self, index: QModelIndex, role: int = Qt.DisplayRole) → Any¶
-
dataItem
(self, idx: QModelIndex) → QgsDataItem¶ Returns the data item at the specified index, or a None if no item exists at the index.
-
decodeData
()¶
-
disconnectNotify
()¶
-
driveItems
(self) → object¶ Returns a map of the root drive items shown in the browser.
These correspond to the top-level directory items shown, e.g. on Windows the C:, D:, etc, and on Linux the “/” root directory.
New in version 3.6.
-
dropMimeData
(self, data: QMimeData, action: Qt.DropAction, row: int, column: int, parent: QModelIndex) → bool¶
-
encodeData
()¶
-
endInsertColumns
()¶
-
endInsertItems
(self)¶
-
endInsertRows
()¶
-
endMoveColumns
()¶
-
endMoveRows
()¶
-
endRemoveColumns
()¶
-
endRemoveItems
(self)¶
-
endRemoveRows
()¶
-
endResetModel
()¶
-
fetchMore
(self, parent: QModelIndex)¶
-
findItem
(self, item: QgsDataItem, parent: QgsDataItem = None) → QModelIndex¶ Returns the model index corresponding to the specified data
item
. If the item was not found, an invalid QModelIndex is returned.If the
parent
item is argument is specified, then only items which are children ofparent
are searched. If noparent
is specified, then all items within the model are searched.
-
findPath
(self, path: str, matchFlag: Qt.MatchFlag = Qt.MatchExactly) → QModelIndex¶ Returns index of item with given path. It only searches in currently fetched items, i.e. it does not fetch children.
- Parameters
path – item path
matchFlag – supported is Qt.MatchExactly and Qt.MatchStartsWith which has reverse meaning, i.e. find item with the longest match from start with path (to get as close/deep as possible to deleted item).
- Returns
model index, invalid if item not found *
-
findUri
(self, uri: str, index: QModelIndex = QModelIndex()) → QModelIndex¶ Returns index of layer item with given uri. It only searches in currently fetched items, i.e. it does not fetch children.
- Parameters
uri – item uri
index – the current index of the parent (to search for children)
- Returns
model index, invalid if item not found
New in version 3.6.
-
flags
(self, index: QModelIndex) → Qt.ItemFlags¶
-
hasChildren
(self, parent: QModelIndex = QModelIndex()) → bool¶
-
headerData
(self, section: int, orientation: Qt.Orientation, role: int = Qt.DisplayRole) → Any¶
-
hidePath
(self, item: QgsDataItem)¶ Hide the given path in the browser model
-
index
(self, row: int, column: int, parent: QModelIndex = QModelIndex()) → QModelIndex¶
-
initialize
(self)¶ Delayed initialization, needed because the provider registry must be already populated.
See also
-
initialized
(self) → bool¶ Returns true if the model has been initialized.
See also
-
isSignalConnected
()¶
-
itemDataChanged
(self, item: QgsDataItem)¶
-
itemStateChanged
(self, item: QgsDataItem, oldState: QgsDataItem.State)¶
-
mimeData
(self, indexes: object) → QMimeData¶
-
mimeTypes
(self) → List[str]¶
-
parent
(self, index: QModelIndex) → QModelIndex¶
-
persistentIndexList
()¶
-
receivers
()¶
-
refresh
(self, path: str)¶ Refresh item specified by path
refresh(self, index: QModelIndex = QModelIndex()) Refresh item children
-
refreshDrives
(self)¶ Refreshes the list of drive items, removing any corresponding to removed drives and adding newly added drives.
New in version 3.4.
-
reload
(self)¶ Reload the whole model
-
removeFavorite
(self, index: QModelIndex)¶ Removes a favorite directory from its corresponding model index.
See also
New in version 3.0.
-
removeRootItems
(self)¶
-
resetInternalData
()¶
-
rowCount
(self, parent: QModelIndex = QModelIndex()) → int¶
-
sender
()¶
-
senderSignalIndex
()¶
-
setData
(self, index: QModelIndex, value: Any, role: int = Qt.EditRole) → bool¶
-
stateChanged
¶ Emitted when item children fetch was finished [signal]
-
timerEvent
()¶
-
updateProjectHome
(self)¶
-