]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fixed selection of directories with a trailing slash used with --select
authorChirag Anand <anand.chirag@gmail.com>
Sat, 24 Sep 2011 19:36:33 +0000 (01:06 +0530)
committerChirag Anand <anand.chirag@gmail.com>
Sat, 24 Sep 2011 19:36:33 +0000 (01:06 +0530)
parameter.

As QHash would not match a KUrl key with it's value if the key had a
trailing slash, so it would return -1, hence the file won't get
selected.
Changed the UpdateViewState slot to remove the trailing slash before
calling the index function for the selected URL. Also modified
DolphinView to use KUrl list instead of KFileItemList to maintain
simplicity.

src/views/dolphinview.cpp
src/views/dolphinview.h

index 71c67b1cf977b27809feb9d2b57123a27b32af21..fe45541e358cee77748b30f92af91cee43d33e19 100644 (file)
@@ -93,7 +93,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
     m_currentItemUrl(),
     m_restoredContentsPosition(),
     m_createdItemUrl(),
-    m_selectedItems(),
+    m_selectedUrls(),
     m_versionControlObserver(0)
 {
     m_topLayout = new QVBoxLayout(this);
@@ -307,10 +307,7 @@ int DolphinView::selectedItemsCount() const
 
 void DolphinView::markUrlsAsSelected(const QList<KUrl>& urls)
 {
-    foreach (const KUrl& url, urls) {
-        KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
-        m_selectedItems.append(item);
-    }
+    m_selectedUrls = urls;
 }
 
 void DolphinView::setItemSelectionEnabled(const QRegExp& pattern, bool enabled)
@@ -409,7 +406,10 @@ void DolphinView::reload()
     QByteArray viewState;
     QDataStream saveStream(&viewState, QIODevice::WriteOnly);
     saveState(saveStream);
-    m_selectedItems= selectedItems();
+
+    const KFileItemList itemList = selectedItems();
+    m_selectedUrls.clear();
+    m_selectedUrls = itemList.urlList();
 
     setUrl(url());
     loadDirectory(url(), true);
@@ -666,7 +666,9 @@ void DolphinView::setHiddenFilesShown(bool show)
         return;
     }
 
-    m_selectedItems = selectedItems();
+    const KFileItemList itemList = selectedItems();
+    m_selectedUrls.clear();
+    m_selectedUrls = itemList.urlList();
 
     ViewProperties props(url());
     props.setHiddenFilesShown(show);
@@ -1020,20 +1022,20 @@ void DolphinView::updateViewState()
         m_container->verticalScrollBar()->setValue(y);
     }
 
-    if (!m_selectedItems.isEmpty()) {
+    if (!m_selectedUrls.isEmpty()) {
         KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
         QSet<int> selectedItems = selectionManager->selectedItems();
         const KFileItemModel* model = fileItemModel();
 
-        foreach (const KFileItem& selectedItem, m_selectedItems) {
-            const int index = model->index(selectedItem);
+        foreach (const KUrl& url, m_selectedUrls) {
+            const int index = model->index(url);
             if (index >= 0) {
                 selectedItems.insert(index);
             }
         }
 
         selectionManager->setSelectedItems(selectedItems);
-        m_selectedItems.clear();
+        m_selectedUrls.clear();
     }
 }
 
index 74cec7dcc0a31e58c643946a4f33940dfa1dc67b..da74011a7215423d88d6784b761fd70d3ba0d99c 100644 (file)
@@ -766,7 +766,7 @@ private:
     KUrl m_currentItemUrl;
     QPoint m_restoredContentsPosition;
     KUrl m_createdItemUrl; // URL for a new item that got created by the "Create New..." menu
-    KFileItemList m_selectedItems; // this is used for making the View to remember selections after F5
+    QList<KUrl> m_selectedUrls; // this is used for making the View to remember selections after F5
     
     VersionControlObserver* m_versionControlObserver;