[pim/kcalutils] /: Remove DndFactory::copyIncidences

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

Remove DndFactory::copyIncidences

Moved to akonadi-calendar, its only user.

M  +23   -3    autotests/testdndfactory.cpp
M  +0    -36   src/dndfactory.cpp
M  +0    -5    src/dndfactory.h

https://invent.kde.org/pim/kcalutils/-/commit/d59d0c89cbc205656f1842b9c1a2b4c40f231e1a

diff --git a/autotests/testdndfactory.cpp b/autotests/testdndfactory.cpp
index c0b7b0b46..b9bf24f10 100644
--- a/autotests/testdndfactory.cpp
+++ b/autotests/testdndfactory.cpp
@@ -12,7 +12,13 @@
 #include "dndfactory.h"
 
 #include <KCalendarCore/MemoryCalendar>
+#if KCALENDARCORE_VERSION >= QT_VERSION_CHECK(6, 29, 0)
+#include <KCalendarCore/MimeData>
+#endif
 
+#include <QClipboard>
+#include <QGuiApplication>
+#include <QMimeData>
 #include <QTest>
 #include <QTimeZone>
 
@@ -23,6 +29,7 @@ using namespace KCalUtils;
 
 void DndFactoryTest::testPasteAllDayEvent()
 {
+#if KCALENDARCORE_VERSION >= QT_VERSION_CHECK(6, 29, 0)
     const Event::Ptr allDayEvent(new Event());
     allDayEvent->setSummary(QStringLiteral("Summary 1"));
     allDayEvent->setDtStart(QDateTime(QDate(2010, 8, 8), {}));
@@ -34,7 +41,9 @@ void DndFactoryTest::testPasteAllDayEvent()
     Incidence::List incidencesToPaste;
     incidencesToPaste.append(allDayEvent);
 
-    QVERIFY(DndFactory::copyIncidences(incidencesToPaste));
+    auto mimeData = new QMimeData;
+    KCalendarCore::MimeData::populate(mimeData, incidencesToPaste);
+    qGuiApp->clipboard()->setMimeData(mimeData);
 
     Incidence::List pastedIncidences = DndFactory::pasteIncidences();
     QVERIFY(pastedIncidences.size() == 1);
@@ -54,10 +63,13 @@ void DndFactoryTest::testPasteAllDayEvent()
     QCOMPARE(pastedEvent->dtStart(), allDayEvent->dtStart());
     QCOMPARE(pastedEvent->dtEnd(), allDayEvent->dtEnd());
     QCOMPARE(pastedEvent->summary(), allDayEvent->summary());
+#endif
 }
 
 void DndFactoryTest::testPasteAllDayEvent2()
 {
+#if KCALENDARCORE_VERSION >= QT_VERSION_CHECK(6, 29, 0)
+
     const Event::Ptr allDayEvent(new Event());
     allDayEvent->setSummary(QStringLiteral("Summary 2"));
     allDayEvent->setDtStart(QDateTime(QDate(2010, 8, 8), {}));
@@ -68,7 +80,10 @@ void DndFactoryTest::testPasteAllDayEvent2()
     Incidence::List incidencesToPaste;
     incidencesToPaste.append(allDayEvent);
 
-    QVERIFY(DndFactory::copyIncidences(incidencesToPaste));
+    auto mimeData = new QMimeData;
+    KCalendarCore::MimeData::populate(mimeData, incidencesToPaste);
+    qGuiApp->clipboard()->setMimeData(mimeData);
+
     const QDateTime newDateTime(QDate(2011, 1, 1).startOfDay());
     const uint originalLength = allDayEvent->dtStart().secsTo(allDayEvent->dtEnd());
 
@@ -100,10 +115,12 @@ void DndFactoryTest::testPasteAllDayEvent2()
     QCOMPARE(newLength, originalLength);
     QCOMPARE(newDateTime, pastedEvent->dtStart());
     QCOMPARE(allDayEvent->summary(), pastedEvent->summary());
+#endif
 }
 
 void DndFactoryTest::testPasteTodo()
 {
+#if KCALENDARCORE_VERSION >= QT_VERSION_CHECK(6, 29, 0)
     const Todo::Ptr todo(new Todo());
     todo->setSummary(QStringLiteral("Summary 1"));
     todo->setDtDue(QDateTime(QDate(2010, 8, 9), {}));
@@ -111,7 +128,9 @@ void DndFactoryTest::testPasteTodo()
     Incidence::List incidencesToPaste;
     incidencesToPaste.append(todo);
 
-    QVERIFY(DndFactory::copyIncidences(incidencesToPaste));
+    auto mimeData = new QMimeData;
+    KCalendarCore::MimeData::populate(mimeData, incidencesToPaste);
+    qGuiApp->clipboard()->setMimeData(mimeData);
 
     const QDateTime newDateTime(QDate(2011, 1, 1), QTime(10, 10));
 
@@ -129,6 +148,7 @@ void DndFactoryTest::testPasteTodo()
 
     QCOMPARE(newDateTime, pastedTodo->dtDue());
     QCOMPARE(todo->summary(), pastedTodo->summary());
+#endif
 }
 
 #include "moc_testdndfactory.cpp"
diff --git a/src/dndfactory.cpp b/src/dndfactory.cpp
index 8e1e02746..8cad65046 100644
--- a/src/dndfactory.cpp
+++ b/src/dndfactory.cpp
@@ -163,42 +163,6 @@ Todo::Ptr DndFactory::createDropTodo(const QMimeData *mimeData)
 }
 #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;
-    const Incidence::List::ConstIterator end(incidences.constEnd());
-    for (it = incidences.constBegin(); it != end; ++it) {
-        if (*it) {
-            calendar->addIncidence(Incidence::Ptr((*it)->clone()));
-        }
-    }
-
-    auto mimeData = new QMimeData;
-
-    ICalDrag::populateMimeData(mimeData, calendar);
-
-    if (calendar->incidences().isEmpty()) {
-        return false;
-    } else {
-        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();
diff --git a/src/dndfactory.h b/src/dndfactory.h
index c96507ff8..0ba44d5a5 100644
--- a/src/dndfactory.h
+++ b/src/dndfactory.h
@@ -72,11 +72,6 @@ public:
     static KCalendarCore::Event::Ptr createDropEvent(const QMimeData *mimeData);
 #endif
 
-    /*!
-      Copies a list of \a incidences to the clipboard.
-    */
-    static bool copyIncidences(const KCalendarCore::Incidence::List &incidences);
-
     /*!
       This function clones the incidences that are in the clipboard and sets the clone's
       date/time to the specified \a newDateTime.
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.