• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kalarm

undo.h

Go to the documentation of this file.
00001 /*
00002  *  undo.h  -  undo/redo facility
00003  *  Program:  kalarm
00004  *  Copyright © 2005-2008 by David Jarvie <software@astrojar.org.uk>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program 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
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef UNDO_H
00022 #define UNDO_H
00023 
00026 #include <QList>
00027 #include <QStringList>
00028 #include "autodeletelist.h"
00029 
00030 class KAEvent;
00031 class AlarmResource;
00032 class UndoItem;
00033 
00034 
00035 class Undo : public QObject
00036 {
00037         Q_OBJECT
00038     public:
00039         enum Type { NONE, UNDO, REDO };
00040         // N.B. Event must be constructed before the action for which the
00041         // undo is being created is carried out, since the don't-show-errors
00042         // status is not contained within the KAEvent itself.
00043         struct Event
00044         {
00045             Event() {}
00046             Event(const KAEvent&, AlarmResource*);
00047             KAEvent        event;
00048             AlarmResource* resource;
00049             QStringList    dontShowErrors;
00050         };
00051         class EventList : public QList<Event>
00052         {
00053         public:
00054             void append(const KAEvent& e, AlarmResource* r)  { QList<Event>::append(Event(e, r)); }
00055         };
00056 
00057         static Undo*       instance();
00058         static void        saveAdd(const KAEvent&, AlarmResource*, const QString& name = QString());
00059         static void        saveAdds(const EventList&, const QString& name = QString());
00060         static void        saveEdit(const Event& oldEvent, const KAEvent& newEvent);
00061         static void        saveDelete(const Event&, const QString& name = QString());
00062         static void        saveDeletes(const EventList&, const QString& name = QString());
00063         static void        saveReactivate(const KAEvent&, AlarmResource*, const QString& name = QString());
00064         static void        saveReactivates(const EventList&, const QString& name = QString());
00065         static bool        undo(QWidget* parent, const QString& action)
00066                                               { return undo(0, UNDO, parent, action); }
00067         static bool        undo(int id, QWidget* parent, const QString& action)
00068                                               { return undo(findItem(id, UNDO), UNDO, parent, action); }
00069         static bool        redo(QWidget* parent, const QString& action)
00070                                               { return undo(0, REDO, parent, action); }
00071         static bool        redo(int id, QWidget* parent, const QString& action)
00072                                               { return undo(findItem(id, REDO), REDO, parent, action); }
00073         static void        clear();
00074         static bool        haveUndo()         { return !mUndoList.isEmpty(); }
00075         static bool        haveRedo()         { return !mRedoList.isEmpty(); }
00076         static QString     actionText(Type);
00077         static QString     actionText(Type, int id);
00078         static QString     description(Type, int id);
00079         static QList<int>  ids(Type);
00080         static void        emitChanged();
00081 
00082         // Types for use by UndoItem class and its descendants
00083         typedef AutoDeleteList<UndoItem> List;
00084 
00085     signals:
00086         void               changed(const QString& undo, const QString& redo);
00087 
00088     protected:
00089         // Methods for use by UndoItem class
00090         static void        add(UndoItem*, bool undo);
00091         static void        remove(UndoItem*, bool undo);
00092         static void        replace(UndoItem* old, UndoItem* New);
00093 
00094     private:
00095         Undo(QObject* parent)  : QObject(parent) { }
00096         static void        removeRedos(const QString& eventID);
00097         static bool        undo(int index, Type, QWidget* parent, const QString& action);
00098         static UndoItem*   getItem(int id, Type);
00099         static int         findItem(int id, Type);
00100         void               emitChanged(const QString& undo, const QString& redo)
00101                                            { emit changed(undo, redo); }
00102 
00103         static Undo*       mInstance;     // the one and only Undo instance
00104         static List        mUndoList;     // edit history for undo, latest undo first
00105         static List        mRedoList;     // edit history for redo, latest redo first
00106 
00107     friend class UndoItem;
00108 };
00109 
00110 #endif // UNDO_H

kalarm

Skip menu "kalarm"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal