QGIS API Documentation
3.0.2-Girona (307d082)
|
#include <qgsbrowsermodel.h>
Public Types | |
enum | ItemDataRole { PathRole = Qt::UserRole, CommentRole = Qt::UserRole + 1, SortRole } |
Public Slots | |
void | addFavoriteDirectory (const QString &directory, const QString &name=QString()) |
Adds a directory to the favorites group. More... | |
void | beginInsertItems (QgsDataItem *parent, int first, int last) |
void | beginRemoveItems (QgsDataItem *parent, int first, int last) |
void | endInsertItems () |
void | endRemoveItems () |
void | hidePath (QgsDataItem *item) |
Hide the given path in the browser model. More... | |
void | initialize () |
Delayed initialization, needed because the provider registry must be already populated. More... | |
void | itemDataChanged (QgsDataItem *item) |
void | itemStateChanged (QgsDataItem *item, QgsDataItem::State oldState) |
void | reload () |
Reload the whole model. More... | |
void | removeFavorite (const QModelIndex &index) |
Removes a favorite directory from its corresponding model index. More... | |
void | updateProjectHome () |
Signals | |
void | connectionsChanged () |
Connections changed in the browser, forwarded to the widget and used to notify the provider dialogs of a changed connection. More... | |
void | stateChanged (const QModelIndex &index, QgsDataItem::State oldState) |
Emitted when item children fetch was finished. More... | |
Public Member Functions | |
QgsBrowserModel (QObject *parent=nullptr) | |
~QgsBrowserModel () override | |
bool | canFetchMore (const QModelIndex &parent) const override |
int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
Provides the number of columns of data exposed by the model. More... | |
void | connectItem (QgsDataItem *item) |
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
Used to supply item data to views and delegates. More... | |
QgsDataItem * | dataItem (const QModelIndex &idx) const |
bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override |
Handles the data supplied by a drag and drop operation that ended with the given action. More... | |
void | fetchMore (const QModelIndex &parent) override |
QModelIndex | findItem (QgsDataItem *item, QgsDataItem *parent=nullptr) const |
QModelIndex | findPath (const QString &path, Qt::MatchFlag matchFlag=Qt::MatchExactly) |
Return index of item with given path. More... | |
Qt::ItemFlags | flags (const QModelIndex &index) const override |
Used by other components to obtain information about each item provided by the model. More... | |
bool | hasChildren (const QModelIndex &parent=QModelIndex()) const override |
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override |
Provides views with information to show in their headers. More... | |
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const override |
Returns the index of the item in the model specified by the given row, column and parent index. More... | |
bool | initialized () const |
Returns true if the model has been initialized. More... | |
QMimeData * | mimeData (const QModelIndexList &indexes) const override |
Returns an object that contains serialized items of data corresponding to the list of indexes specified. More... | |
QStringList | mimeTypes () const override |
Returns a list of mime that can describe model indexes. More... | |
QModelIndex | parent (const QModelIndex &index) const override |
Returns the parent of the model item with the given index. More... | |
void | refresh (const QString &path) |
Refresh item specified by path. More... | |
void | refresh (const QModelIndex &index=QModelIndex()) |
Refresh item children. More... | |
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
Provides the number of rows of data exposed by the model. More... | |
Static Public Member Functions | |
static QModelIndex | findPath (QAbstractItemModel *model, const QString &path, Qt::MatchFlag matchFlag=Qt::MatchExactly) |
Protected Member Functions | |
void | addRootItems () |
Populates the model. More... | |
void | removeRootItems () |
Protected Attributes | |
QgsFavoritesItem * | mFavorites = nullptr |
QgsDirectoryItem * | mProjectHome = nullptr |
QVector< QgsDataItem * > | mRootItems |
Definition at line 55 of file qgsbrowsermodel.h.
Enumerator | |
---|---|
PathRole | Item path used to access path in the tree, see QgsDataItem::mPath. |
CommentRole | Item comment. |
SortRole | Custom sort role, see QgsDataItem::sortKey() |
Definition at line 63 of file qgsbrowsermodel.h.
|
explicit |
Definition at line 45 of file qgsbrowsermodel.cpp.
|
override |
Definition at line 51 of file qgsbrowsermodel.cpp.
|
slot |
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 match directory.
Definition at line 549 of file qgsbrowsermodel.cpp.
|
protected |
Populates the model.
Definition at line 83 of file qgsbrowsermodel.cpp.
|
slot |
Definition at line 384 of file qgsbrowsermodel.cpp.
|
slot |
Definition at line 399 of file qgsbrowsermodel.cpp.
|
override |
Definition at line 510 of file qgsbrowsermodel.cpp.
|
override |
Provides the number of columns of data exposed by the model.
List models do not provide this function because it is already implemented in QAbstractListModel.
Definition at line 287 of file qgsbrowsermodel.cpp.
|
signal |
Connections changed in the browser, forwarded to the widget and used to notify the provider dialogs of a changed connection.
void QgsBrowserModel::connectItem | ( | QgsDataItem * | item | ) |
Definition at line 431 of file qgsbrowsermodel.cpp.
|
override |
Used to supply item data to views and delegates.
Generally, models only need to supply data for Qt::DisplayRole and any application-specific user roles, but it is also good practice to provide data for Qt::ToolTipRole, Qt::AccessibleTextRole, and Qt::AccessibleDescriptionRole. See the Qt::ItemDataRole enum documentation for information about the types associated with each role.
Definition at line 203 of file qgsbrowsermodel.cpp.
QgsDataItem * QgsBrowserModel::dataItem | ( | const QModelIndex & | idx | ) | const |
Definition at line 502 of file qgsbrowsermodel.cpp.
|
override |
Handles the data supplied by a drag and drop operation that ended with the given action.
Definition at line 487 of file qgsbrowsermodel.cpp.
|
slot |
Definition at line 394 of file qgsbrowsermodel.cpp.
|
slot |
Definition at line 407 of file qgsbrowsermodel.cpp.
|
override |
Definition at line 518 of file qgsbrowsermodel.cpp.
QModelIndex QgsBrowserModel::findItem | ( | QgsDataItem * | item, |
QgsDataItem * | parent = nullptr |
||
) | const |
Definition at line 367 of file qgsbrowsermodel.cpp.
QModelIndex QgsBrowserModel::findPath | ( | const QString & | path, |
Qt::MatchFlag | matchFlag = Qt::MatchExactly |
||
) |
Return index of item with given path.
It only searches in currently fetched items, i.e. it does not fetch children.
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). |
Definition at line 293 of file qgsbrowsermodel.cpp.
|
static |
Definition at line 298 of file qgsbrowsermodel.cpp.
|
override |
Used by other components to obtain information about each item provided by the model.
In many models, the combination of flags should include Qt::ItemIsEnabled and Qt::ItemIsSelectable.
Definition at line 187 of file qgsbrowsermodel.cpp.
|
override |
Definition at line 278 of file qgsbrowsermodel.cpp.
|
override |
Provides views with information to show in their headers.
The information is only retrieved by views that can display header information.
Definition at line 249 of file qgsbrowsermodel.cpp.
|
slot |
Hide the given path in the browser model.
Definition at line 564 of file qgsbrowsermodel.cpp.
|
override |
Returns the index of the item in the model specified by the given row, column and parent index.
Definition at line 347 of file qgsbrowsermodel.cpp.
|
slot |
Delayed initialization, needed because the provider registry must be already populated.
Definition at line 175 of file qgsbrowsermodel.cpp.
|
inline |
Returns true if the model has been initialized.
Definition at line 144 of file qgsbrowsermodel.h.
|
slot |
Definition at line 412 of file qgsbrowsermodel.cpp.
|
slot |
Definition at line 420 of file qgsbrowsermodel.cpp.
|
override |
Returns an object that contains serialized items of data corresponding to the list of indexes specified.
Definition at line 461 of file qgsbrowsermodel.cpp.
|
override |
Returns a list of mime that can describe model indexes.
Definition at line 452 of file qgsbrowsermodel.cpp.
|
override |
Returns the parent of the model item with the given index.
If the item has no parent, an invalid QModelIndex is returned.
Definition at line 358 of file qgsbrowsermodel.cpp.
void QgsBrowserModel::refresh | ( | const QString & | path | ) |
Refresh item specified by path.
Definition at line 531 of file qgsbrowsermodel.cpp.
void QgsBrowserModel::refresh | ( | const QModelIndex & | index = QModelIndex() | ) |
Refresh item children.
Definition at line 538 of file qgsbrowsermodel.cpp.
|
slot |
Reload the whole model.
Definition at line 338 of file qgsbrowsermodel.cpp.
|
slot |
Removes a favorite directory from its corresponding model index.
Definition at line 555 of file qgsbrowsermodel.cpp.
|
protected |
Definition at line 165 of file qgsbrowsermodel.cpp.
|
override |
Provides the number of rows of data exposed by the model.
Definition at line 260 of file qgsbrowsermodel.cpp.
|
signal |
Emitted when item children fetch was finished.
|
slot |
Definition at line 56 of file qgsbrowsermodel.cpp.
|
protected |
Definition at line 198 of file qgsbrowsermodel.h.
|
protected |
Definition at line 199 of file qgsbrowsermodel.h.
|
protected |
Definition at line 197 of file qgsbrowsermodel.h.