┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphiniconsview.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2007-01-06 21:11:04 +0000
committerPeter Penz <[email protected]>2007-01-06 21:11:04 +0000
commit8fb8b7d7112eb3984d78d150382fce029d9ceeeb (patch)
tree746674c3c09970789ecec9bbe33fce275ef8b73e /src/dolphiniconsview.cpp
parent86ad5d0a630654f81f4649f997dd6451f371f5f6 (diff)
Reanimated drag & drop support for the icons view.
svn path=/trunk/playground/utils/dolphin/; revision=620649
Diffstat (limited to 'src/dolphiniconsview.cpp')
-rw-r--r--src/dolphiniconsview.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp
index eb3dde47f..11fbf69a0 100644
--- a/src/dolphiniconsview.cpp
+++ b/src/dolphiniconsview.cpp
@@ -19,14 +19,17 @@
***************************************************************************/
#include "dolphiniconsview.h"
+#include "dolphinmainwindow.h"
#include "dolphinview.h"
#include <kdirmodel.h>
#include <kfileitem.h>
+#include <QAbstractProxyModel>
+
DolphinIconsView::DolphinIconsView(DolphinView* parent) :
QListView(parent),
- m_parentView( parent )
+ m_parentView(parent)
{
setResizeMode(QListView::Adjust);
}
@@ -58,11 +61,8 @@ void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
const QModelIndex index = indexAt(event->pos());
if (index.isValid()) {
- // TODO: assuming that model() returns an instance of the class
- // KDirModel is dangerous, especially in combination with a proxy model.
- // As the current test implementation of proxy model does not work, this
- // will be cleaned up later.
- KDirModel* dirModel = static_cast<KDirModel*>(model());
+ const QAbstractProxyModel* proxyModel = static_cast<const QAbstractProxyModel*>(model());
+ const KDirModel* dirModel = static_cast<const KDirModel*>(proxyModel->sourceModel());
item = dirModel->itemForIndex(index);
}
@@ -75,4 +75,24 @@ void DolphinIconsView::mouseReleaseEvent(QMouseEvent* event)
m_parentView->declareViewActive();
}
+void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
+{
+ if (event->mimeData()->hasUrls()) {
+ event->acceptProposedAction();
+ }
+}
+
+void DolphinIconsView::dropEvent(QDropEvent* event)
+{
+ const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
+ if (!urls.isEmpty()) {
+ event->acceptProposedAction();
+
+ // TODO: handle dropping above a directory
+
+ const KUrl& destination = m_parentView->url();
+ m_parentView->mainWindow()->dropUrls(urls, destination);
+ }
+}
+
#include "dolphiniconsview.moc"