[pim/kcalutils] src: Replace most iCal QMimeData en/decoding API with KCalendarCore::MimeData

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

Replace most iCal QMimeData en/decoding API with KCalendarCore::MimeData

The remaining methods have one user each and will be used there, entirely
removing DndFactory as well.

M  +19   -0    src/dndfactory.cpp
M  +2    -0    src/dndfactory.h
M  +2    -0    src/icaldrag.cpp
M  +2    -0    src/icaldrag.h
M  +2    -0    src/vcaldrag.cpp
M  +2    -0    src/vcaldrag.h

https://invent.kde.org/pim/kcalutils/-/commit/1b167c95a08230cb86ba899afc5d0eaec977981f

diff --git a/src/dndfactory.cpp b/src/dndfactory.cpp
index 9c8bc01c9..8e1e02746 100644
--- a/src/dndfactory.cpp
+++ b/src/dndfactory.cpp
@@ -27,6 +27,9 @@
 
 #include "kcalutils_debug.h"
 #include <KCalendarCore/MemoryCalendar>
+#if KCALENDARCORE_VERSION >= QT_VERSION_CHECK(6, 29, 0)
+#include <KCalendarCore/MimeData>
+#endif
 #include <QUrl>
 
 #include <QClipboard>
@@ -114,6 +117,7 @@ static Incidence::Ptr pasteIncidence(const Incidence::Ptr &incidence, QDateTime
 }
 //@endcond
 
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
 Calendar::Ptr DndFactory::createDropCalendar(const QMimeData *mimeData)
 {
     if (mimeData) {
@@ -157,11 +161,13 @@ Todo::Ptr DndFactory::createDropTodo(const QMimeData *mimeData)
 
     return todo;
 }
+#endif
 
 bool DndFactory::copyIncidences(const Incidence::List &incidences)
 {
     QClipboard *clipboard = QGuiApplication::clipboard();
     Q_ASSERT(clipboard);
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
     Calendar::Ptr const calendar(new MemoryCalendar(QTimeZone::systemTimeZone()));
 
     Incidence::List::ConstIterator it;
@@ -182,13 +188,26 @@ bool DndFactory::copyIncidences(const Incidence::List &incidences)
         clipboard->setMimeData(mimeData);
         return true;
     }
+#else
+    auto mimeData = new QMimeData;
+    KCalendarCore::MimeData::populate(mimeData, incidences);
+    if (KCalendarCore::MimeData::canDecode(mimeData)) {
+        clipboard->setMimeData(mimeData);
+        return true;
+    }
+    return false;
+#endif
 }
 
 Incidence::List DndFactory::pasteIncidences(const QDateTime &newDateTime, PasteFlags pasteOptions)
 {
     QClipboard const *clipboard = QGuiApplication::clipboard();
     Q_ASSERT(clipboard);
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
     Calendar::Ptr const calendar(createDropCalendar(clipboard->mimeData()));
+#else
+    Calendar::Ptr const calendar(KCalendarCore::MimeData::decodeCalendar(clipboard->mimeData()));
+#endif
     Incidence::List list;
 
     if (!calendar) {
diff --git a/src/dndfactory.h b/src/dndfactory.h
index 873fd9df0..c96507ff8 100644
--- a/src/dndfactory.h
+++ b/src/dndfactory.h
@@ -55,6 +55,7 @@ public:
 
     Q_DECLARE_FLAGS(PasteFlags, PasteFlag)
 
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
     /*!
      Create the calendar that is contained in the mime data.
     */
@@ -69,6 +70,7 @@ public:
       Create Event object from mime data.
     */
     static KCalendarCore::Event::Ptr createDropEvent(const QMimeData *mimeData);
+#endif
 
     /*!
       Copies a list of \a incidences to the clipboard.
diff --git a/src/icaldrag.cpp b/src/icaldrag.cpp
index 0fdfce698..1ba0a5bfa 100644
--- a/src/icaldrag.cpp
+++ b/src/icaldrag.cpp
@@ -8,6 +8,7 @@
 */
 #include "icaldrag.h"
 
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
 #include <KCalendarCore/ICalFormat>
 using namespace KCalendarCore;
 
@@ -59,3 +60,4 @@ bool ICalDrag::fromMimeData(const QMimeData *de, const Calendar::Ptr &cal)
 
     return success;
 }
+#endif
diff --git a/src/icaldrag.h b/src/icaldrag.h
index 4da1dc878..4c0d8038f 100644
--- a/src/icaldrag.h
+++ b/src/icaldrag.h
@@ -12,6 +12,7 @@
 
 #include <KCalendarCore/Calendar>
 
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
 class QMimeData;
 
 namespace KCalUtils
@@ -54,3 +55,4 @@ KCALUTILS_EXPORT bool populateMimeData(QMimeData *e, const KCalendarCore::Calend
 [[nodiscard]] KCALUTILS_EXPORT bool fromMimeData(const QMimeData *e, const KCalendarCore::Calendar::Ptr &cal);
 }
 }
+#endif
diff --git a/src/vcaldrag.cpp b/src/vcaldrag.cpp
index 59ad1c467..13e645500 100644
--- a/src/vcaldrag.cpp
+++ b/src/vcaldrag.cpp
@@ -8,6 +8,7 @@
 */
 #include "vcaldrag.h"
 
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
 #include <KCalendarCore/VCalFormat>
 using namespace KCalendarCore;
 
@@ -48,3 +49,4 @@ bool VCalDrag::fromMimeData(const QMimeData *de, const Calendar::Ptr &cal)
 
     return success;
 }
+#endif
diff --git a/src/vcaldrag.h b/src/vcaldrag.h
index 22c95ba2b..b08d4173d 100644
--- a/src/vcaldrag.h
+++ b/src/vcaldrag.h
@@ -11,6 +11,7 @@
 #include "kcalutils_export.h"
 #include <KCalendarCore/Calendar>
 
+#if KCALENDARCORE_VERSION < QT_VERSION_CHECK(6, 29, 0)
 class QMimeData;
 
 namespace KCalUtils
@@ -45,3 +46,4 @@ namespace VCalDrag
 [[nodiscard]] KCALUTILS_EXPORT bool fromMimeData(const QMimeData *e, const KCalendarCore::Calendar::Ptr &cal);
 }
 }
+#endif
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.