[pim/calendarsupport] src: Use KCalendarCore::MimeData for iCal QMimeData encoding/decoding

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

Use KCalendarCore::MimeData for iCal QMimeData encoding/decoding

Also removes CalendarSupport::incidences(const QMimeData*) as that's now
provided by KCalendarCore API.

M  +14   -0    src/utils.cpp
M  +2    -0    src/utils.h

https://invent.kde.org/pim/calendarsupport/-/commit/1f9ee0a2d330138aff40ed39561869fe17206a6a

diff --git a/src/utils.cpp b/src/utils.cpp
index 0dd5af37..f4af51d0 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -31,9 +31,13 @@ using namespace Qt::Literals::StringLiterals;
 #include <KCalendarCore/FreeBusy>
 #include <KCalendarCore/MemoryCalendar>
 
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
 #include <KCalUtils/DndFactory>
 #include <KCalUtils/ICalDrag>
 #include <KCalUtils/VCalDrag>
+#else
+#include <KCalendarCore/MimeData>
+#endif
 
 #include <KLocalizedString>
 
@@ -213,7 +217,11 @@ static bool containsValidIncidenceItemUrl(const QList<QUrl> &urls)
 bool CalendarSupport::canDecode(const QMimeData *md)
 {
     if (md) {
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
         return containsValidIncidenceItemUrl(md->urls()) || KCalUtils::ICalDrag::canDecode(md) || KCalUtils::VCalDrag::canDecode(md);
+#else
+        return containsValidIncidenceItemUrl(md->urls()) || KCalendarCore::MimeData::canDecode(md);
+#endif
     } else {
         return false;
     }
@@ -233,9 +241,14 @@ QList<QUrl> CalendarSupport::incidenceItemUrls(const QMimeData *mimeData)
 
 bool CalendarSupport::mimeDataHasIncidence(const QMimeData *mimeData)
 {
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
     return !incidenceItemUrls(mimeData).isEmpty() || !incidences(mimeData).isEmpty();
+#else
+    return !incidenceItemUrls(mimeData).isEmpty() || !KCalendarCore::MimeData::decodeIncidences(mimeData).isEmpty();
+#endif
 }
 
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
 KCalendarCore::Incidence::List CalendarSupport::incidences(const QMimeData *mimeData)
 {
     KCalendarCore::Incidence::List incidences;
@@ -253,6 +266,7 @@ KCalendarCore::Incidence::List CalendarSupport::incidences(const QMimeData *mime
 
     return incidences;
 }
+#endif
 
 Akonadi::Collection CalendarSupport::selectCollection(QWidget *parent, int &dialogCode, const QStringList &mimeTypes, const Akonadi::Collection &defCollection)
 {
diff --git a/src/utils.h b/src/utils.h
index b61fc13c..4417913a 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -107,7 +107,9 @@ CALENDARSUPPORT_EXPORT QList<QUrl> incidenceItemUrls(const QMimeData *mimeData);
 
 CALENDARSUPPORT_EXPORT bool mimeDataHasIncidence(const QMimeData *mimeData);
 
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
 CALENDARSUPPORT_EXPORT KCalendarCore::Incidence::List incidences(const QMimeData *mimeData);
+#endif
 
 #ifndef QT_NO_DRAGANDDROP
 /*!
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.