Changeset View
Changeset View
Standalone View
Standalone View
containments/desktop/plugins/folder/foldermodel.cpp
Show First 20 Lines • Show All 886 Lines • ▼ Show 20 Line(s) | |||||
887 | void FolderModel::drop(QQuickItem *target, QObject* dropEvent, int row) | 887 | void FolderModel::drop(QQuickItem *target, QObject* dropEvent, int row) | ||
888 | { | 888 | { | ||
889 | QMimeData *mimeData = qobject_cast<QMimeData *>(dropEvent->property("mimeData").value<QObject *>()); | 889 | QMimeData *mimeData = qobject_cast<QMimeData *>(dropEvent->property("mimeData").value<QObject *>()); | ||
890 | 890 | | |||
891 | if (!mimeData) { | 891 | if (!mimeData) { | ||
892 | return; | 892 | return; | ||
893 | } | 893 | } | ||
894 | 894 | | |||
895 | const int x = dropEvent->property("x").toInt(); | ||||
896 | const int y = dropEvent->property("y").toInt(); | ||||
897 | | ||||
895 | if (m_dragInProgress && row == -1 && !m_urlChangedWhileDragging) { | 898 | if (m_dragInProgress && row == -1 && !m_urlChangedWhileDragging) { | ||
896 | if (m_locked || mimeData->urls().isEmpty()) { | 899 | if (m_locked || mimeData->urls().isEmpty()) { | ||
897 | return; | 900 | return; | ||
898 | } | 901 | } | ||
899 | 902 | | |||
900 | setSortMode(-1); | 903 | setSortMode(-1); | ||
901 | 904 | | |||
902 | emit move(dropEvent->property("x").toInt(), dropEvent->property("y").toInt(), | 905 | emit move(x, y, mimeData->urls()); | ||
903 | mimeData->urls()); | | |||
904 | 906 | | |||
905 | return; | 907 | return; | ||
906 | } | 908 | } | ||
907 | 909 | | |||
908 | QModelIndex idx; | 910 | QModelIndex idx; | ||
909 | KFileItem item; | 911 | KFileItem item; | ||
910 | 912 | | |||
911 | if (row > -1 && row < rowCount()) { | 913 | if (row > -1 && row < rowCount()) { | ||
Show All 37 Lines | 939 | if (mimeData->hasFormat(QStringLiteral("application/x-kde-ark-dndextract-service")) && | |||
949 | 951 | | |||
950 | return; | 952 | return; | ||
951 | } | 953 | } | ||
952 | 954 | | |||
953 | if (idx.isValid() && !(flags(idx) & Qt::ItemIsDropEnabled)) { | 955 | if (idx.isValid() && !(flags(idx) & Qt::ItemIsDropEnabled)) { | ||
954 | return; | 956 | return; | ||
955 | } | 957 | } | ||
956 | 958 | | |||
957 | QPoint pos; | 959 | QPoint pos = {x, y}; | ||
broulik: `QPoint pos(x, y);`? | |||||
958 | pos.setX(dropEvent->property("x").toInt()); | | |||
959 | pos.setY(dropEvent->property("y").toInt()); | | |||
960 | | ||||
961 | pos = target->mapToScene(pos).toPoint(); | 960 | pos = target->mapToScene(pos).toPoint(); | ||
962 | pos = target->window()->mapToGlobal(pos); | 961 | pos = target->window()->mapToGlobal(pos); | ||
963 | 962 | | |||
964 | Qt::DropAction proposedAction((Qt::DropAction)dropEvent->property("proposedAction").toInt()); | 963 | Qt::DropAction proposedAction((Qt::DropAction)dropEvent->property("proposedAction").toInt()); | ||
965 | Qt::DropActions possibleActions(dropEvent->property("possibleActions").toInt()); | 964 | Qt::DropActions possibleActions(dropEvent->property("possibleActions").toInt()); | ||
966 | Qt::MouseButtons buttons(dropEvent->property("buttons").toInt()); | 965 | Qt::MouseButtons buttons(dropEvent->property("buttons").toInt()); | ||
967 | Qt::KeyboardModifiers modifiers(dropEvent->property("modifiers").toInt()); | 966 | Qt::KeyboardModifiers modifiers(dropEvent->property("modifiers").toInt()); | ||
968 | 967 | | |||
969 | QDropEvent ev(pos, possibleActions, mimeData, buttons, modifiers); | 968 | QDropEvent ev(pos, possibleActions, mimeData, buttons, modifiers); | ||
970 | ev.setDropAction(proposedAction); | 969 | ev.setDropAction(proposedAction); | ||
971 | 970 | | |||
972 | KIO::DropJob *dropJob = KIO::drop(&ev, dropTargetUrl); | 971 | KIO::DropJob *dropJob = KIO::drop(&ev, dropTargetUrl); | ||
973 | dropJob->uiDelegate()->setAutoErrorHandlingEnabled(true); | 972 | dropJob->uiDelegate()->setAutoErrorHandlingEnabled(true); | ||
974 | const int x = dropEvent->property("x").toInt(); | | |||
975 | const int y = dropEvent->property("y").toInt(); | | |||
976 | 973 | | |||
977 | // The QMimeData we extract from the DropArea's drop event is deleted as soon as this method | 974 | // The QMimeData we extract from the DropArea's drop event is deleted as soon as this method | ||
978 | // ends but we need to keep a copy for when popupMenuAboutToShow fires. | 975 | // ends but we need to keep a copy for when popupMenuAboutToShow fires. | ||
979 | QMimeData *mimeCopy = new QMimeData(); | 976 | QMimeData *mimeCopy = new QMimeData(); | ||
980 | for (const QString &format : mimeData->formats()) { | 977 | for (const QString &format : mimeData->formats()) { | ||
981 | mimeCopy->setData(format, mimeData->data(format)); | 978 | mimeCopy->setData(format, mimeData->data(format)); | ||
982 | } | 979 | } | ||
983 | 980 | | |||
▲ Show 20 Lines • Show All 718 Lines • Show Last 20 Lines |
QPoint pos(x, y);?