[pim/kmail] src: Continue to move items (undo/redo)

Laurent Montel <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 90075217cf250a3f5f8fd4e41992d42a7a576d33 by Laurent Montel.
Committed on 27/07/2026 at 05:41.
Pushed by mlaurent into branch 'master'.

Continue to move items (undo/redo)

M  +10   -28   src/kmundoredomanager.cpp
M  +3    -3    src/kmundoredomanager.h

https://invent.kde.org/pim/kmail/-/commit/90075217cf250a3f5f8fd4e41992d42a7a576d33

diff --git a/src/kmundoredomanager.cpp b/src/kmundoredomanager.cpp
index 4b73de531..148c8de75 100644
--- a/src/kmundoredomanager.cpp
+++ b/src/kmundoredomanager.cpp
@@ -20,13 +20,10 @@ KMUndoRedoManager::KMUndoRedoManager(QObject *parent)
 
 KMUndoRedoManager::~KMUndoRedoManager() = default;
 
-void KMUndoRedoManager::moveItems()
+void KMUndoRedoManager::moveItems(const Akonadi::Item::List &items, const Akonadi::Collection &collection)
 {
-#if 0
-    auto job = new Akonadi::ItemMoveJob(mItems, mSrcFolder, nullptr);
+    auto job = new Akonadi::ItemMoveJob(items, collection, nullptr);
     connect(job, &Akonadi::ItemMoveJob::result, this, &KMUndoRedoManager::slotMoveResult);
-#endif
-    // TODO
 }
 
 void KMUndoRedoManager::slotMoveResult(KJob *job)
@@ -36,28 +33,17 @@ void KMUndoRedoManager::slotMoveResult(KJob *job)
     }
 }
 
-int KMUndoRedoManager::newUndoMoveAction(const Akonadi::Collection &srcFolder, const Akonadi::Collection &destFolder)
+QUndoCommand *KMUndoRedoManager::newUndoMoveAction(const Akonadi::Collection &srcFolder, const Akonadi::Collection &destFolder)
 {
     auto info = new KMUndoInfoMoveItems(this);
+    info->setSrcFolder(srcFolder);
+    info->setDestFolder(destFolder);
+    info->setMoveToTrash(destFolder == CommonKernel->trashCollectionFolder());
     mUndoStack->push(info);
-#if 0
-    info->id = ++mLastId;
-    info->srcFolder = srcFolder;
-    info->destFolder = destFolder;
-    info->moveToTrash = (destFolder == CommonKernel->trashCollectionFolder());
-    if (static_cast<int>(mStack.count()) == mSize) {
-        delete mStack.last();
-        mStack.removeLast();
-    }
-    mStack.prepend(info);
-    Q_EMIT undoStackChanged();
-    return info->id;
-#endif
-    // TODO
-    return -1;
+    return info;
 }
 
-void KMUndoRedoManager::addMsgToMoveAction(int undoId, const Akonadi::Item &item)
+void KMUndoRedoManager::addMsgToMoveAction(QUndoCommand *command, const Akonadi::Item &item)
 {
     // TODO push push()
     // TODO
@@ -71,16 +57,12 @@ KMUndoInfoMoveItems::KMUndoInfoMoveItems(KMUndoRedoManager *manager, QUndoComman
 
 void KMUndoInfoMoveItems::undo()
 {
-#if 0
-    auto job = new Akonadi::ItemMoveJob(mItems, mSrcFolder, nullptr);
-    connect(job, &Akonadi::ItemMoveJob::result, this, &KMUndoInfoMoveItems::slotMoveResult);
-#endif
-    // TODO
+    mManager->moveItems(mItems, mDestFolder);
 }
 
 void KMUndoInfoMoveItems::redo()
 {
-    // TODO
+    mManager->moveItems(mItems, mSrcFolder);
 }
 
 Akonadi::Item::List KMUndoInfoMoveItems::items() const
diff --git a/src/kmundoredomanager.h b/src/kmundoredomanager.h
index d7b2a5020..50c120e2b 100644
--- a/src/kmundoredomanager.h
+++ b/src/kmundoredomanager.h
@@ -19,10 +19,10 @@ public:
     explicit KMUndoRedoManager(QObject *parent = nullptr);
     ~KMUndoRedoManager() override;
 
-    [[nodiscard]] int newUndoMoveAction(const Akonadi::Collection &srcFolder, const Akonadi::Collection &destFolder);
-    void addMsgToMoveAction(int undoId, const Akonadi::Item &item);
+    [[nodiscard]] QUndoCommand *newUndoMoveAction(const Akonadi::Collection &srcFolder, const Akonadi::Collection &destFolder);
+    void addMsgToMoveAction(QUndoCommand *command, const Akonadi::Item &item);
 
-    void moveItems();
+    void moveItems(const Akonadi::Item::List &list, const Akonadi::Collection &collection);
     void slotMoveResult(KJob *job);
 
 private:
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.