]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/treeviewsidebarpage.cpp
don't overrun the array (CID 3278)
[dolphin.git] / src / treeviewsidebarpage.cpp
index b1fcc8daa87655d9a055d68dde1f9d09a8bd6fa8..63689b6ebff3b1bef6b16ecedad4b45cac49ac96 100644 (file)
@@ -78,8 +78,8 @@ TreeViewSidebarPage::TreeViewSidebarPage(DolphinMainWindow* mainWindow,
 
     connect(m_treeView, SIGNAL(clicked(const QModelIndex&)),
             this, SLOT(updateActiveView(const QModelIndex&)));
-    connect(m_treeView, SIGNAL(doubleClicked(const QModelIndex&)),
-            this, SLOT(slotDoubleClicked(const QModelIndex&)));
+    connect(m_treeView, SIGNAL(urlsDropped(const KUrl::List&, const QModelIndex&)),
+            this, SLOT(dropUrls(const KUrl::List&, const QModelIndex&)));
 
     QVBoxLayout* layout = new QVBoxLayout(this);
     layout->addWidget(m_treeView);
@@ -201,6 +201,23 @@ void TreeViewSidebarPage::updateActiveView(const QModelIndex& index)
     }
 }
 
+void TreeViewSidebarPage::dropUrls(const KUrl::List& urls,
+                                   const QModelIndex& index)
+{
+    if (index.isValid()) {
+#if defined(USE_PROXY_MODEL)
+        const QModelIndex& dirIndex = m_proxyModel->mapToSource(index);
+        KFileItem* item = m_dirModel->itemForIndex(dirIndex);
+#else
+        KFileItem* item = m_dirModel->itemForIndex(index);
+#endif
+        Q_ASSERT(item != 0);
+        if (item->isDir()) {
+            mainWindow()->dropUrls(urls, item->url());
+        }
+    }
+}
+
 void TreeViewSidebarPage::connectToActiveView()
 {
     const QWidget* parent = parentWidget();