[pim/kalarm] src: Use KCalendarCore::MimeData for DnD operations

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

Use KCalendarCore::MimeData for DnD operations

Once we depend on KF 6.29 this will remove the dependency on kcalendarutils
here entirely.

M  +8    -0    src/editdlgtypes.cpp
M  +8    -0    src/lib/lineedit.cpp
M  +16   -1    src/mainwindow.cpp

https://invent.kde.org/pim/kalarm/-/commit/9da28b82b60c511cc4463012541d56ec777b5de9

diff --git a/src/editdlgtypes.cpp b/src/editdlgtypes.cpp
index 2b6188d60..4f9f133b8 100644
--- a/src/editdlgtypes.cpp
+++ b/src/editdlgtypes.cpp
@@ -36,7 +36,11 @@
 #include "audioplugin/audioplugin.h"
 #include "kalarm_debug.h"
 
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
 #include <KCalUtils/ICalDrag>
+#else
+#include <KCalendarCore/MimeData>
+#endif
 #include <KCalendarCore/Person>
 
 #include <KLocalizedString>
@@ -1994,7 +1998,11 @@ void TextEdit::enableEmailDrop()
 
 void TextEdit::dragEnterEvent(QDragEnterEvent* e)
 {
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
     if (KCalUtils::ICalDrag::canDecode(e->mimeData()))
+#else
+    if (KCalendarCore::MimeData::canDecode(e->mimeData()))
+#endif
     {
         e->ignore();   // don't accept "text/calendar" objects
         return;
diff --git a/src/lib/lineedit.cpp b/src/lib/lineedit.cpp
index c0559f415..47927cd04 100644
--- a/src/lib/lineedit.cpp
+++ b/src/lib/lineedit.cpp
@@ -11,7 +11,11 @@
 #include "dragdrop.h"
 
 #include <KContacts/VCardDrag>
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
 #include <KCalUtils/ICalDrag>
+#else
+#include <KCalendarCore/MimeData>
+#endif
 
 #include <KUrlCompletion>
 #include <KShell>
@@ -87,7 +91,11 @@ void LineEdit::dragEnterEvent(QDragEnterEvent* e)
 {
     const QMimeData* data = e->mimeData();
     bool ok;
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
     if (KCalUtils::ICalDrag::canDecode(data))
+#else
+    if (KCalendarCore::MimeData::canDecode(data))
+#endif
         ok = false;   // don't accept "text/calendar" objects
     else
         ok = (data->hasText()
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index c33ec41e8..ca0118c6e 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -34,10 +34,14 @@
 #include "config-kalarm.h"
 #include "kalarm_debug.h"
 
-#include <KCalUtils/ICalDrag>
 #include <KCalendarCore/MemoryCalendar>
 using namespace KCalendarCore;
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
+#include <KCalUtils/ICalDrag>
 using namespace KCalUtils;
+#else
+#include <KCalendarCore/MimeData>
+#endif
 
 #include <KAboutData>
 #include <KToolBar>
@@ -1424,8 +1428,13 @@ void MainWindow::closeEvent(QCloseEvent* ce)
 void MainWindow::executeDragEnterEvent(QDragEnterEvent* e)
 {
     const QMimeData* data = e->mimeData();
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
     bool accept = ICalDrag::canDecode(data) ? !e->source()   // don't accept "text/calendar" objects from this application
                                             : data->hasText() || data->hasUrls();
+#else
+    bool accept = KCalendarCore::MimeData::canDecode(data) ? !e->source()   // don't accept "text/calendar" objects from this application
+                                            : data->hasText() || data->hasUrls();
+#endif
     if (accept)
         e->acceptProposedAction();
 }
@@ -1449,7 +1458,9 @@ void MainWindow::executeDropEvent(MainWindow* win, QDropEvent* e)
     const QMimeData* data = e->mimeData();
     KAEvent::SubAction action = KAEvent::SubAction::Message;
     AlarmText          alarmText;
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
     MemoryCalendar::Ptr calendar(new MemoryCalendar(Preferences::timeSpecAsZone()));
+#endif
 #ifndef NDEBUG
     const QString fmts = data->formats().join(", "_L1);
     qCDebug(KALARM_LOG) << "MainWindow::executeDropEvent:" << fmts;
@@ -1465,7 +1476,11 @@ void MainWindow::executeDropEvent(MainWindow* win, QDropEvent* e)
         qCDebug(KALARM_LOG) << "MainWindow::executeDropEvent: email";
 //TODO: Fetch attachments if an email alarm is created below
     }
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
     else if (ICalDrag::fromMimeData(data, calendar))
+#else
+    else if (const auto calendar = KCalendarCore::MimeData::decodeCalendar(data); calendar)
+#endif
     {
         // iCalendar - If events are included, use the first event
         qCDebug(KALARM_LOG) << "MainWindow::executeDropEvent: iCalendar";
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.