#include <kdganttproxymodel.h>
Definition at line 31 of file kdganttproxymodel.h.
Public Member Functions | |
int | column (int ganttrole) const |
int | columnCount (const QModelIndex &idx) const |
QVariant | data (const QModelIndex &idx, int role=Qt::DisplayRole) const |
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const |
QModelIndex | mapFromSource (const QModelIndex &idx) const |
QModelIndex | mapToSource (const QModelIndex &proxyIdx) const |
QModelIndex | parent (const QModelIndex &idx) const |
ProxyModel (QObject *parent=0) | |
int | role (int ganttrole) const |
int | rowCount (const QModelIndex &idx) const |
void | setColumn (int ganttrole, int col) |
bool | setData (const QModelIndex &idx, const QVariant &value, int role=Qt::EditRole) |
void | setRole (int ganttrole, int role) |
void | setSourceModel (QAbstractItemModel *model) |
virtual | ~ProxyModel () |
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) |
ProxyModel::ProxyModel | ( | QObject * | parent = 0 |
) | [explicit] |
ProxyModel::~ProxyModel | ( | ) | [virtual] |
int ProxyModel::column | ( | int | ganttrole | ) | const |
Definition at line 114 of file kdganttproxymodel.cpp.
References d.
00115 { 00116 return d->columnMap[ganttrole]; 00117 }
int ProxyModel::columnCount | ( | const QModelIndex & | idx | ) | const |
Reimplemented from KDGantt::ForwardingProxyModel.
Definition at line 150 of file kdganttproxymodel.cpp.
References mapToSource().
00151 { 00152 return qMin( sourceModel()->columnCount( mapToSource( proxyIndex ) ), 1 ); 00153 }
QVariant ProxyModel::data | ( | const QModelIndex & | idx, | |
int | role = Qt::DisplayRole | |||
) | const |
Definition at line 155 of file kdganttproxymodel.cpp.
References d, KDGantt::ForwardingProxyModel::index(), and mapToSource().
00156 { 00157 int srole = role; 00158 int scol = proxyIdx.column(); 00159 QHash<int, int>::const_iterator it = d->roleMap.find( role ); 00160 if ( it != d->roleMap.end() ) srole = *it; 00161 it = d->columnMap.find( role ); 00162 if ( it != d->columnMap.end() ) scol = *it; 00163 00164 #if 0 00165 qDebug() << "mapping role"<<static_cast<ItemDataRole>(role)<<"to"<<static_cast<ItemDataRole>(srole); 00166 qDebug() << "mapping column"<<proxyIdx.column()<<"to"<<scol 00167 << "value="<<sourceModel()->data( sourceModel()->index( proxyIdx.row(), scol, mapToSource( proxyIdx.parent() ) ), srole ); 00168 #endif 00169 00170 const QAbstractItemModel* model = sourceModel(); 00171 return model->data( model->index( proxyIdx.row(), scol, mapToSource( proxyIdx.parent() ) ), srole ); 00172 }
QModelIndex ForwardingProxyModel::index | ( | int | row, | |
int | column, | |||
const QModelIndex & | parent = QModelIndex() | |||
) | const [inherited] |
Definition at line 261 of file kdganttforwardingproxymodel.cpp.
References KDGantt::ForwardingProxyModel::mapFromSource(), and KDGantt::ForwardingProxyModel::mapToSource().
Referenced by data(), and KDAB_SCOPED_UNITTEST_SIMPLE().
00262 { 00263 return mapFromSource( sourceModel()->index( row, column, mapToSource( parent ) ) ); 00264 }
QModelIndex ProxyModel::mapFromSource | ( | const QModelIndex & | sourceIndex | ) | const |
Converts indexes in the source model to indexes in the proxy model
Reimplemented from KDGantt::ForwardingProxyModel.
Definition at line 72 of file kdganttproxymodel.cpp.
00073 { 00074 #if 0 00075 if( sourceIdx.isValid() ) { 00076 if ( calendarMode() ) { 00077 const QAbstractItemModel* model = sourceIdx.model(); 00078 if ( model->hasChildren( sourceIdx ) ) { 00079 return BASE::mapFromSource( model->index( sourceIdx.row(),0,sourceIdx.parent())); 00080 } else { 00081 // Map children to columns 00082 return BASE::mapFromSource( model->index( sourceIdx.row(),0,sourceIdx.parent())) 00083 .child( 0, sourceIdx.column() ); 00084 } 00085 } 00086 return BASE::mapFromSource( sourceIdx.model()->index( sourceIdx.row(),0,sourceIdx.parent())); 00087 } 00088 else return QModelIndex(); 00089 #else 00090 return BASE::mapFromSource( sourceIdx.model()?sourceIdx.model()->index( sourceIdx.row(),0,sourceIdx.parent()):QModelIndex()); 00091 #endif 00092 }
QModelIndex ProxyModel::mapToSource | ( | const QModelIndex & | proxyIndex | ) | const |
Converts indexes in the proxy model to indexes in the source model
Reimplemented from KDGantt::ForwardingProxyModel.
Definition at line 94 of file kdganttproxymodel.cpp.
Referenced by columnCount(), data(), and setData().
00095 { 00096 #if 0 00097 if( proxyIdx.isValid() ) { 00098 if ( calendarMode() && proxyIdx.column() > 0 ) { 00099 return BASE::mapToSource( proxyIdx.model()->index( proxyIdx.column(), 0, proxyIdx ) ); 00100 } 00101 return BASE::mapToSource( proxyIdx ); 00102 } 00103 else return QModelIndex(); 00104 #else 00105 return BASE::mapToSource( proxyIdx ); 00106 #endif 00107 }
QModelIndex ForwardingProxyModel::parent | ( | const QModelIndex & | idx | ) | const [inherited] |
Definition at line 267 of file kdganttforwardingproxymodel.cpp.
References KDGantt::ForwardingProxyModel::mapFromSource(), and KDGantt::ForwardingProxyModel::mapToSource().
00268 { 00269 return mapFromSource( sourceModel()->parent( mapToSource( idx ) ) ); 00270 }
int ProxyModel::role | ( | int | ganttrole | ) | const |
Definition at line 124 of file kdganttproxymodel.cpp.
References d.
00125 { 00126 return d->roleMap[ganttrole]; 00127 }
int ProxyModel::rowCount | ( | const QModelIndex & | idx | ) | const |
Reimplemented from KDGantt::ForwardingProxyModel.
Definition at line 144 of file kdganttproxymodel.cpp.
void ProxyModel::setColumn | ( | int | ganttrole, | |
int | col | |||
) |
Definition at line 109 of file kdganttproxymodel.cpp.
References d.
00110 { 00111 d->columnMap[ganttrole] = col; 00112 }
bool ProxyModel::setData | ( | const QModelIndex & | index, | |
const QVariant & | value, | |||
int | role = Qt::EditRole | |||
) |
Reimplemented from KDGantt::ForwardingProxyModel.
Definition at line 174 of file kdganttproxymodel.cpp.
References d, and mapToSource().
00175 { 00176 int srole = role; 00177 int scol = proxyIdx.column(); 00178 QHash<int, int>::const_iterator it = d->roleMap.find( role ); 00179 if ( it != d->roleMap.end() ) srole = *it; 00180 it = d->columnMap.find( role ); 00181 if ( it != d->columnMap.end() ) scol = *it; 00182 00183 QAbstractItemModel* model = sourceModel(); 00184 return model->setData( model->index( proxyIdx.row(), scol, mapToSource( proxyIdx.parent() ) ), value, srole ); 00185 }
void ProxyModel::setRole | ( | int | ganttrole, | |
int | role | |||
) |
void ForwardingProxyModel::setSourceModel | ( | QAbstractItemModel * | model | ) | [inherited] |
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 KDGantt::ForwardingProxyModel::sourceColumnsAboutToBeInserted(), KDGantt::ForwardingProxyModel::sourceColumnsAboutToBeRemoved(), KDGantt::ForwardingProxyModel::sourceColumnsInserted(), KDGantt::ForwardingProxyModel::sourceColumnsRemoved(), KDGantt::ForwardingProxyModel::sourceDataChanged(), KDGantt::ForwardingProxyModel::sourceLayoutAboutToBeChanged(), KDGantt::ForwardingProxyModel::sourceLayoutChanged(), KDGantt::ForwardingProxyModel::sourceModelAboutToBeReset(), KDGantt::ForwardingProxyModel::sourceModelReset(), KDGantt::ForwardingProxyModel::sourceRowsAboutToBeInserted(), KDGantt::ForwardingProxyModel::sourceRowsAboutToBeRemoved(), KDGantt::ForwardingProxyModel::sourceRowsInserted(), and KDGantt::ForwardingProxyModel::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, inherited] |
Called just before columns are inserted into the source model.
Reimplemented in KDGantt::SummaryHandlingProxyModel.
Definition at line 171 of file kdganttforwardingproxymodel.cpp.
References KDGantt::ForwardingProxyModel::mapFromSource().
Referenced by KDGantt::ForwardingProxyModel::setSourceModel().
00174 { 00175 beginInsertColumns( mapFromSource( parentIdx ), start, end ); 00176 }
void ForwardingProxyModel::sourceColumnsAboutToBeRemoved | ( | const QModelIndex & | parentIdx, | |
int | start, | |||
int | end | |||
) | [protected, virtual, slot, inherited] |
Called just before columns are removed from the source model.
Reimplemented in KDGantt::SummaryHandlingProxyModel.
Definition at line 192 of file kdganttforwardingproxymodel.cpp.
References KDGantt::ForwardingProxyModel::mapFromSource().
Referenced by KDGantt::ForwardingProxyModel::setSourceModel().
00195 { 00196 beginRemoveColumns( mapFromSource( parentIdx ), start, end ); 00197 }
void ForwardingProxyModel::sourceColumnsInserted | ( | const QModelIndex & | parentIdx, | |
int | start, | |||
int | end | |||
) | [protected, virtual, slot, inherited] |
Called after columns have been inserted into the source model.
Definition at line 181 of file kdganttforwardingproxymodel.cpp.
Referenced by KDGantt::ForwardingProxyModel::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, inherited] |
Called after columns have been removed from the source model.
Definition at line 202 of file kdganttforwardingproxymodel.cpp.
Referenced by KDGantt::ForwardingProxyModel::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, inherited] |
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 KDGantt::ForwardingProxyModel::mapFromSource().
Referenced by KDGantt::ForwardingProxyModel::setSourceModel().
00163 { 00164 //qDebug() << "ForwardingProxyModel::sourceDataChanged("<<from<<to<<")"; 00165 emit dataChanged( mapFromSource( from ), mapFromSource( to ) ); 00166 }
void ForwardingProxyModel::sourceLayoutAboutToBeChanged | ( | ) | [protected, virtual, slot, inherited] |
Called just before the layout of the source model is changed.
Definition at line 144 of file kdganttforwardingproxymodel.cpp.
Referenced by KDGantt::ForwardingProxyModel::setSourceModel().
00145 { 00146 //qDebug() << "ForwardingProxyModel::sourceLayoutAboutToBeChanged()"; 00147 emit layoutAboutToBeChanged(); 00148 }
void ForwardingProxyModel::sourceLayoutChanged | ( | ) | [protected, virtual, slot, inherited] |
Called when the layout of the source model has changed.
Reimplemented in KDGantt::SummaryHandlingProxyModel.
Definition at line 153 of file kdganttforwardingproxymodel.cpp.
Referenced by KDGantt::ForwardingProxyModel::setSourceModel().
void ForwardingProxyModel::sourceModelAboutToBeReset | ( | ) | [protected, virtual, slot, inherited] |
Called when the source model is about to be reset.
Definition at line 126 of file kdganttforwardingproxymodel.cpp.
Referenced by KDGantt::ForwardingProxyModel::setSourceModel().
void ForwardingProxyModel::sourceModelReset | ( | ) | [protected, virtual, slot, inherited] |
Called when the source model is reset
Reimplemented in KDGantt::SummaryHandlingProxyModel.
Definition at line 134 of file kdganttforwardingproxymodel.cpp.
Referenced by KDGantt::ForwardingProxyModel::setSourceModel().
void ForwardingProxyModel::sourceRowsAboutToBeInserted | ( | const QModelIndex & | parentIdx, | |
int | start, | |||
int | end | |||
) | [protected, virtual, slot, inherited] |
Called just before rows are inserted into the source model.
Reimplemented in KDGantt::SummaryHandlingProxyModel.
Definition at line 213 of file kdganttforwardingproxymodel.cpp.
References KDGantt::ForwardingProxyModel::mapFromSource().
Referenced by KDGantt::ForwardingProxyModel::setSourceModel().
00214 { 00215 beginInsertRows( mapFromSource( parentIdx ), start, end ); 00216 }
void ForwardingProxyModel::sourceRowsAboutToBeRemoved | ( | const QModelIndex & | parentIdx, | |
int | start, | |||
int | end | |||
) | [protected, virtual, slot, inherited] |
Called just before rows are removed from the source model.
Reimplemented in KDGantt::SummaryHandlingProxyModel.
Definition at line 232 of file kdganttforwardingproxymodel.cpp.
References KDGantt::ForwardingProxyModel::mapFromSource().
Referenced by KDGantt::ForwardingProxyModel::setSourceModel().
00233 { 00234 beginRemoveRows( mapFromSource( parentIdx ), start, end ); 00235 }
void ForwardingProxyModel::sourceRowsInserted | ( | const QModelIndex & | parentIdx, | |
int | start, | |||
int | end | |||
) | [protected, virtual, slot, inherited] |
Called after rows have been inserted into the source model.
Definition at line 221 of file kdganttforwardingproxymodel.cpp.
Referenced by KDGantt::ForwardingProxyModel::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, inherited] |
Called after rows have been removed from the source model.
Definition at line 240 of file kdganttforwardingproxymodel.cpp.
Referenced by KDGantt::ForwardingProxyModel::setSourceModel().
00241 { 00242 Q_UNUSED( parentIdx ); 00243 Q_UNUSED( start ); 00244 Q_UNUSED( end ); 00245 endRemoveRows(); 00246 }