Changeset View
Changeset View
Standalone View
Standalone View
containments/desktop/plugins/folder/foldermodel.cpp
Show First 20 Lines • Show All 946 Lines • ▼ Show 20 Line(s) | 866 | { | |||
---|---|---|---|---|---|
947 | QDropEvent ev(pos, possibleActions, mimeData, buttons, modifiers); | 947 | QDropEvent ev(pos, possibleActions, mimeData, buttons, modifiers); | ||
948 | ev.setDropAction(proposedAction); | 948 | ev.setDropAction(proposedAction); | ||
949 | 949 | | |||
950 | KIO::DropJob *dropJob = KIO::drop(&ev, dropTargetUrl); | 950 | KIO::DropJob *dropJob = KIO::drop(&ev, dropTargetUrl); | ||
951 | dropJob->uiDelegate()->setAutoErrorHandlingEnabled(true); | 951 | dropJob->uiDelegate()->setAutoErrorHandlingEnabled(true); | ||
952 | const int x = dropEvent->property("x").toInt(); | 952 | const int x = dropEvent->property("x").toInt(); | ||
953 | const int y = dropEvent->property("y").toInt(); | 953 | const int y = dropEvent->property("y").toInt(); | ||
954 | 954 | | |||
955 | connect(dropJob, static_cast<void(KIO::DropJob::*)(const KFileItemListProperties &)>(&KIO::DropJob::popupMenuAboutToShow), this, [this, mimeData, x, y, dropJob](const KFileItemListProperties &) { | 955 | // The QMimeData we extract from the DropArea's drop event is deleted as soon as this method | ||
956 | emit popupMenuAboutToShow(dropJob, mimeData, x, y); | 956 | // ends but we need to keep a copy for when popupMenuAboutToShow fires. | ||
957 | QMimeData *mimeCopy = new QMimeData(); | ||||
958 | for (const QString &format : mimeData->formats()) { | ||||
959 | mimeCopy->setData(format, mimeData->data(format)); | ||||
960 | } | ||||
961 | | ||||
962 | connect(dropJob, static_cast<void(KIO::DropJob::*)(const KFileItemListProperties &)>(&KIO::DropJob::popupMenuAboutToShow), this, [this, mimeCopy, x, y, dropJob](const KFileItemListProperties &) { | ||||
963 | emit popupMenuAboutToShow(dropJob, mimeCopy, x, y); | ||||
964 | mimeCopy->deleteLater(); | ||||
957 | }); | 965 | }); | ||
958 | } | 966 | } | ||
959 | 967 | | |||
960 | void FolderModel::dropCwd(QObject* dropEvent) | 968 | void FolderModel::dropCwd(QObject* dropEvent) | ||
961 | { | 969 | { | ||
962 | QMimeData *mimeData = qobject_cast<QMimeData *>(dropEvent->property("mimeData").value<QObject *>()); | 970 | QMimeData *mimeData = qobject_cast<QMimeData *>(dropEvent->property("mimeData").value<QObject *>()); | ||
963 | 971 | | |||
964 | if (!mimeData) { | 972 | if (!mimeData) { | ||
▲ Show 20 Lines • Show All 710 Lines • Show Last 20 Lines |