diff options
Diffstat (limited to 'src/panels')
| -rw-r--r-- | src/panels/places/placesitemlistwidget.cpp | 2 | ||||
| -rw-r--r-- | src/panels/places/placesitemmodel.cpp | 7 | ||||
| -rw-r--r-- | src/panels/places/placesitemmodel.h | 5 | ||||
| -rw-r--r-- | src/panels/places/placespanel.cpp | 19 | ||||
| -rw-r--r-- | src/panels/places/placespanel.h | 1 |
5 files changed, 31 insertions, 3 deletions
diff --git a/src/panels/places/placesitemlistwidget.cpp b/src/panels/places/placesitemlistwidget.cpp index 3f4c92dfa..24c2b3f11 100644 --- a/src/panels/places/placesitemlistwidget.cpp +++ b/src/panels/places/placesitemlistwidget.cpp @@ -19,6 +19,8 @@ #include "placesitemlistwidget.h" +#include "kdebug.h" + PlacesItemListWidget::PlacesItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) : KStandardItemListWidget(informant, parent) { diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp index 00ab9670b..497901345 100644 --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@ -396,7 +396,12 @@ QMimeData* PlacesItemModel::createMimeData(const QSet<int>& indexes) const return mimeData; } -void PlacesItemModel::dropMimeData(int index, const QMimeData* mimeData) +bool PlacesItemModel::supportsDropping(int index) const +{ + return index >= 0 && index < count(); +} + +void PlacesItemModel::dropMimeDataBefore(int index, const QMimeData* mimeData) { if (mimeData->hasFormat(internalMimeType())) { // The item has been moved inside the view diff --git a/src/panels/places/placesitemmodel.h b/src/panels/places/placesitemmodel.h index a060f4549..463e564e3 100644 --- a/src/panels/places/placesitemmodel.h +++ b/src/panels/places/placesitemmodel.h @@ -120,7 +120,10 @@ public: /** @reimp */ virtual QMimeData* createMimeData(const QSet<int>& indexes) const; - void dropMimeData(int index, const QMimeData* mimeData); + /** @reimp */ + virtual bool supportsDropping(int index) const; + + void dropMimeDataBefore(int index, const QMimeData* mimeData); /** * @return Converts the URL, which contains "virtual" URLs for system-items like diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index 64de516fa..429c5399a 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -93,6 +93,7 @@ void PlacesPanel::showEvent(QShowEvent* event) connect(m_controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF))); connect(m_controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF))); connect(m_controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*))); + connect(m_controller, SIGNAL(aboveItemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotAboveItemDropEvent(int,QGraphicsSceneDragDropEvent*))); KItemListContainer* container = new KItemListContainer(m_controller, this); container->setEnabledFrame(false); @@ -253,7 +254,23 @@ void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos) void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event) { - m_model->dropMimeData(index, event->mimeData()); + if (index < 0) { + return; + } + + KUrl destUrl = m_model->placesItem(index)->url(); + QDropEvent dropEvent(event->pos().toPoint(), + event->possibleActions(), + event->mimeData(), + event->buttons(), + event->modifiers()); + + DragAndDropHelper::dropUrls(KFileItem(), destUrl, &dropEvent); +} + +void PlacesPanel::slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event) +{ + m_model->dropMimeDataBefore(index, event->mimeData()); } void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent) diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h index 427b01248..8a84e00a0 100644 --- a/src/panels/places/placespanel.h +++ b/src/panels/places/placespanel.h @@ -56,6 +56,7 @@ private slots: void slotItemContextMenuRequested(int index, const QPointF& pos); void slotViewContextMenuRequested(const QPointF& pos); void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event); + void slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event); void slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent); void slotTrashUpdated(KJob* job); void slotStorageSetupDone(int index, bool success); |
