#include <kdganttforwardingproxymodel.h>
Definition at line 33 of file kdganttforwardingproxymodel.h.
Public Member Functions | |
int | columnCount (const QModelIndex &idx=QModelIndex()) const |
ForwardingProxyModel (QObject *parent=0) | |
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const |
QModelIndex | mapFromSource (const QModelIndex &sourceIndex) const |
QModelIndex | mapToSource (const QModelIndex &proxyIndex) const |
QModelIndex | parent (const QModelIndex &idx) const |
int | rowCount (const QModelIndex &idx=QModelIndex()) const |
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) |
void | setSourceModel (QAbstractItemModel *model) |
virtual | ~ForwardingProxyModel () |
Protected Slots | |
virtual void | sourceColumnsAboutToBeInserted (const QModelIndex &idx, int start, int end) |
virtual void | sourceColumnsAboutToBeRemoved (const QModelIndex &idx, int start, int end) |
virtual void | sourceColumnsInserted (const QModelIndex &idx, int start, int end) |
virtual void | sourceColumnsRemoved (const QModelIndex &idx, int start, int end) |
virtual void | sourceDataChanged (const QModelIndex &from, const QModelIndex &to) |
virtual void | sourceLayoutAboutToBeChanged () |
virtual void | sourceLayoutChanged () |
virtual void | sourceModelAboutToBeReset () |
virtual void | sourceModelReset () |
virtual void | sourceRowsAboutToBeInserted (const QModelIndex &idx, int start, int end) |
virtual void | sourceRowsAboutToBeRemoved (const QModelIndex &, int start, int end) |
virtual void | sourceRowsInserted (const QModelIndex &idx, int start, int end) |
virtual void | sourceRowsRemoved (const QModelIndex &, int start, int end) |
ForwardingProxyModel::ForwardingProxyModel | ( | QObject * | parent = 0 |
) | [explicit] |
Constructor. Creates a new ForwardingProxyModel with parent parent
Definition at line 36 of file kdganttforwardingproxymodel.cpp.
00037 : BASE( parent ) 00038 { 00039 }
ForwardingProxyModel::~ForwardingProxyModel | ( | ) | [virtual] |
int ForwardingProxyModel::columnCount | ( | const QModelIndex & | idx = QModelIndex() |
) | const |
Reimplemented in KDGantt::ProxyModel.
Definition at line 255 of file kdganttforwardingproxymodel.cpp.
References mapToSource().
00256 { 00257 return sourceModel()->columnCount( mapToSource( idx ) ); 00258 }
QModelIndex ForwardingProxyModel::index | ( | int | row, | |
int | column, | |||
const QModelIndex & | parent = QModelIndex() | |||
) | const |
Definition at line 261 of file kdganttforwardingproxymodel.cpp.
References mapFromSource(), and mapToSource().
Referenced by KDGantt::ProxyModel::data(), and KDAB_SCOPED_UNITTEST_SIMPLE().
00262 { 00263 return mapFromSource( sourceModel()->index( row, column, mapToSource( parent ) ) ); 00264 }
QModelIndex ForwardingProxyModel::mapFromSource | ( | const QModelIndex & | sourceIndex | ) | const |
Converts indexes in the source model to indexes in the proxy model
Reimplemented in KDGantt::ProxyModel.
Definition at line 46 of file kdganttforwardingproxymodel.cpp.
Referenced by index(), parent(), KDGantt::SummaryHandlingProxyModel::setData(), sourceColumnsAboutToBeInserted(), sourceColumnsAboutToBeRemoved(), KDGantt::SummaryHandlingProxyModel::sourceDataChanged(), sourceDataChanged(), sourceRowsAboutToBeInserted(), and sourceRowsAboutToBeRemoved().
00047 { 00048 if ( !sourceIndex.isValid() ) 00049 return QModelIndex(); 00050 assert( sourceIndex.model() == sourceModel() ); 00051 00052 // Create an index that preserves the internal pointer from the source; 00053 // this way KDDataConverterProxyModel preserves the structure of the source model 00054 return createIndex( sourceIndex.row(), sourceIndex.column(), sourceIndex.internalPointer() ); 00055 }
QModelIndex ForwardingProxyModel::mapToSource | ( | const QModelIndex & | proxyIndex | ) | const |
Converts indexes in the proxy model to indexes in the source model
Reimplemented in KDGantt::ProxyModel.
Definition at line 67 of file kdganttforwardingproxymodel.cpp.
Referenced by columnCount(), KDGantt::SummaryHandlingProxyModel::data(), KDGantt::SummaryHandlingProxyModel::flags(), index(), parent(), rowCount(), KDGantt::SummaryHandlingProxyModel::setData(), and setData().
00068 { 00069 if ( !proxyIndex.isValid() ) 00070 return QModelIndex(); 00071 assert( proxyIndex.model() == this ); 00072 // So here we need to create a source index which holds that internal pointer. 00073 // No way to pass it to sourceModel()->index... so we have to do the ugly way: 00074 QModelIndex sourceIndex; 00075 KDPrivateModelIndex* hack = reinterpret_cast<KDPrivateModelIndex*>(&sourceIndex); 00076 hack->r = proxyIndex.row(); 00077 hack->c = proxyIndex.column(); 00078 hack->p = proxyIndex.internalPointer(); 00079 hack->m = sourceModel(); 00080 assert( sourceIndex.isValid() ); 00081 return sourceIndex; 00082 }
QModelIndex ForwardingProxyModel::parent | ( | const QModelIndex & | idx | ) | const |
Definition at line 267 of file kdganttforwardingproxymodel.cpp.
References mapFromSource(), and mapToSource().
00268 { 00269 return mapFromSource( sourceModel()->parent( mapToSource( idx ) ) ); 00270 }
int ForwardingProxyModel::rowCount | ( | const QModelIndex & | idx = QModelIndex() |
) | const |
Reimplemented in KDGantt::ProxyModel.
Definition at line 249 of file kdganttforwardingproxymodel.cpp.
References mapToSource().
00250 { 00251 return sourceModel()->rowCount( mapToSource( idx ) ); 00252 }
bool ForwardingProxyModel::setData | ( | const QModelIndex & | index, | |
const QVariant & | value, | |||
int | role = Qt::EditRole | |||
) |
Reimplemented in KDGantt::ProxyModel, and KDGantt::SummaryHandlingProxyModel.
Definition at line 273 of file kdganttforwardingproxymodel.cpp.
References mapToSource().
00274 { 00275 //qDebug() << "ForwardingProxyModel::setData( " << index<<value<< role<<")"; 00276 return sourceModel()->setData( mapToSource( index ), value, role ); 00277 }
void ForwardingProxyModel::setSourceModel | ( | QAbstractItemModel * | model | ) |
Sets the model to be used as the source model for this proxy. The proxy does not take ownership of the model.
Reimplemented in KDGantt::SummaryHandlingProxyModel.
Definition at line 88 of file kdganttforwardingproxymodel.cpp.
References sourceColumnsAboutToBeInserted(), sourceColumnsAboutToBeRemoved(), sourceColumnsInserted(), sourceColumnsRemoved(), sourceDataChanged(), sourceLayoutAboutToBeChanged(), sourceLayoutChanged(), sourceModelAboutToBeReset(), sourceModelReset(), sourceRowsAboutToBeInserted(), sourceRowsAboutToBeRemoved(), sourceRowsInserted(), and sourceRowsRemoved().
00089 { 00090 if ( sourceModel() ) sourceModel()->disconnect( this ); 00091 BASE::setSourceModel( model ); 00092 00093 if(!model) return; 00094 00095 connect( model, SIGNAL(modelAboutToBeReset()), this, SLOT(sourceModelAboutToBeReset()) ); 00096 connect( model, SIGNAL(modelReset()), this, SLOT(sourceModelReset()) ); 00097 connect( model, SIGNAL(layoutAboutToBeChanged()), this, SLOT(sourceLayoutAboutToBeChanged()) ); 00098 connect( model, SIGNAL(layoutChanged()), this, SLOT(sourceLayoutChanged()) ); 00099 00100 connect( model, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)), 00101 this, SLOT(sourceDataChanged(const QModelIndex&,const QModelIndex&)) ); 00102 00103 00104 connect( model, SIGNAL(columnsAboutToBeInserted(const QModelIndex&, int,int)), 00105 this, SLOT(sourceColumnsAboutToBeInserted(const QModelIndex&,int,int)) ); 00106 connect( model, SIGNAL(columnsInserted(const QModelIndex&, int,int)), 00107 this, SLOT(sourceColumnsInserted(const QModelIndex&,int,int)) ); 00108 connect( model, SIGNAL(columnsAboutToBeRemoved(const QModelIndex&, int,int)), 00109 this, SLOT(sourceColumnsAboutToBeRemoved(const QModelIndex&,int,int)) ); 00110 connect( model, SIGNAL(columnsRemoved(const QModelIndex&, int,int)), 00111 this, SLOT(sourceColumnsRemoved(const QModelIndex&,int,int)) ); 00112 00113 connect( model, SIGNAL(rowsAboutToBeInserted(const QModelIndex&, int,int)), 00114 this, SLOT(sourceRowsAboutToBeInserted(const QModelIndex&,int,int)) ); 00115 connect( model, SIGNAL(rowsInserted(const QModelIndex&, int,int)), 00116 this, SLOT(sourceRowsInserted(const QModelIndex&,int,int)) ); 00117 connect( model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&, int,int)), 00118 this, SLOT(sourceRowsAboutToBeRemoved(const QModelIndex&,int,int)) ); 00119 connect( model, SIGNAL(rowsRemoved(const QModelIndex&, int,int)), 00120 this, SLOT(sourceRowsRemoved(const QModelIndex&,int,int)) ); 00121 }
void ForwardingProxyModel::sourceColumnsAboutToBeInserted | ( | const QModelIndex & | parentIdx, | |
int | start, | |||
int | end | |||
) | [protected, virtual, slot] |
Called just before columns are inserted into the source model.
Reimplemented in KDGantt::SummaryHandlingProxyModel.
Definition at line 171 of file kdganttforwardingproxymodel.cpp.
References mapFromSource().
Referenced by setSourceModel().
00174 { 00175 beginInsertColumns( mapFromSource( parentIdx ), start, end ); 00176 }
void ForwardingProxyModel::sourceColumnsAboutToBeRemoved | ( | const QModelIndex & | parentIdx, | |
int | start, | |||
int | end | |||
) | [protected, virtual, slot] |
Called just before columns are removed from the source model.
Reimplemented in KDGantt::SummaryHandlingProxyModel.
Definition at line 192 of file kdganttforwardingproxymodel.cpp.
References mapFromSource().
Referenced by setSourceModel().
00195 { 00196 beginRemoveColumns( mapFromSource( parentIdx ), start, end ); 00197 }
void ForwardingProxyModel::sourceColumnsInserted | ( | const QModelIndex & | parentIdx, | |
int | start, | |||
int | end | |||
) | [protected, virtual, slot] |
Called after columns have been inserted into the source model.
Definition at line 181 of file kdganttforwardingproxymodel.cpp.
Referenced by setSourceModel().
00182 { 00183 Q_UNUSED( parentIdx ); 00184 Q_UNUSED( start ); 00185 Q_UNUSED( end ); 00186 endInsertColumns(); 00187 }
void ForwardingProxyModel::sourceColumnsRemoved | ( | const QModelIndex & | parentIdx, | |
int | start, | |||
int | end | |||
) | [protected, virtual, slot] |
Called after columns have been removed from the source model.
Definition at line 202 of file kdganttforwardingproxymodel.cpp.
Referenced by setSourceModel().
00203 { 00204 Q_UNUSED( parentIdx ); 00205 Q_UNUSED( start ); 00206 Q_UNUSED( end ); 00207 endRemoveColumns(); 00208 }
void ForwardingProxyModel::sourceDataChanged | ( | const QModelIndex & | from, | |
const QModelIndex & | to | |||
) | [protected, virtual, slot] |
Called when the data in an existing item in the source model changes.
Reimplemented in KDGantt::SummaryHandlingProxyModel.
Definition at line 162 of file kdganttforwardingproxymodel.cpp.
References mapFromSource().
Referenced by setSourceModel().
00163 { 00164 //qDebug() << "ForwardingProxyModel::sourceDataChanged("<<from<<to<<")"; 00165 emit dataChanged( mapFromSource( from ), mapFromSource( to ) ); 00166 }
void ForwardingProxyModel::sourceLayoutAboutToBeChanged | ( | ) | [protected, virtual, slot] |
Called just before the layout of the source model is changed.
Definition at line 144 of file kdganttforwardingproxymodel.cpp.
Referenced by setSourceModel().
00145 { 00146 //qDebug() << "ForwardingProxyModel::sourceLayoutAboutToBeChanged()"; 00147 emit layoutAboutToBeChanged(); 00148 }
void ForwardingProxyModel::sourceLayoutChanged | ( | ) | [protected, virtual, slot] |
Called when the layout of the source model has changed.
Reimplemented in KDGantt::SummaryHandlingProxyModel.
Definition at line 153 of file kdganttforwardingproxymodel.cpp.
Referenced by setSourceModel().
void ForwardingProxyModel::sourceModelAboutToBeReset | ( | ) | [protected, virtual, slot] |
Called when the source model is about to be reset.
Definition at line 126 of file kdganttforwardingproxymodel.cpp.
Referenced by setSourceModel().
void ForwardingProxyModel::sourceModelReset | ( | ) | [protected, virtual, slot] |
Called when the source model is reset
Reimplemented in KDGantt::SummaryHandlingProxyModel.
Definition at line 134 of file kdganttforwardingproxymodel.cpp.
Referenced by setSourceModel().
void ForwardingProxyModel::sourceRowsAboutToBeInserted | ( | const QModelIndex & | parentIdx, | |
int | start, | |||
int | end | |||
) | [protected, virtual, slot] |
Called just before rows are inserted into the source model.
Reimplemented in KDGantt::SummaryHandlingProxyModel.
Definition at line 213 of file kdganttforwardingproxymodel.cpp.
References mapFromSource().
Referenced by setSourceModel().
00214 { 00215 beginInsertRows( mapFromSource( parentIdx ), start, end ); 00216 }
void ForwardingProxyModel::sourceRowsAboutToBeRemoved | ( | const QModelIndex & | parentIdx, | |
int | start, | |||
int | end | |||
) | [protected, virtual, slot] |
Called just before rows are removed from the source model.
Reimplemented in KDGantt::SummaryHandlingProxyModel.
Definition at line 232 of file kdganttforwardingproxymodel.cpp.
References mapFromSource().
Referenced by setSourceModel().
00233 { 00234 beginRemoveRows( mapFromSource( parentIdx ), start, end ); 00235 }
void ForwardingProxyModel::sourceRowsInserted | ( | const QModelIndex & | parentIdx, | |
int | start, | |||
int | end | |||
) | [protected, virtual, slot] |
Called after rows have been inserted into the source model.
Definition at line 221 of file kdganttforwardingproxymodel.cpp.
Referenced by setSourceModel().
00222 { 00223 Q_UNUSED( parentIdx ); 00224 Q_UNUSED( start ); 00225 Q_UNUSED( end ); 00226 endInsertRows(); 00227 }
void ForwardingProxyModel::sourceRowsRemoved | ( | const QModelIndex & | parentIdx, | |
int | start, | |||
int | end | |||
) | [protected, virtual, slot] |
Called after rows have been removed from the source model.
Definition at line 240 of file kdganttforwardingproxymodel.cpp.
Referenced by setSourceModel().
00241 { 00242 Q_UNUSED( parentIdx ); 00243 Q_UNUSED( start ); 00244 Q_UNUSED( end ); 00245 endRemoveRows(); 00246 }