Back to index

scribus-ng  1.3.4.dfsg+svn20071115
undostate.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /***************************************************************************
00008  *   Copyright (C) 2005 by Riku Leino                                      *
00009  *   riku@scribus.info                                                     *
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  *   This program is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00019  *   GNU General Public License for more details.                          *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU General Public License     *
00022  *   along with this program; if not, write to the                         *
00023  *   Free Software Foundation, Inc.,                                       *
00024  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00025  ***************************************************************************/
00026 
00027 #ifndef UNDOSTATE_H
00028 #define UNDOSTATE_H
00029 
00030 #include <qmap.h>
00031 #include "scribusapi.h"
00032 
00033 class QPixmap;
00034 class QString;
00035 class PageItem;
00036 class UndoObject;
00037 
00053 class SCRIBUS_API UndoState
00054 {
00055 public:
00063        UndoState(const QString& name, const QString& description = 0, QPixmap* pixmap = 0);
00064 
00065        virtual ~UndoState();
00066 
00071        virtual QString getName();
00072 
00077        virtual void setName(const QString &newName);
00078 
00083        virtual QString getDescription();
00084 
00089        virtual void setDescription(const QString &newDescription);
00090 
00095        virtual QPixmap* getPixmap();
00096 
00101        virtual void setPixmap(QPixmap *newPixmap);
00102 
00105        virtual void undo();
00108        virtual void redo();
00109 
00111        virtual void setUndoObject(UndoObject *object);
00113        virtual UndoObject* undoObject();
00114 
00115 private:
00117        QString actionName_;
00119        QString actionDescription_;
00121        QPixmap *actionPixmap_;
00123        UndoObject *undoObject_;
00124 };
00125 
00126 /*** SimpleState **************************************************************************/
00127 
00137 class SCRIBUS_API SimpleState : public UndoState
00138 {
00139 public:
00147        SimpleState(const QString& name, const QString& description = 0, QPixmap* pixmap = 0);
00148 
00149        virtual ~SimpleState();
00150 
00156        bool contains(const QString& key);
00157 
00170        QString get(const QString& key, const QString& def = "");
00171 
00187        int getInt(const QString& key, int def = 0);
00188 
00204        uint getUInt(const QString& key, uint def = 0);
00205 
00220        double getDouble(const QString& key, double def = 0.0);
00221 
00236        bool getBool(const QString& key, bool def = false);
00237 
00243        void set(const QString& key, const QString& value);
00244 
00250        void set(const QString& key, int value);
00251 
00257        void set(const QString& key, uint value);
00258 
00264        void set(const QString& key, double value);
00265 
00271        void set(const QString& key, bool value);
00272 
00273 private:
00275        QMap<QString, QString> values_;
00276 };
00277 
00278 /*** ItemState ***************************************************************************/
00279 
00280 template<class C>
00281 class ItemState : public SimpleState
00282 {
00283 public:
00284        ItemState(const QString& name, const QString& description = 0, QPixmap* pixmap = 0)
00285        : SimpleState(name, description, pixmap) {}
00286        ~ItemState() {}
00287        void setItem(const C &c) { item_ = c; }
00288        C getItem() const { return item_; }
00289 private:
00290        C item_;
00291 };
00292 
00293 #endif