Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QIdentityProxyModel Class Reference

The QIdentityProxyModel class proxies its source model unmodified More...

 #include <QIdentityProxyModel>

Inherits: QAbstractProxyModel.

This class was introduced in Qt 4.8.

Public Functions

QIdentityProxyModel ( QObject * parent = 0 )
~QIdentityProxyModel ()

Reimplemented Public Functions

virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const
virtual bool dropMimeData ( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent )
virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const
virtual bool insertColumns ( int column, int count, const QModelIndex & parent = QModelIndex() )
virtual bool insertRows ( int row, int count, const QModelIndex & parent = QModelIndex() )
virtual QModelIndex mapFromSource ( const QModelIndex & sourceIndex ) const
virtual QItemSelection mapSelectionFromSource ( const QItemSelection & selection ) const
virtual QItemSelection mapSelectionToSource ( const QItemSelection & selection ) const
virtual QModelIndex mapToSource ( const QModelIndex & proxyIndex ) const
virtual QModelIndexList match ( const QModelIndex & start, int role, const QVariant & value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const
virtual QModelIndex parent ( const QModelIndex & child ) const
virtual bool removeColumns ( int column, int count, const QModelIndex & parent = QModelIndex() )
virtual bool removeRows ( int row, int count, const QModelIndex & parent = QModelIndex() )
virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const
virtual void setSourceModel ( QAbstractItemModel * sourceModel )

Additional Inherited Members

Detailed Description

The QIdentityProxyModel class proxies its source model unmodified

QIdentityProxyModel can be used to forward the structure of a source model exactly, with no sorting, filtering or other transformation. This is similar in concept to an identity matrix where A.I = A.

Because it does no sorting or filtering, this class is most suitable to proxy models which transform the data() of the source model. For example, a proxy model could be created to define the font used, or the background colour, or the tooltip etc. This removes the need to implement all data handling in the same class that creates the structure of the model, and can also be used to create re-usable components.

This also provides a way to change the data in the case where a source model is supplied by a third party which can not be modified.

 class DateFormatProxyModel : public QIdentityProxyModel
 {
   // ...

   void setDateFormatString(const QString &formatString)
   {
     m_formatString = formatString;
   }

   QVariant data(const QModelIndex &index, int role)
   {
     if (role != Qt::DisplayRole)
       return QIdentityProxyModel::data(index, role);

     const QDateTime dateTime = sourceModel()->data(SourceClass::DateRole).toDateTime();

     return dateTime.toString(m_formatString);
   }

 private:
   QString m_formatString;
 };

See also QAbstractProxyModel, Model/View Programming, and QAbstractItemModel.

Member Function Documentation

QIdentityProxyModel::QIdentityProxyModel ( QObject * parent = 0 )

Constructs an identity model with the given parent.

QIdentityProxyModel::~QIdentityProxyModel ()

Destroys this identity model.

int QIdentityProxyModel::columnCount ( const QModelIndex & parent = QModelIndex() ) const [virtual]

Reimplemented from QAbstractItemModel::columnCount().

bool QIdentityProxyModel::dropMimeData ( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent ) [virtual]

Reimplemented from QAbstractItemModel::dropMimeData().

QModelIndex QIdentityProxyModel::index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const [virtual]

Reimplemented from QAbstractItemModel::index().

bool QIdentityProxyModel::insertColumns ( int column, int count, const QModelIndex & parent = QModelIndex() ) [virtual]

Reimplemented from QAbstractItemModel::insertColumns().

bool QIdentityProxyModel::insertRows ( int row, int count, const QModelIndex & parent = QModelIndex() ) [virtual]

Reimplemented from QAbstractItemModel::insertRows().

QModelIndex QIdentityProxyModel::mapFromSource ( const QModelIndex & sourceIndex ) const [virtual]

Reimplemented from QAbstractProxyModel::mapFromSource().

QItemSelection QIdentityProxyModel::mapSelectionFromSource ( const QItemSelection & selection ) const [virtual]

Reimplemented from QAbstractProxyModel::mapSelectionFromSource().

QItemSelection QIdentityProxyModel::mapSelectionToSource ( const QItemSelection & selection ) const [virtual]

Reimplemented from QAbstractProxyModel::mapSelectionToSource().

QModelIndex QIdentityProxyModel::mapToSource ( const QModelIndex & proxyIndex ) const [virtual]

Reimplemented from QAbstractProxyModel::mapToSource().

QModelIndexList QIdentityProxyModel::match ( const QModelIndex & start, int role, const QVariant & value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const [virtual]

Reimplemented from QAbstractItemModel::match().

QModelIndex QIdentityProxyModel::parent ( const QModelIndex & child ) const [virtual]

Reimplemented from QAbstractItemModel::parent().

bool QIdentityProxyModel::removeColumns ( int column, int count, const QModelIndex & parent = QModelIndex() ) [virtual]

Reimplemented from QAbstractItemModel::removeColumns().

bool QIdentityProxyModel::removeRows ( int row, int count, const QModelIndex & parent = QModelIndex() ) [virtual]

Reimplemented from QAbstractItemModel::removeRows().

int QIdentityProxyModel::rowCount ( const QModelIndex & parent = QModelIndex() ) const [virtual]

Reimplemented from QAbstractItemModel::rowCount().

void QIdentityProxyModel::setSourceModel ( QAbstractItemModel * sourceModel ) [virtual]

Reimplemented from QAbstractProxyModel::setSourceModel().

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.8
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web