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

List:       kde-commits
Subject:    KDE/kdepimlibs/akonadi
From:       Stephen Kelly <steveire () gmail ! com>
Date:       2010-12-23 13:03:44
Message-ID: 20101223130344.745B03E1F6 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1208846 by skelly:

Don't add an item to the virtual collection if it is already there.

 M  +11 -2     entitytreemodel_p.cpp  


--- trunk/KDE/kdepimlibs/akonadi/entitytreemodel_p.cpp #1208845:1208846
@@ -1009,8 +1009,17 @@
   if ( !m_mimeChecker.wantedMimeTypes().isEmpty() && !m_mimeChecker.isWantedItem( \
item ) )  return;
 
-  const int row = m_childEntities.value( collectionId ).size();
+  QList<Node*> &collectionEntities =  m_childEntities[ collectionId ];
 
+  int existingPosition = indexOf<Node::Item>( collectionEntities, itemId );
+
+  if ( existingPosition > 0 ) {
+    qWarning() << "Item with id " << itemId << " already in virtual collection with \
id " << collectionId; +    return;
+  }
+
+  const int row = collectionEntities.size();
+
   const QModelIndex parentIndex = indexForCollection( m_collections.value( \
collectionId ) );  
   q->beginInsertRows( parentIndex, row, row );
@@ -1021,7 +1030,7 @@
   node->id = itemId;
   node->parent = collectionId;
   node->type = Node::Item;
-  m_childEntities[ collectionId ].append( node );
+  collectionEntities.append( node );
   q->endInsertRows();
 }
 


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

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