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

List:       kde-commits
Subject:    KDE/kdebase/apps/dolphin/src
From:       Peter Penz <peter.penz () gmx ! at>
Date:       2009-08-01 16:07:43
Message-ID: 1249142863.513902.13776.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1005646 by ppenz:

Assure that the revision control observer receives the correct revision states of \
subtree-items.

 M  +1 -1      dolphinfileitemdelegate.cpp  
 M  +25 -19    revisioncontrolobserver.cpp  
 M  +10 -4     revisioncontrolobserver.h  


--- trunk/KDE/kdebase/apps/dolphin/src/dolphinfileitemdelegate.cpp #1005645:1005646
@@ -63,7 +63,7 @@
         // The currently shown items are under revision control. Show the current \
revision  // state by adding an emblem.
         const QModelIndex dirIndex = proxyModel->mapToSource(index);
-        const QModelIndex revisionIndex = dolphinModel->index(dirIndex.row(), \
DolphinModel::Revision); +        const QModelIndex revisionIndex = \
                dolphinModel->index(dirIndex.row(), DolphinModel::Revision, \
                dirIndex.parent());
         const QVariant data = dolphinModel->data(revisionIndex, Qt::DecorationRole);
         const RevisionControlPlugin::RevisionState state = \
static_cast<RevisionControlPlugin::RevisionState>(data.toInt());  
--- trunk/KDE/kdebase/apps/dolphin/src/revisioncontrolobserver.cpp #1005645:1005646
@@ -73,10 +73,13 @@
 {
     Q_ASSERT(!m_itemStates.isEmpty());
     Q_ASSERT(m_plugin != 0);
-    
-    // it is assumed that all items have the same parent directory
-    const QString directory = \
m_itemStates.first().item.url().directory(KUrl::AppendTrailingSlash);  
+    // The items from m_itemStates may be located in different directory levels. The \
revision +    // plugin requires the root directory for \
RevisionControlPlugin::beginRetrieval(). Instead +    // of doing an expensive \
search, we utilize the knowledge of the implementation of +    // \
RevisionControlObserver::addDirectory() to be sure that the last item contains the \
root. +    const QString directory = \
m_itemStates.last().item.url().directory(KUrl::AppendTrailingSlash); +
     QMutexLocker locker(m_pluginMutex);
     m_retrievedItems = false;
     if (m_plugin->beginRetrieval(directory)) {
@@ -293,22 +296,9 @@
         return;
     }
     
-    const int rowCount = m_dolphinModel->rowCount();
-    if (rowCount > 0) {
-        // Build a list of all items in the current directory and delegate
-        // this list to the thread, which adjusts the revision states.
-        QList<ItemState> itemStates;
-        for (int row = 0; row < rowCount; ++row) {
-            const QModelIndex index = m_dolphinModel->index(row, \
                DolphinModel::Revision);
-            
-            ItemState itemState;
-            itemState.index = index;
-            itemState.item = m_dolphinModel->itemForIndex(index);
-            itemState.revision = RevisionControlPlugin::UnversionedRevision;
-
-            itemStates.append(itemState);
-        }
-        
+    QList<ItemState> itemStates;
+    addDirectory(QModelIndex(), itemStates);
+    if (!itemStates.isEmpty()) {
         if (!m_silentUpdate) {
             emit infoMessage(i18nc("@info:status", "Updating revision \
information..."));  }
@@ -317,4 +307,20 @@
     }
 }
 
+void RevisionControlObserver::addDirectory(const QModelIndex& parentIndex, \
QList<ItemState>& itemStates) +{
+    const int rowCount = m_dolphinModel->rowCount(parentIndex);
+    for (int row = 0; row < rowCount; ++row) {
+        const QModelIndex index = m_dolphinModel->index(row, DolphinModel::Revision, \
parentIndex); +        addDirectory(index, itemStates);
+        
+        ItemState itemState;
+        itemState.index = index;
+        itemState.item = m_dolphinModel->itemForIndex(index);
+        itemState.revision = RevisionControlPlugin::UnversionedRevision;
+
+        itemStates.append(itemState);
+    }
+}
+
 #include "revisioncontrolobserver.moc"
--- trunk/KDE/kdebase/apps/dolphin/src/revisioncontrolobserver.h #1005645:1005646
@@ -96,16 +96,22 @@
     void applyUpdatedItemStates();
     
 private:
-    void updateItemStates();
-
-private:
     struct ItemState
     {
         QPersistentModelIndex index;
         KFileItem item;
         RevisionControlPlugin::RevisionState revision;
     };
-    
+
+    void updateItemStates();
+
+    /**
+     * Adds recursively all items from the directory \p parentIndex into
+     * the list \p itemStates.
+     */
+    void addDirectory(const QModelIndex& parentIndex, QList<ItemState>& itemStates);
+
+private:
     bool m_pendingItemStatesUpdate;
     bool m_revisionedDirectory;
     bool m_silentUpdate; // if true, no messages will be send during the update


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

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