[pim/kmail] src/kontactplugin/kmail: Use KCalendarCore::MimeData for iCal DnD operations

Volker Krause <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 6ad818077ad1e63c169a574e66641bd2d4d22454 by Volker Krause.
Committed on 26/07/2026 at 14:49.
Pushed by vkrause into branch 'master'.

Use KCalendarCore::MimeData for iCal DnD operations

Once we depend on KF 6.29 this will remove the (direct) dependency on
kcalendarutils here then.

M  +17   -3    src/kontactplugin/kmail/kmail_plugin.cpp

https://invent.kde.org/pim/kmail/-/commit/6ad818077ad1e63c169a574e66641bd2d4d22454

diff --git a/src/kontactplugin/kmail/kmail_plugin.cpp b/src/kontactplugin/kmail/kmail_plugin.cpp
index 959b404cf..b132ec68a 100644
--- a/src/kontactplugin/kmail/kmail_plugin.cpp
+++ b/src/kontactplugin/kmail/kmail_plugin.cpp
@@ -11,8 +11,13 @@
 #include "kmailinterface.h"
 #include "summarywidget.h"
 
+#include <kcalendarcore_version.h>
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
 #include <KCalUtils/ICalDrag>
 #include <KCalUtils/VCalDrag>
+#else
+#include <KCalendarCore/MimeData>
+#endif
 #include <KCalendarCore/FileStorage>
 #include <KCalendarCore/MemoryCalendar>
 #include <KContacts/VCardDrag>
@@ -30,7 +35,6 @@
 #include <QStandardPaths>
 #include <QUrl>
 
-using namespace KCalUtils;
 using namespace KCalendarCore;
 using namespace Qt::Literals::StringLiterals;
 
@@ -65,7 +69,11 @@ KMailPlugin::KMailPlugin(KontactInterface::Core *core, const KPluginMetaData &da
 
 bool KMailPlugin::canDecodeMimeData(const QMimeData *mimeData) const
 {
-    return ICalDrag::canDecode(mimeData) || VCalDrag::canDecode(mimeData) || KContacts::VCardDrag::canDecode(mimeData);
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
+    return KCalUtils::ICalDrag::canDecode(mimeData) || KCalUtils::VCalDrag::canDecode(mimeData) || KContacts::VCardDrag::canDecode(mimeData);
+#else
+    return KCalendarCore::MimeData::canDecode(mimeData) || KContacts::VCardDrag::canDecode(mimeData);
+#endif
 }
 
 void KMailPlugin::shortcutChanged()
@@ -82,11 +90,17 @@ void KMailPlugin::shortcutChanged()
 
 void KMailPlugin::processDropEvent(QDropEvent *de)
 {
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
     MemoryCalendar::Ptr cal(new MemoryCalendar(QTimeZone::utc()));
+#endif
     KContacts::Addressee::List list;
     const QMimeData *md = de->mimeData();
 
-    if (VCalDrag::fromMimeData(md, cal) || ICalDrag::fromMimeData(md, cal)) {
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
+    if (KCalUtils::VCalDrag::fromMimeData(md, cal) || KCalUtils::ICalDrag::fromMimeData(md, cal)) {
+#else
+    if (const auto cal = KCalendarCore::MimeData::decodeCalendar(md); cal) {
+#endif
         QTemporaryFile tmp(QStringLiteral("incidences-kmail_XXXXXX.ics"));
         if (tmp.open()) {
             tmp.setAutoRemove(false);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.