QGIS API Documentation  2.99.0-Master (6a61179)
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsBrowserModel Class Reference

#include <qgsbrowsermodel.h>

Inheritance diagram for QgsBrowserModel:
Inheritance graph
[legend]

Public Types

enum  ItemDataRole { PathRole = Qt::UserRole, CommentRole = Qt::UserRole + 1 }
 

Public Slots

void addFavoriteDirectory (const QString &directory)
 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 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 stateChanged (const QModelIndex &index, QgsDataItem::State oldState)
 Emitted when item children fetch was finished. More...
 

Public Member Functions

 QgsBrowserModel (QObject *parent=nullptr)
 
 ~QgsBrowserModel ()
 
bool canFetchMore (const QModelIndex &parent) const override
 
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const override
 Provides the number of columns of data exposed by the model. More...
 
void connectItem (QgsDataItem *item)
 
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 Used to supply item data to views and delegates. More...
 
QgsDataItemdataItem (const QModelIndex &idx) const
 
virtual 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...
 
virtual 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
 
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 Provides views with information to show in their headers. More...
 
virtual 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...
 
virtual QMimeData * mimeData (const QModelIndexList &indexes) const override
 Returns an object that contains serialized items of data corresponding to the list of indexes specified. More...
 
virtual QStringList mimeTypes () const override
 Returns a list of mime that can describe model indexes. More...
 
virtual 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...
 
virtual 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

QgsFavoritesItemmFavorites
 
QgsDirectoryItemmProjectHome
 
QVector< QgsDataItem * > mRootItems
 

Detailed Description

Definition at line 51 of file qgsbrowsermodel.h.

Member Enumeration Documentation

§ ItemDataRole

Enumerator
PathRole 

Item path used to access path in the tree, see QgsDataItem::mPath.

CommentRole 

Item comment.

Definition at line 59 of file qgsbrowsermodel.h.

Constructor & Destructor Documentation

§ QgsBrowserModel()

QgsBrowserModel::QgsBrowserModel ( QObject *  parent = nullptr)
explicit

Definition at line 50 of file qgsbrowsermodel.cpp.

§ ~QgsBrowserModel()

QgsBrowserModel::~QgsBrowserModel ( )

Definition at line 60 of file qgsbrowsermodel.cpp.

Member Function Documentation

§ addFavoriteDirectory

void QgsBrowserModel::addFavoriteDirectory ( const QString &  directory)
slot

Adds a directory to the favorites group.

Note
added in QGIS 3.0
See also
removeFavorite()

Definition at line 533 of file qgsbrowsermodel.cpp.

§ addRootItems()

void QgsBrowserModel::addRootItems ( )
protected

Populates the model.

Definition at line 92 of file qgsbrowsermodel.cpp.

§ beginInsertItems

void QgsBrowserModel::beginInsertItems ( QgsDataItem parent,
int  first,
int  last 
)
slot

Definition at line 374 of file qgsbrowsermodel.cpp.

§ beginRemoveItems

void QgsBrowserModel::beginRemoveItems ( QgsDataItem parent,
int  first,
int  last 
)
slot

Definition at line 389 of file qgsbrowsermodel.cpp.

§ canFetchMore()

bool QgsBrowserModel::canFetchMore ( const QModelIndex &  parent) const
override

Definition at line 494 of file qgsbrowsermodel.cpp.

§ columnCount()

int QgsBrowserModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
overridevirtual

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 277 of file qgsbrowsermodel.cpp.

§ connectItem()

void QgsBrowserModel::connectItem ( QgsDataItem item)

Definition at line 420 of file qgsbrowsermodel.cpp.

§ data()

QVariant QgsBrowserModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
overridevirtual

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 197 of file qgsbrowsermodel.cpp.

§ dataItem()

QgsDataItem * QgsBrowserModel::dataItem ( const QModelIndex &  idx) const

Definition at line 486 of file qgsbrowsermodel.cpp.

§ dropMimeData()

bool QgsBrowserModel::dropMimeData ( const QMimeData *  data,
Qt::DropAction  action,
int  row,
int  column,
const QModelIndex &  parent 
)
overridevirtual

Handles the data supplied by a drag and drop operation that ended with the given action.

Definition at line 471 of file qgsbrowsermodel.cpp.

§ endInsertItems

void QgsBrowserModel::endInsertItems ( )
slot

Definition at line 384 of file qgsbrowsermodel.cpp.

§ endRemoveItems

void QgsBrowserModel::endRemoveItems ( )
slot

Definition at line 397 of file qgsbrowsermodel.cpp.

§ fetchMore()

void QgsBrowserModel::fetchMore ( const QModelIndex &  parent)
override

Definition at line 502 of file qgsbrowsermodel.cpp.

§ findItem()

