From d4e25e6cc6d78a7b858f4a282ee8cef6957fec71 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Thu, 2 Mar 2006 12:26:51 +0000 Subject: [PATCH] don't mark the thread todo if the thread is collapsed and you want to mark the top message todo svn path=/branches/KDE/3.5/kdepim/; revision=515022 --- kmheaders.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/kmheaders.cpp b/kmheaders.cpp index 9d70e98ba..5fd0419cb 100644 --- a/kmheaders.cpp +++ b/kmheaders.cpp @@ -1148,13 +1148,28 @@ void KMHeaders::msgHeaderChanged(KMFolder*, int msgId) //----------------------------------------------------------------------------- void KMHeaders::setMsgStatus (KMMsgStatus status, bool toggle) { + kdDebug() << k_funcinfo << endl; SerNumList serNums; - for (QListViewItemIterator it(this); it.current(); ++it) + QListViewItemIterator it(this, QListViewItemIterator::Selected|QListViewItemIterator::Visible); + while( it.current() ) { if ( it.current()->isSelected() && it.current()->isVisible() ) { + if ( it.current()->parent() && ( !it.current()->parent()->isOpen() ) ) { + // the item's parent is closed, don't traverse any more of this subtree + QListViewItem * lastAncestorWithSiblings = it.current()->parent(); + // travel towards the root until we find an ancestor with siblings + while ( ( lastAncestorWithSiblings->depth() > 0 ) && !lastAncestorWithSiblings->nextSibling() ) + lastAncestorWithSiblings = lastAncestorWithSiblings->parent(); + // move the iterator to that ancestor's next sibling + it = QListViewItemIterator( lastAncestorWithSiblings->nextSibling() ); + continue; + } + HeaderItem *item = static_cast(it.current()); KMMsgBase *msgBase = mFolder->getMsgBase(item->msgId()); serNums.append( msgBase->getMsgSerNum() ); } + ++it; + } if (serNums.empty()) return;