Sophie

Sophie

distrib > Mageia > 5 > i586 > by-pkgid > cf746698214707f972e669b661d0ae59 > files > 39

kdepim4-4.14.10-1.3.mga5.src.rpm

From 8cebb06702c98130cd4a1a2d812b5cd6f268d482 Mon Sep 17 00:00:00 2001
From: Sergio Martins <smartins@kde.org>
Date: Mon, 8 Feb 2016 12:42:16 +0000
Subject: [PATCH 39/74] kaddressbook: Fix checking new collections when they
 are created.

This wasn't working properly for collections with children.
When a new row+children is inserted we only get the row insertion
signal for the parent, not for the children, which must me iterated manually.
---
 kaddressbook/mainwidget.cpp | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/kaddressbook/mainwidget.cpp b/kaddressbook/mainwidget.cpp
index 320734ba4c..e186250cec 100644
--- a/kaddressbook/mainwidget.cpp
+++ b/kaddressbook/mainwidget.cpp
@@ -1006,12 +1006,20 @@ Akonadi::EntityTreeModel *MainWidget::entityTreeModel() const
 void MainWidget::slotCheckNewCalendar( const QModelIndex &parent, int begin, int end )
 {
     // HACK: Check newly created calendars
+
+    if ( begin < end ) {
+        return;
+    }
+
     Akonadi::EntityTreeModel *etm = entityTreeModel();
+    QAbstractItemModel *model = mCollectionView->model();
     if ( etm && etm->isCollectionTreeFetched() ) {
         for( int row=begin; row<=end; ++row ) {
-            QModelIndex index = mCollectionView->model()->index( row, 0, parent );
-            if ( index.isValid() )
-                mCollectionView->model()->setData( index, Qt::Checked, Qt::CheckStateRole );
+            QModelIndex index = model->index( row, 0, parent );
+            if ( index.isValid() ) {
+                model->setData( index, Qt::Checked, Qt::CheckStateRole );
+                slotCheckNewCalendar( index, 0, model->rowCount(index) - 1 );
+            }
         }
         if ( parent.isValid() ) {
             mCollectionView->setExpanded( parent, true );
-- 
2.14.1