[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bzanshin=5D_src=3A_Fix_Column_count_in_TodoProxyMode?=
From:       Kevin Ottens <ervin () kde ! org>
Date:       2011-04-09 17:10:10
Message-ID: 20110409171010.B37E0A60D1 () git ! kde ! org
[Download RAW message or body]

Git commit 051d65ef8aa32e6d369f34480900b0f8ba87b171 by Kevin Ottens. on behalf of Mario Bensi
Committed on 05/04/2011 at 11:43.
Pushed by ervin into branch 'master'.

Fix Column count in TodoProxyModelBase

We forwarded the parent index directly to the sourceModel but we can
have leaves which became intermediate node in the TodoTreeModel and in
this case, this new node should return a column count different than 0.

Signed-off-by: Kevin Ottens <ervin@kde.org>

M  +10   -1    src/todoproxymodelbase.cpp     

http://commits.kde.org/zanshin/051d65ef8aa32e6d369f34480900b0f8ba87b171

diff --git a/src/todoproxymodelbase.cpp b/src/todoproxymodelbase.cpp
index 7ef723e..2bbef57 100644
--- a/src/todoproxymodelbase.cpp
+++ b/src/todoproxymodelbase.cpp
@@ -93,7 +93,16 @@ int TodoProxyModelBase::columnCount(const QModelIndex &parent) const
         return 1;
     }
 
-    return sourceModel()->columnCount(mapToSource(parent));
+    if (parent.isValid()) {
+        TodoNode *node = m_manager->nodeForIndex(parent);
+        if (node && node->children().size() > 0) {
+            return sourceModel()->columnCount();
+        } else {
+            return 0;
+        }
+    } else {
+        return sourceModel()->columnCount(mapToSource(parent));
+    }
 }
 
 QVariant TodoProxyModelBase::headerData(int section, Qt::Orientation orientation, int role) const


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic