[pim/kmail] src: Fix undo/redo
Laurent Montel <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 32c42eaea7d17013024cb2d78cafaf641637648d by Laurent Montel.
Committed on 27/07/2026 at 11:38.
Pushed by mlaurent into branch 'master'.
Fix undo/redo
M +6 -4 src/kmcommands.cpp
M +2 -3 src/kmundoredomanager.cpp
https://invent.kde.org/pim/kmail/-/commit/32c42eaea7d17013024cb2d78cafaf641637648d
diff --git a/src/kmcommands.cpp b/src/kmcommands.cpp
index d5aadac04..6434b821d 100644
--- a/src/kmcommands.cpp
+++ b/src/kmcommands.cpp
@@ -1633,10 +1633,6 @@ KMCommand::Result KMTrashMsgCommand::execute()
for (auto trashIt = mTrashFolders.begin(), end = mTrashFolders.end(); trashIt != end; ++trashIt) {
const auto trash = trashIt.key();
if (trash.isValid()) {
- auto job = new Akonadi::ItemMoveJob(*trashIt, trash, this);
- connect(job, &KIO::Job::result, this, &KMTrashMsgCommand::slotMoveResult);
- mPendingMoves.push_back(job);
-
// group by source folder for undo
std::sort(trashIt->begin(), trashIt->end(), [](const Akonadi::Item &lhs, const Akonadi::Item &rhs) {
return lhs.storageCollectionId() < rhs.storageCollectionId();
@@ -1649,10 +1645,16 @@ KMCommand::Result KMTrashMsgCommand::execute()
}
if (parent.id() != item.storageCollectionId()) {
parent = Akonadi::Collection(item.storageCollectionId());
+ if (command) {
+ kmkernel->undoRedoManager()->undoStack()->push(command);
+ }
command = kmkernel->undoRedoManager()->newUndoMoveAction(parent, trash);
}
kmkernel->undoRedoManager()->addMsgToMoveAction(command, item);
}
+ if (command) {
+ kmkernel->undoRedoManager()->undoStack()->push(command);
+ }
} else {
auto job = new Akonadi::ItemDeleteJob(*trashIt, this);
connect(job, &KIO::Job::result, this, &KMTrashMsgCommand::slotDeleteResult);
diff --git a/src/kmundoredomanager.cpp b/src/kmundoredomanager.cpp
index a28a8ab70..445d295f0 100644
--- a/src/kmundoredomanager.cpp
+++ b/src/kmundoredomanager.cpp
@@ -44,7 +44,6 @@ QUndoCommand *KMUndoRedoManager::newUndoMoveAction(const Akonadi::Collection &sr
info->setSrcFolder(srcFolder);
info->setDestFolder(destFolder);
info->setMoveToTrash(destFolder == CommonKernel->trashCollectionFolder());
- mUndoStack->push(info);
return info;
}
@@ -64,12 +63,12 @@ KMUndoInfoMoveItems::KMUndoInfoMoveItems(KMUndoRedoManager *manager, QUndoComman
void KMUndoInfoMoveItems::undo()
{
- mManager->moveItems(mItems, mDestFolder);
+ mManager->moveItems(mItems, mSrcFolder);
}
void KMUndoInfoMoveItems::redo()
{
- mManager->moveItems(mItems, mSrcFolder);
+ mManager->moveItems(mItems, mDestFolder);
}
Akonadi::Item::List KMUndoInfoMoveItems::items() const