QModelIndex QgsBrowserModel::findItem ( QgsDataItem item,
QgsDataItem parent = nullptr 
) const

Definition at line 357 of file qgsbrowsermodel.cpp.

§ findPath() [1/2]

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.

Parameters
pathitem path
matchFlagsupported 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

Definition at line 283 of file qgsbrowsermodel.cpp.

§ findPath() [2/2]

QModelIndex QgsBrowserModel::findPath ( QAbstractItemModel *  model,
const QString &  path,
Qt::MatchFlag  matchFlag = Qt::MatchExactly 
)
static
Note
not available in python bindings

Definition at line 288 of file qgsbrowsermodel.cpp.

§ flags()

Qt::ItemFlags QgsBrowserModel::flags ( const QModelIndex &  index) const
overridevirtual

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 181 of file qgsbrowsermodel.cpp.

§ hasChildren()

bool QgsBrowserModel::hasChildren ( const QModelIndex &  parent = QModelIndex()) const
override

Definition at line 268 of file qgsbrowsermodel.cpp.

§ headerData()

QVariant QgsBrowserModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
overridevirtual

Provides views with information to show in their headers.

The information is only retrieved by views that can display header information.

Definition at line 239 of file qgsbrowsermodel.cpp.

§ hidePath

void QgsBrowserModel::hidePath ( QgsDataItem item)
slot

Hide the given path in the browser model.

Definition at line 548 of file qgsbrowsermodel.cpp.

§ index()

QModelIndex QgsBrowserModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
overridevirtual

Returns the index of the item in the model specified by the given row, column and parent index.

Definition at line 337 of file qgsbrowsermodel.cpp.

§ itemDataChanged

void QgsBrowserModel::itemDataChanged ( QgsDataItem item)
slot

Definition at line 402 of file qgsbrowsermodel.cpp.

§ itemStateChanged

void QgsBrowserModel::itemStateChanged ( QgsDataItem item,
QgsDataItem::State  oldState 
)
slot

Definition at line 410 of file qgsbrowsermodel.cpp.

§ mimeData()

QMimeData * QgsBrowserModel::mimeData ( const QModelIndexList &  indexes) const
overridevirtual

Returns an object that contains serialized items of data corresponding to the list of indexes specified.

Definition at line 445 of file qgsbrowsermodel.cpp.

§ mimeTypes()

QStringList QgsBrowserModel::mimeTypes ( ) const
overridevirtual

Returns a list of mime that can describe model indexes.

Definition at line 436 of file qgsbrowsermodel.cpp.

§ parent()

QModelIndex QgsBrowserModel::parent ( const QModelIndex &  index) const
overridevirtual

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 348 of file qgsbrowsermodel.cpp.

§ refresh() [1/2]

void QgsBrowserModel::refresh ( const QString &  path)

Refresh item specified by path.

Definition at line 515 of file qgsbrowsermodel.cpp.

§ refresh() [2/2]

void QgsBrowserModel::refresh ( const QModelIndex &  index = QModelIndex())

Refresh item children.

Definition at line 522 of file qgsbrowsermodel.cpp.

§ reload

void QgsBrowserModel::reload ( )
slot

Reload the whole model.

Definition at line 328 of file qgsbrowsermodel.cpp.

§ removeFavorite

void QgsBrowserModel::removeFavorite ( const QModelIndex &  index)
slot

Removes a favorite directory from its corresponding model index.

Note
added in QGIS 3.0
See also
addFavoriteDirectory()

Definition at line 539 of file qgsbrowsermodel.cpp.

§ removeRootItems()

void QgsBrowserModel::removeRootItems ( )
protected

Definition at line 170 of file qgsbrowsermodel.cpp.

§ rowCount()

int QgsBrowserModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
overridevirtual

Provides the number of rows of data exposed by the model.

Definition at line 250 of file qgsbrowsermodel.cpp.

§ stateChanged

void QgsBrowserModel::stateChanged ( const QModelIndex &  index,
QgsDataItem::State  oldState 
)
signal

Emitted when item children fetch was finished.

§ updateProjectHome

void QgsBrowserModel::updateProjectHome ( )
slot

Definition at line 65 of file qgsbrowsermodel.cpp.

Member Data Documentation

§ mFavorites

QgsFavoritesItem* QgsBrowserModel::mFavorites
protected

Definition at line 171 of file qgsbrowsermodel.h.

§ mProjectHome

QgsDirectoryItem* QgsBrowserModel::mProjectHome
protected

Definition at line 172 of file qgsbrowsermodel.h.

§ mRootItems

QVector<QgsDataItem*> QgsBrowserModel::mRootItems
protected

Definition at line 170 of file qgsbrowsermodel.h.


The documentation for this class was generated from the following files: