File indexing completed on 2025-01-19 03:57:44
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2010-03-18 0007 * Description : Drag-and-drop handler for geolocation interface used in the demo 0008 * 0009 * SPDX-FileCopyrightText: 2010 by Michael G. Hansen <mike at mghansen dot de> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "mydragdrophandler.h" 0016 0017 // Qt includes 0018 0019 #include <QDropEvent> 0020 0021 // Local includes 0022 0023 #include "digikam_debug.h" 0024 #include "mytreewidget.h" 0025 0026 MyDragDropHandler::MyDragDropHandler(QAbstractItemModel* const pModel, QObject* const parent) 0027 : GeoDragDropHandler(parent), 0028 model (pModel) 0029 { 0030 } 0031 0032 MyDragDropHandler::~MyDragDropHandler() 0033 { 0034 } 0035 0036 Qt::DropAction MyDragDropHandler::accepts(const QDropEvent* /*e*/) 0037 { 0038 return Qt::CopyAction; 0039 } 0040 0041 bool MyDragDropHandler::dropEvent(const QDropEvent* e, const GeoCoordinates& dropCoordinates) 0042 { 0043 const MyDragData* const mimeData = qobject_cast<const MyDragData*>(e->mimeData()); 0044 0045 if (!mimeData) 0046 return false; 0047 0048 qCDebug(DIGIKAM_TESTS_LOG) << mimeData->draggedIndices.count(); 0049 0050 for (int i = 0 ; i < mimeData->draggedIndices.count() ; ++i) 0051 { 0052 const QPersistentModelIndex itemIndex = mimeData->draggedIndices.at(i); 0053 0054 if (!itemIndex.isValid()) 0055 { 0056 continue; 0057 } 0058 0059 model->setData(itemIndex, QVariant::fromValue(dropCoordinates), RoleCoordinates); 0060 } 0061 0062 // TODO: tell the main window about this so it can start an altitude lookup 0063 0064 return true; 0065 } 0066 0067 QMimeData* MyDragDropHandler::createMimeData(const QList<QPersistentModelIndex>& /*modelIndices*/) 0068 { 0069 return nullptr; 0070 } 0071 0072 #include "moc_mydragdrophandler.cpp"