#include "treeviewsidebarpage.h"
#include "bookmarkselector.h"
+#include "dolphincontextmenu.h"
#include "dolphinmainwindow.h"
#include "dolphinsortfilterproxymodel.h"
#include "dolphinview.h"
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->setMargin(0);
layout->addWidget(m_treeView);
}
connectToActiveView();
}
+void TreeViewSidebarPage::contextMenuEvent(QContextMenuEvent* event)
+{
+ SidebarPage::contextMenuEvent(event);
+
+ const QModelIndex index = m_treeView->indexAt(event->pos());
+ if (!index.isValid()) {
+ // only open a context menu above a directory item
+ return;
+ }
+
+#if defined(USE_PROXY_MODEL)
+ const QModelIndex dirModelIndex = m_proxyModel->mapToSource(index);
+ KFileItem* item = m_dirModel->itemForIndex(dirModelIndex);
+#else
+ KFileItem* item = m_dirModel->itemForIndex(index);
+#endif
+
+ DolphinContextMenu contextMenu(mainWindow(),
+ item,
+ m_dirLister->url(),
+ DolphinContextMenu::SidebarView);
+ contextMenu.open();
+}
+
void TreeViewSidebarPage::updateSelection(const KUrl& url)
{
if (!url.isValid() || (url == m_selectedUrl)) {
}
}
+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();