Changeset View
Changeset View
Standalone View
Standalone View
ui/annotationproxymodels.cpp
Show First 20 Lines • Show All 208 Lines • ▼ Show 20 Line(s) | 203 | { | |||
---|---|---|---|---|---|
209 | } | 209 | } | ||
210 | 210 | | |||
211 | QAbstractProxyModel::setSourceModel( model ); | 211 | QAbstractProxyModel::setSourceModel( model ); | ||
212 | 212 | | |||
213 | connect( sourceModel(), &QAbstractItemModel::layoutChanged, this, &PageGroupProxyModel::rebuildIndexes ); | 213 | connect( sourceModel(), &QAbstractItemModel::layoutChanged, this, &PageGroupProxyModel::rebuildIndexes ); | ||
214 | connect( sourceModel(), &QAbstractItemModel::modelReset, this, &PageGroupProxyModel::rebuildIndexes ); | 214 | connect( sourceModel(), &QAbstractItemModel::modelReset, this, &PageGroupProxyModel::rebuildIndexes ); | ||
215 | connect( sourceModel(), &QAbstractItemModel::rowsInserted, this, &PageGroupProxyModel::rebuildIndexes ); | 215 | connect( sourceModel(), &QAbstractItemModel::rowsInserted, this, &PageGroupProxyModel::rebuildIndexes ); | ||
216 | connect( sourceModel(), &QAbstractItemModel::rowsRemoved, this, &PageGroupProxyModel::rebuildIndexes ); | 216 | connect( sourceModel(), &QAbstractItemModel::rowsRemoved, this, &PageGroupProxyModel::rebuildIndexes ); | ||
217 | connect( sourceModel(), &QAbstractItemModel::dataChanged, this, &PageGroupProxyModel::sourceDataChanged ); | ||||
217 | 218 | | |||
218 | rebuildIndexes(); | 219 | rebuildIndexes(); | ||
219 | } | 220 | } | ||
220 | 221 | | |||
221 | void PageGroupProxyModel::rebuildIndexes() | 222 | void PageGroupProxyModel::rebuildIndexes() | ||
222 | { | 223 | { | ||
223 | beginResetModel(); | 224 | beginResetModel(); | ||
224 | 225 | | |||
Show All 19 Lines | 244 | for ( int subRow = 0; subRow < sourceModel()->rowCount( pageIndex ); ++subRow ) { | |||
244 | mIndexes.append( sourceModel()->index( subRow, 0, pageIndex ) ); | 245 | mIndexes.append( sourceModel()->index( subRow, 0, pageIndex ) ); | ||
245 | } | 246 | } | ||
246 | } | 247 | } | ||
247 | } | 248 | } | ||
248 | 249 | | |||
249 | endResetModel(); | 250 | endResetModel(); | ||
250 | } | 251 | } | ||
251 | 252 | | |||
253 | void PageGroupProxyModel::sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) | ||||
254 | { | ||||
255 | emit dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight), roles); | ||||
256 | } | ||||
257 | | ||||
252 | void PageGroupProxyModel::groupByPage( bool value ) | 258 | void PageGroupProxyModel::groupByPage( bool value ) | ||
253 | { | 259 | { | ||
254 | if ( mGroupByPage == value ) | 260 | if ( mGroupByPage == value ) | ||
255 | return; | 261 | return; | ||
256 | 262 | | |||
257 | mGroupByPage = value; | 263 | mGroupByPage = value; | ||
258 | 264 | | |||
259 | rebuildIndexes(); | 265 | rebuildIndexes(); | ||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Line(s) | 438 | { | |||
438 | } | 444 | } | ||
439 | 445 | | |||
440 | QAbstractProxyModel::setSourceModel( model ); | 446 | QAbstractProxyModel::setSourceModel( model ); | ||
441 | 447 | | |||
442 | connect( sourceModel(), &QAbstractItemModel::layoutChanged, this, &AuthorGroupProxyModel::rebuildIndexes ); | 448 | connect( sourceModel(), &QAbstractItemModel::layoutChanged, this, &AuthorGroupProxyModel::rebuildIndexes ); | ||
443 | connect( sourceModel(), &QAbstractItemModel::modelReset, this, &AuthorGroupProxyModel::rebuildIndexes ); | 449 | connect( sourceModel(), &QAbstractItemModel::modelReset, this, &AuthorGroupProxyModel::rebuildIndexes ); | ||
444 | connect( sourceModel(), &QAbstractItemModel::rowsInserted, this, &AuthorGroupProxyModel::rebuildIndexes ); | 450 | connect( sourceModel(), &QAbstractItemModel::rowsInserted, this, &AuthorGroupProxyModel::rebuildIndexes ); | ||
445 | connect( sourceModel(), &QAbstractItemModel::rowsRemoved, this, &AuthorGroupProxyModel::rebuildIndexes ); | 451 | connect( sourceModel(), &QAbstractItemModel::rowsRemoved, this, &AuthorGroupProxyModel::rebuildIndexes ); | ||
452 | connect( sourceModel(), &QAbstractItemModel::dataChanged, this, &AuthorGroupProxyModel::sourceDataChanged ); | ||||
446 | 453 | | |||
447 | rebuildIndexes(); | 454 | rebuildIndexes(); | ||
448 | } | 455 | } | ||
449 | 456 | | |||
450 | static bool isAuthorItem( const QModelIndex &index ) | 457 | static bool isAuthorItem( const QModelIndex &index ) | ||
451 | { | 458 | { | ||
452 | if ( !index.isValid() ) { | 459 | if ( !index.isValid() ) { | ||
453 | return false; | 460 | return false; | ||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Line(s) | 593 | } else { | |||
596 | } | 603 | } | ||
597 | } | 604 | } | ||
598 | } | 605 | } | ||
599 | } | 606 | } | ||
600 | 607 | | |||
601 | endResetModel(); | 608 | endResetModel(); | ||
602 | } | 609 | } | ||
603 | 610 | | |||
611 | void AuthorGroupProxyModel::sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) | ||||
612 | { | ||||
613 | emit dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight), roles); | ||||
614 | } | ||||
615 | | ||||
604 | #include "moc_annotationproxymodels.cpp" | 616 | #include "moc_annotationproxymodels.cpp" |