Commit 8fec0cca authored by Sergio Martins's avatar Sergio Martins
Browse files

Don't create the custom collection selections if it's disabled.

Check mCustomColumnSetupUsed before executing code regarding
this feature.

CCBUG: 326095
parent 55a04ab9
......@@ -663,40 +663,46 @@ void MultiAgendaView::doRestoreConfig( const KConfigGroup &configGroup )
d->mCustomColumnTitles[i] = generateColumnLabel( i );
}
}
QVector<KCheckableProxyModel*> oldModels = d->mCollectionSelectionModels;
d->mCollectionSelectionModels.clear();
d->mCollectionSelectionModels.resize( d->mCustomNumberOfColumns );
for ( int i = 0; i < d->mCustomNumberOfColumns; ++i ) {
// Sort the calanders by name
QSortFilterProxyModel *sortProxy = new QSortFilterProxyModel( this );
sortProxy->setDynamicSortFilter( true );
if ( calendar() ) {
sortProxy->setSourceModel( calendar()->entityTreeModel() );
}
// Only show the first column
KColumnFilterProxyModel *columnFilterProxy = new KColumnFilterProxyModel( this );
columnFilterProxy->setVisibleColumn( Akonadi::ETMCalendar::CollectionTitle );
columnFilterProxy->setSourceModel( sortProxy );
// Keep track of selection.
QItemSelectionModel *qsm = new QItemSelectionModel( columnFilterProxy );
if ( d->mCustomColumnSetupUsed ) {
d->mCollectionSelectionModels.resize( d->mCustomNumberOfColumns );
for ( int i = 0; i < d->mCustomNumberOfColumns; ++i ) {
// Sort the calanders by name
QSortFilterProxyModel *sortProxy = new QSortFilterProxyModel( this );
sortProxy->setDynamicSortFilter( true );
if ( calendar() ) {
sortProxy->setSourceModel( calendar()->entityTreeModel() );
}
// Make the model checkable.
KCheckableProxyModel *checkableProxy = new KCheckableProxyModel( this );
checkableProxy->setSourceModel( columnFilterProxy );
checkableProxy->setSelectionModel( qsm );
const QString groupName = configGroup.name() + "_subView_" + QByteArray::number( i );
const KConfigGroup group = configGroup.config()->group( groupName );
// Only show the first column
KColumnFilterProxyModel *columnFilterProxy = new KColumnFilterProxyModel( this );
columnFilterProxy->setVisibleColumn( Akonadi::ETMCalendar::CollectionTitle );
columnFilterProxy->setSourceModel( sortProxy );
if ( !d->mSelectionSavers.contains( groupName ) ) {
d->mSelectionSavers.insert( groupName, new KViewStateMaintainer<ETMViewStateSaver>( group ) );
d->mSelectionSavers[groupName]->setSelectionModel( checkableProxy->selectionModel() );
}
// Keep track of selection.
QItemSelectionModel *qsm = new QItemSelectionModel( columnFilterProxy );
d->mSelectionSavers[groupName]->restoreState();
d->mCollectionSelectionModels[i] = checkableProxy;
// Make the model checkable.
KCheckableProxyModel *checkableProxy = new KCheckableProxyModel( this );
checkableProxy->setSourceModel( columnFilterProxy );
checkableProxy->setSelectionModel( qsm );
const QString groupName = configGroup.name() + "_subView_" + QByteArray::number( i );
const KConfigGroup group = configGroup.config()->group( groupName );
if ( !d->mSelectionSavers.contains( groupName ) ) {
d->mSelectionSavers.insert( groupName, new KViewStateMaintainer<ETMViewStateSaver>( group ) );
d->mSelectionSavers[groupName]->setSelectionModel( checkableProxy->selectionModel() );
}
d->mSelectionSavers[groupName]->restoreState();
d->mCollectionSelectionModels[i] = checkableProxy;
}
}
d->mPendingChanges = true;
recreateViews();
qDeleteAll( oldModels );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment