File indexing completed on 2024-05-12 05:20:46
0001 /* 0002 This file is part of KMail 0003 0004 SPDX-FileCopyrightText: 1999 Waldo Bastian <bastian@kde.org> 0005 SPDX-FileCopyrightText: 2003 Zack Rusin <zack@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-only 0008 */ 0009 0010 #pragma once 0011 0012 #include "kmail_private_export.h" 0013 #include <Akonadi/Collection> 0014 #include <Akonadi/Item> 0015 #include <QList> 0016 #include <QObject> 0017 0018 class KJob; 0019 0020 namespace KMail 0021 { 0022 /** A class for storing Undo information. */ 0023 class UndoInfo 0024 { 0025 public: 0026 UndoInfo() = default; 0027 0028 int id = -1; 0029 Akonadi::Item::List items; 0030 Akonadi::Collection srcFolder; 0031 Akonadi::Collection destFolder; 0032 bool moveToTrash = false; 0033 }; 0034 0035 class KMAILTESTS_TESTS_EXPORT UndoStack : public QObject 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 explicit UndoStack(int size); 0041 ~UndoStack() override; 0042 0043 void clear(); 0044 [[nodiscard]] int size() const; 0045 [[nodiscard]] int newUndoAction(const Akonadi::Collection &srcFolder, const Akonadi::Collection &destFolder); 0046 void addMsgToAction(int undoId, const Akonadi::Item &item); 0047 [[nodiscard]] bool isEmpty() const; 0048 void undo(); 0049 0050 void pushSingleAction(const Akonadi::Item &item, const Akonadi::Collection &, const Akonadi::Collection &destFolder); 0051 void folderDestroyed(const Akonadi::Collection &folder); 0052 0053 [[nodiscard]] QString undoInfo() const; 0054 0055 Q_SIGNALS: 0056 void undoStackChanged(); 0057 0058 private: 0059 void slotMoveResult(KJob *); 0060 QList<UndoInfo *> mStack; 0061 const int mSize = 0; 0062 int mLastId = 0; 0063 UndoInfo *mCachedInfo = nullptr; 0064 }; 0065 }