kmail

undostack.h
00001 /*
00002     This file is part of KMail
00003 
00004     Copyright (C) 1999 Waldo Bastian (bastian@kde.org)
00005     Copyright (c) 2003 Zack Rusin <zack@kde.org>
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU General Public License
00009     version 2 as published by the Free Software Foundation.
00010 
00011     This software is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this library; see the file COPYING. If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef UNDOSTACK_H
00023 #define UNDOSTACK_H
00024 
00025 #include <tqptrlist.h>
00026 #include <tqstring.h>
00027 #include <tqobject.h>
00028 
00029 class KMFolder;
00030 class KMMsgBase;
00031 
00032 namespace KMail {
00033 
00035 class UndoInfo
00036 {
00037 public:
00038   int               id;
00039   TQValueList<ulong> serNums;
00040   KMFolder         *srcFolder;
00041   KMFolder         *destFolder;
00042 };
00043 
00044 class UndoStack : public TQObject
00045 {
00046   Q_OBJECT
00047   TQ_OBJECT
00048 
00049 public:
00050   UndoStack(int size);
00051 
00052   void clear();
00053   int  size() const { return mStack.count(); }
00054   int  newUndoAction( KMFolder* srcFolder, KMFolder* destFolder );
00055   void addMsgToAction( int undoId, ulong serNum );
00056   void undo();
00057 
00058   void pushSingleAction(ulong serNum, KMFolder *folder, KMFolder* destFolder);
00059   void msgDestroyed( KMMsgBase *msg);
00060   void folderDestroyed( KMFolder *folder);
00061 protected:
00062   TQPtrList<UndoInfo> mStack;
00063   int mSize;
00064   int mLastId;
00065   UndoInfo *mCachedInfo;
00066 
00067 signals:
00068    void undoStackChanged();
00069 };
00070 
00071 }
00072 
00073 #endif