/***************************************************************************
- * Copyright (C) 2006 by Peter Penz *
- * peter.penz@gmx.at *
+ * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
}
else {
event->acceptProposedAction();
- //m_controller->indicateDroppedUrls(urls, event->pos());
+ emit urlsDropped(urls, event->pos());
}
}
/***************************************************************************
- * Copyright (C) 2006 by Peter Penz *
- * peter.penz@gmx.at *
+ * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
#ifndef SIDEBARTREEVIEW_H
#define SIDEBARTREEVIEW_H
+#include <kurl.h>
#include <QTreeView>
class DolphinMainWindow;
/**
- * @brief
+ * @brief Tree view widget which is used for the sidebar panel.
+ *
+ * @see TreeViewSidebarPage
*/
class SidebarTreeView : public QTreeView
{
explicit SidebarTreeView(DolphinMainWindow* mainWindow, QWidget* parent = 0);
virtual ~SidebarTreeView();
+signals:
+ /**
+ * Is emitted if the URLs \a urls have been dropped.
+ * @param pos Position relative to the tree view where the
+ * dropping has been done. It is recommended
+ * to get the corresponding model index from
+ * this position to find out the destination.
+ */
+ void urlsDropped(const KUrl::List& urls,
+ const QPoint& pos);
+
protected:
virtual bool event(QEvent* event);
virtual void dragEnterEvent(QDragEnterEvent* event);
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 QPoint&)),
+ this, SLOT(dropUrls(const KUrl::List&, const QPoint&)));
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_treeView);
}
}
+void TreeViewSidebarPage::dropUrls(const KUrl::List& urls,
+ const QPoint& pos)
+{
+ const QModelIndex index = m_treeView->indexAt(pos);
+ 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();
/***************************************************************************
- * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>
+ * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
class KDirLister;
class KDirModel;
-class KUrl;
class DolphinSortFilterProxyModel;
class SidebarTreeView;
*/
void updateActiveView(const QModelIndex& index);
+ /**
+ * Is emitted if the URLs \a urls have been dropped
+ * to the position \a pos. */
+ void dropUrls(const KUrl::List& urls,
+ const QPoint& pos);
+
private:
/**
* Connects to signals from the currently active Dolphin view to get
KUrl m_selectedUrl;
};
-#endif // BOOKMARKSSIDEBARPAGE_H
+#endif // TREEVIEWSIDEBARPAGE_H