| 1 | /* ============================================================ |
| 2 | * |
| 3 | * This file is a part of digiKam project |
| 4 | * https://www.digikam.org |
| 5 | * |
| 6 | * Date : 2010-03-18 |
| 7 | * Description : Drag-and-drop handler for geolocation interface used in the demo |
| 8 | * |
| 9 | * SPDX-FileCopyrightText: 2010 by Michael G. Hansen <mike at mghansen dot de> |
| 10 | * |
| 11 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 12 | * |
| 13 | * ============================================================ */ |
| 14 | |
| 15 | #include "mydragdrophandler.h" |
| 16 | |
| 17 | // Qt includes |
| 18 | |
| 19 | #include <QDropEvent> |
| 20 | |
| 21 | // Local includes |
| 22 | |
| 23 | #include "digikam_debug.h" |
| 24 | #include "mytreewidget.h" |
| 25 | |
| 26 | MyDragDropHandler::MyDragDropHandler(QAbstractItemModel* const pModel, QObject* const parent) |
| 27 | : GeoDragDropHandler(parent), |
| 28 | model (pModel) |
| 29 | { |
| 30 | } |
| 31 | |
| 32 | MyDragDropHandler::~MyDragDropHandler() |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | Qt::DropAction MyDragDropHandler::accepts(const QDropEvent* /*e*/) |
| 37 | { |
| 38 | return Qt::CopyAction; |
| 39 | } |
| 40 | |
| 41 | bool MyDragDropHandler::dropEvent(const QDropEvent* e, const GeoCoordinates& dropCoordinates) |
| 42 | { |
| 43 | const MyDragData* const mimeData = qobject_cast<const MyDragData*>(e->mimeData()); |
| 44 | |
| 45 | if (!mimeData) |
| 46 | return false; |
| 47 | |
| 48 | qCDebug(DIGIKAM_TESTS_LOG) << mimeData->draggedIndices.count(); |
| 49 | |
| 50 | for (int i = 0 ; i < mimeData->draggedIndices.count() ; ++i) |
| 51 | { |
| 52 | const QPersistentModelIndex itemIndex = mimeData->draggedIndices.at(i); |
| 53 | |
| 54 | if (!itemIndex.isValid()) |
| 55 | { |
| 56 | continue; |
| 57 | } |
| 58 | |
| 59 | model->setData(itemIndex, QVariant::fromValue(dropCoordinates), RoleCoordinates); |
| 60 | } |
| 61 | |
| 62 | // TODO: tell the main window about this so it can start an altitude lookup |
| 63 | |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | QMimeData* MyDragDropHandler::createMimeData(const QList<QPersistentModelIndex>& /*modelIndices*/) |
| 68 | { |
| 69 | return nullptr; |
| 70 | } |
| 71 | |
| 72 | #include "moc_mydragdrophandler.cpp" |