F:/KPlato/koffice/libs/kofficecore/KoSetPropCommand.h

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2000 Werner Trobin <trobin@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KOGENCOMMAND_H
00021 #define KOGENCOMMAND_H
00022 
00023 #include <kcommand.h>
00024 
00029 template<class Property, class Object, void (Object::* Function) (Property)> class KoSetBasicPropCommand : public KNamedCommand {
00030 
00031 public:
00032     KoSetBasicPropCommand(Object *object, const QString &name) : KNamedCommand(name), m_object(object) {}
00033     KoSetBasicPropCommand(Object *object, const QString &name,
00034                const Property &oldProperty, const Property &newProperty) : KNamedCommand(name),
00035         m_object(object), m_oldProperty(oldProperty), m_newProperty(newProperty) {}
00036     virtual ~KoSetBasicPropCommand() {}
00037 
00038     virtual void execute() { if(m_object) (m_object->*Function)(m_newProperty); }
00039     virtual void unexecute() { if(m_object) (m_object->*Function)(m_oldProperty); }
00040 
00041     void setOldProperty(const Property &oldProperty) { m_oldProperty=oldProperty; }
00042     const Property &oldProperty() const { return m_oldProperty; }
00043     void setNewProperty(const Property &newProperty) { m_newProperty=newProperty; }
00044     const Property &newProperty() const { return m_newProperty; }
00045 
00046 private:
00047     // Don't copy or assign this stuff
00048     KoSetBasicPropCommand(const KoSetBasicPropCommand<Property, Object, Function> &rhs);
00049     KoSetBasicPropCommand &operator=(const KoSetBasicPropCommand<Property, Object, Function> &rhs);
00050 
00051     Object *m_object;
00052     Property m_oldProperty, m_newProperty;
00053 };
00054 
00059 template<class Property, class Object, void (Object::* Function) (const Property &)> class KoSetPropCommand : public KNamedCommand {
00060 
00061 public:
00062     KoSetPropCommand(Object *object, const QString &name) : KNamedCommand(name), m_object(object) {}
00063     KoSetPropCommand(Object *object, const QString &name,
00064                const Property &oldProperty, const Property &newProperty) : KNamedCommand(name),
00065         m_object(object), m_oldProperty(oldProperty), m_newProperty(newProperty) {}
00066     virtual ~KoSetPropCommand() {}
00067 
00068     virtual void execute() { if(m_object) (m_object->*Function)(m_newProperty); }
00069     virtual void unexecute() { if(m_object) (m_object->*Function)(m_oldProperty); }
00070 
00071     void setOldProperty(const Property &oldProperty) { m_oldProperty=oldProperty; }
00072     const Property &oldProperty() const { return m_oldProperty; }
00073     void setNewProperty(const Property &newProperty) { m_newProperty=newProperty; }
00074     const Property &newProperty() const { return m_newProperty; }
00075 
00076 private:
00077     // Don't copy or assign this stuff
00078     KoSetPropCommand(const KoSetPropCommand<Property, Object, Function> &rhs);
00079     KoSetPropCommand &operator=(const KoSetPropCommand<Property, Object, Function> &rhs);
00080 
00081     Object *m_object;
00082     Property m_oldProperty, m_newProperty;
00083 };
00084 
00085 #endif /* KOGENCOMMAND_H */
00086 

Généré le Wed Nov 22 23:41:04 2006 pour KPlato par  doxygen 1.5.1-p1