kaddressbook Library API Documentation

undo.h

00001 /*
00002     This file is part of KAddressBook.
00003     Copyright (C) 1999 Don Sanders <sanders@kde.org>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 
00019     As a special exception, permission is given to link this program
00020     with any edition of Qt, and distribute the resulting executable,
00021     without including the source code for Qt in the source distribution.
00022 */
00023 
00024 #ifndef UNDO_H
00025 #define UNDO_H
00026 
00027 #include <qobject.h>
00028 #include <qptrstack.h>
00029 #include <qstring.h>
00030 
00031 #include <kabc/addressbook.h>
00032 
00033 #include "kablock.h"
00034 
00035 class Command
00036 {
00037   public:
00038     Command( KABC::AddressBook *addressBook ) { mAddressBook = addressBook; }
00039     virtual ~Command() {};
00040 
00041     virtual QString name() = 0;
00042     virtual bool redo() = 0;
00043     virtual bool undo() = 0;
00044 
00045   protected:
00046     KABC::AddressBook *addressBook() const { return mAddressBook; }
00047     KABLock *lock() const { return KABLock::self( mAddressBook ); }
00048 
00049   private:
00050     KABC::AddressBook *mAddressBook;
00051 };
00052 
00061 class StackBase : public QObject
00062 {
00063   Q_OBJECT
00064 
00065   public:
00066     StackBase() : QObject() {}
00067 
00068     void push( Command *c );
00069     bool isEmpty();
00070     Command *top();
00071     void clear();
00072 
00073   signals:
00074     void changed();
00075 
00076   protected:
00081     Command *pop();
00082     
00083     QPtrStack<Command> mCommandStack;
00084 };
00085 
00086 class UndoStack : public StackBase
00087 {
00088   public:
00089     static UndoStack *instance();
00090     void undo();
00091 
00092   protected:
00093     UndoStack();
00094     static UndoStack* instance_;
00095 };
00096 
00097 class RedoStack : public StackBase
00098 {
00099   public:
00100     static RedoStack *instance();
00101     void redo();
00102 
00103   protected:
00104     RedoStack();
00105     static RedoStack* instance_;
00106 };
00107 
00108 #endif
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:38:53 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003