QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 }
 

Public Slots

void addFavouriteDirectory (QString favDir)
 
void beginInsertItems (QgsDataItem *parent, int first, int last)
 
void beginRemoveItems (QgsDataItem *parent, int first, int last)
 
void endInsertItems ()
 
void endRemoveItems ()
 
void itemDataChanged (QgsDataItem *item)
 
void itemStateChanged (QgsDataItem *item, QgsDataItem::State oldState)
 
void reload ()
 
void removeFavourite (const QModelIndex &index)
 
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=0)
 
 ~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=0) const
 
QModelIndex findPath (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 (QString path)
 
void refresh (const QModelIndex &index=QModelIndex())
 
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, QString path, Qt::MatchFlag matchFlag=Qt::MatchExactly)
 

Protected Member Functions

void addRootItems ()
 
void removeRootItems ()
 

Protected Attributes

QgsFavouritesItemmFavourites
 
QgsDirectoryItemmProjectHome
 
QVector< QgsDataItem * > mRootItems
 

Detailed Description

Definition at line 44 of file qgsbrowsermodel.h.

Member Enumeration Documentation

Enumerator
PathRole 

Definition at line 52 of file qgsbrowsermodel.h.

Constructor & Destructor Documentation

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

Definition at line 47 of file qgsbrowsermodel.cpp.

QgsBrowserModel::~QgsBrowserModel ( )

Definition at line 57 of file qgsbrowsermodel.cpp.

Member Function Documentation

void QgsBrowserModel::addFavouriteDirectory ( QString  favDir)
slot

Definition at line 528 of file qgsbrowsermodel.cpp.

void QgsBrowserModel::addRootItems ( )
protected

Definition at line 89 of file qgsbrowsermodel.cpp.

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

Definition at line 377 of file qgsbrowsermodel.cpp.

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

Definition at line 392 of file qgsbrowsermodel.cpp.

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

Definition at line 488 of file qgsbrowsermodel.cpp.

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

void QgsBrowserModel::connectItem ( QgsDataItem item)

Definition at line 424 of file qgsbrowsermodel.cpp.

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

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

Definition at line 480 of file qgsbrowsermodel.cpp.

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

void QgsBrowserModel::endInsertItems ( )
slot

Definition at line 387 of file qgsbrowsermodel.cpp.

void QgsBrowserModel::endRemoveItems ( )
slot

Definition at line 400 of file qgsbrowsermodel.cpp.

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

Definition at line 496 of file qgsbrowsermodel.cpp.

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

Definition at line 360 of file qgsbrowsermodel.cpp.

QModelIndex QgsBrowserModel::findPath ( 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 289 of file qgsbrowsermodel.cpp.

QModelIndex QgsBrowserModel::findPath ( QAbstractItemModel *  model,
QString  path,
Qt::MatchFlag  matchFlag = Qt::MatchExactly 
)
static

Definition at line 294 of file qgsbrowsermodel.cpp.

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

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

Definition at line 274 of file qgsbrowsermodel.cpp.

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

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

void QgsBrowserModel::itemDataChanged ( QgsDataItem item)
slot

Definition at line 405 of file qgsbrowsermodel.cpp.

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

Definition at line 413 of file qgsbrowsermodel.cpp.

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

QStringList QgsBrowserModel::mimeTypes ( ) const
overridevirtual

Returns a list of mime that can describe model indexes.

Definition at line 440 of file qgsbrowsermodel.cpp.

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

void QgsBrowserModel::refresh ( QString  path)

Definition at line 510 of file qgsbrowsermodel.cpp.

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

Definition at line 517 of file qgsbrowsermodel.cpp.

void QgsBrowserModel::reload ( )
slot

Definition at line 334 of file qgsbrowsermodel.cpp.

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

Definition at line 534 of file qgsbrowsermodel.cpp.

void QgsBrowserModel::removeRootItems ( )
protected

Definition at line 184 of file qgsbrowsermodel.cpp.

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

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

Definition at line 256 of file qgsbrowsermodel.cpp.

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

Emitted when item children fetch was finished.

void QgsBrowserModel::updateProjectHome ( )
slot

Definition at line 62 of file qgsbrowsermodel.cpp.

Member Data Documentation

QgsFavouritesItem* QgsBrowserModel::mFavourites
protected

Definition at line 147 of file qgsbrowsermodel.h.

QgsDirectoryItem* QgsBrowserModel::mProjectHome
protected

Definition at line 148 of file qgsbrowsermodel.h.

QVector<QgsDataItem*> QgsBrowserModel::mRootItems
protected

Definition at line 146 of file qgsbrowsermodel.h.


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