[pim/akonadi-calendar] src: Use KCalendarCore::MimeData for iCal QMimeData encoding/decoding

Allen Winter <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 328f4130fdd6372fae75c0d0aa8a2aa18c4bba3d by Allen Winter, on behalf of Volker Krause.
Committed on 22/07/2026 at 19:14.
Pushed by vkrause into branch 'master'.

Use KCalendarCore::MimeData for iCal QMimeData encoding/decoding

M  +8    -0    src/calendarclipboard.cpp
M  +10   -3    src/calendarutils.cpp
M  +15   -1    src/todomodel.cpp

https://invent.kde.org/pim/akonadi-calendar/-/commit/328f4130fdd6372fae75c0d0aa8a2aa18c4bba3d

diff --git a/src/calendarclipboard.cpp b/src/calendarclipboard.cpp
index f8ef1981..b7d27730 100644
--- a/src/calendarclipboard.cpp
+++ b/src/calendarclipboard.cpp
@@ -6,7 +6,11 @@
 
 #include "calendarclipboard_p.h"
 #include <KCalUtils/DndFactory>
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
 #include <KCalUtils/ICalDrag>
+#else
+#include <KCalendarCore/MimeData>
+#endif
 
 #include <KLocalizedString>
 #include <KMessageBox>
@@ -242,7 +246,11 @@ bool CalendarClipboard::copyIncidence(const KCalendarCore::Incidence::Ptr &incid
 
 bool CalendarClipboard::pasteAvailable() const
 {
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
     return KCalUtils::ICalDrag::canDecode(QApplication::clipboard()->mimeData());
+#else
+    return KCalendarCore::MimeData::canDecode(QGuiApplication::clipboard()->mimeData());
+#endif
 }
 
 #include "moc_calendarclipboard.cpp"
diff --git a/src/calendarutils.cpp b/src/calendarutils.cpp
index 270f6cfa..597ba191 100644
--- a/src/calendarutils.cpp
+++ b/src/calendarutils.cpp
@@ -17,7 +17,11 @@ using namespace Qt::Literals::StringLiterals;
 #include <Akonadi/Collection>
 #include <Akonadi/EntityTreeModel>
 
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
 #include <KCalUtils/ICalDrag>
+#else
+#include <KCalendarCore/MimeData>
+#endif
 
 #include <KLocalizedString>
 
@@ -227,28 +231,31 @@ QMimeData *CalendarUtils::createMimeData(const Akonadi::Item::List &items)
     KCalendarCore::MemoryCalendar::Ptr const cal(new KCalendarCore::MemoryCalendar(QTimeZone::systemTimeZone()));
 
     QList<QUrl> urls;
-    int incidencesFound = 0;
     for (const Akonadi::Item &item : items) {
         const KCalendarCore::Incidence::Ptr incidence(CalendarUtils::incidence(item));
         if (!incidence) {
             continue;
         }
-        ++incidencesFound;
         urls.push_back(item.url());
         KCalendarCore::Incidence::Ptr const i(incidence->clone());
         cal->addIncidence(i);
     }
 
-    if (incidencesFound == 0) {
+    if (urls.isEmpty()) {
         return nullptr;
     }
 
     auto mimeData = std::make_unique<QMimeData>();
     mimeData->setUrls(urls);
 
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
     if (KCalUtils::ICalDrag::populateMimeData(mimeData.get(), cal)) {
         return mimeData.release();
     } else {
         return nullptr;
     }
+#else
+    KCalendarCore::MimeData::populate(mimeData.get(), cal);
+    return KCalendarCore::MimeData::canDecode(mimeData.get()) ? mimeData.release() : nullptr;
+#endif
 }
diff --git a/src/todomodel.cpp b/src/todomodel.cpp
index d5b466b8..9d85011f 100644
--- a/src/todomodel.cpp
+++ b/src/todomodel.cpp
@@ -17,10 +17,14 @@ using namespace Qt::Literals::StringLiterals;
 #include <Akonadi/IncidenceTreeModel>
 #include <Akonadi/TagCache>
 
+#include <KCalUtils/IncidenceFormatter>
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
 #include <KCalUtils/DndFactory>
 #include <KCalUtils/ICalDrag>
-#include <KCalUtils/IncidenceFormatter>
 #include <KCalUtils/VCalDrag>
+#else
+#include <KCalendarCore/MimeData>
+#endif
 
 #include "akonadicalendar_debug.h"
 
@@ -526,11 +530,15 @@ Qt::DropActions TodoModel::supportedDropActions() const
 
 QStringList TodoModel::mimeTypes() const
 {
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
     static QStringList list;
     if (list.isEmpty()) {
         list << KCalUtils::ICalDrag::mimeType() << KCalUtils::VCalDrag::mimeType();
     }
     return list;
+#else
+    return KCalendarCore::MimeData::supportedMimeTypes();
+#endif
 }
 
 QMimeData *TodoModel::mimeData(const QModelIndexList &indexes) const
@@ -552,9 +560,15 @@ bool TodoModel::dropMimeData(const QMimeData *data, Qt::DropAction action, [[may
         return false;
     }
 
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
     if (d->m_changer && (KCalUtils::ICalDrag::canDecode(data) || KCalUtils::VCalDrag::canDecode(data))) {
         KCalendarCore::Todo::Ptr const t = KCalUtils::DndFactory::createDropTodo(data);
         KCalendarCore::Event::Ptr const e = KCalUtils::DndFactory::createDropEvent(data);
+#else
+    if (d->m_changer && KCalendarCore::MimeData::canDecode(data)) {
+        KCalendarCore::Todo::Ptr const t = KCalendarCore::MimeData::decodeTodo(data);
+        KCalendarCore::Event::Ptr const e = KCalendarCore::MimeData::decodeEvent(data);
+#endif
 
         if (t) {
             // we don't want to change the created todo, but the one which is already
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.