File indexing completed on 2024-06-02 04:14:46

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2009-04-26
0007  * Description : Qt Model for Images - drag and drop handling
0008  *
0009  * SPDX-FileCopyrightText: 2009-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #include "abstractitemdragdrophandler.h"
0016 
0017 // Qt includes
0018 
0019 #include <QMimeData>
0020 #include <QStringList>
0021 
0022 namespace Digikam
0023 {
0024 
0025 AbstractItemDragDropHandler::AbstractItemDragDropHandler(QAbstractItemModel* const model)
0026     : QObject(model),
0027       m_model(model)
0028 {
0029 }
0030 
0031 AbstractItemDragDropHandler::~AbstractItemDragDropHandler()
0032 {
0033 }
0034 
0035 QAbstractItemModel* AbstractItemDragDropHandler::model() const
0036 {
0037     return m_model;
0038 }
0039 
0040 bool AbstractItemDragDropHandler::dropEvent(QAbstractItemView*, const QDropEvent*, const QModelIndex&)
0041 {
0042     return false;
0043 }
0044 
0045 Qt::DropAction AbstractItemDragDropHandler::accepts(const QDropEvent*, const QModelIndex&)
0046 {
0047     return Qt::IgnoreAction;
0048 }
0049 
0050 QStringList AbstractItemDragDropHandler::mimeTypes() const
0051 {
0052     return QStringList();
0053 }
0054 
0055 QMimeData* AbstractItemDragDropHandler::createMimeData(const QList<QModelIndex>&)
0056 {
0057     return nullptr;
0058 }
0059 
0060 bool AbstractItemDragDropHandler::acceptsMimeData(const QMimeData* mime)
0061 {
0062     QStringList modelTypes = mimeTypes();
0063 
0064     for (int i = 0 ; i < modelTypes.count() ; ++i)
0065     {
0066         if (mime->hasFormat(modelTypes.at(i))) //&& (e->dropAction() & model->supportedDropActions()))
0067         {
0068             return true;
0069         }
0070     }
0071 
0072     return false;
0073 }
0074 
0075 } // namespace Digikam
0076 
0077 #include "moc_abstractitemdragdrophandler.cpp"