/usr/include/scribus/undostate.h is in scribus-dev 1.4.6+dfsg-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | /*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
/***************************************************************************
* Copyright (C) 2005 by Riku Leino *
* riku@scribus.info *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef UNDOSTATE_H
#define UNDOSTATE_H
#include <QMap>
#include <QPixmap>
#include <QVariant>
#include "scribusapi.h"
#include "undoobject.h"
class QString;
class PageItem;
/**
* @brief UndoState describes an undoable state (action).
*
* Undoable objects implement undo/redo by sending and receiving UndoState
* subclasses. This means that they will need to produce some sort of information
* for the UndoState subclass (if no suitable subclass exists it must be also
* created) and later they will need to be able to restore the state described
* by the subclass to apply undo/redo.
*
* UndoManager will handle the deletion of UndoState objects.
*
* @sa SimpleState
* @author Riku Leino riku@scribus.info
* @date December 2004
*/
class SCRIBUS_API UndoState
{
public:
/**
* @brief Creates a new UndoState instance.
* @param name Name of the state (action). Will be used when describing the
* state in UndoGui subclasses.
* @param description Description of the state (action)
* @param pixmap Pointer to an icon describing the action visually.
*/
UndoState(const QString& name, const QString& description = 0, QPixmap* pixmap = 0);
virtual ~UndoState();
/**
* @brief Returns name of the state (action).
* @return name of the state
*/
virtual QString getName();
/**
* @brief Set the name for this UndoState.
* @param newName name for this UndoState
*/
virtual void setName(const QString &newName);
/**
* @brief Returns description of the state.
* @return description of the state
*/
virtual QString getDescription();
/**
* @brief Set the description for this UndoState
* @param newDescription description for this UndoState
*/
virtual void setDescription(const QString &newDescription);
/**
* @brief Returns a pointer to the icon attached to the state.
* @return A pointer to the icon attached to the state
*/
virtual QPixmap* getPixmap();
/**
* @brief Set the icon for this UndoState.
* @param newPixmap icon for this UndoState
*/
virtual void setPixmap(QPixmap *newPixmap);
/** @brief undo the state described by this UndoState,
* @brief requires related UndoObject */
virtual void undo();
/** @brief redo the state described by this UndoState,
* @brief requires the related UndoObject */
virtual void redo();
/** @brief Set the UndoObject this state belongs to */
virtual void setUndoObject(UndoObject *object);
/** @brief return the UndoObject this state belongs to */
virtual UndoObject* undoObject();
int transactionCode;
private:
/** @brief Name of the state (operation) (f.e. Move object) */
QString actionName_;
/** @brief Detailed description of the state (operation). */
QString actionDescription_;
/** @brief Icon related to the state (operation) */
QPixmap *actionPixmap_;
/** @brief UndoObject this state belongs to */
UndoObjectPtr undoObject_;
};
/*** SimpleState **************************************************************************/
/**
* @brief SimpleState provides a simple implementation of the UndoState.
*
* SimpleState uses a <code>QMap</code> to store key-value pairs that can be queried and
* set using it's get() and set() methods.
*
* @author Riku Leino tsoots@gmail.com
* @date December 2004
*/
class SCRIBUS_API SimpleState : public UndoState
{
public:
/**
* @brief Creates a new SimpleState instance.
* @param name Name of the state (action). Will be used when describing the
* state in UndoGui subclasses.
* @param description Description of the state (action)
* @param pixmap Pointer to an icon describing the state (action) visually.
*/
SimpleState(const QString& name, const QString& description = 0, QPixmap* pixmap = 0);
virtual ~SimpleState();
/**
* @brief Returns true if parameter key exists in the map.
* @param key Key that is searched from the map
* @return true if parameter key exists in the map if not false
*/
bool contains(const QString& key);
/**
* @brief Returns the QString value attached to the key.
*
* If key is not found from the map it will be added there with the
* value given as a parameter def. In such case <code>def</code> will also
* be returned.
* @param key Key that is searched from the map
* @param def Default value to be used if key is not found from the map
* @return Value attached to the key in the map. If the key is not found
* from the map it will be added with the value described in the param
* <code>def</code> which is then returned.
*/
QString get(const QString& key, const QString& def = "");
/**
* @brief Returns the int value attached to the key.
*
* Values are stored as <code>QString</code>s in the map and when queried
* with this method value attached to the key is converted to an int. If
* the conversion fails value of the parameter <code>def</code> will be returned.
* If key is not found from the map it will be added there with the
* value given as a parameter <code>def</code>. In such case <code>def</code>
* will also be returned.
* @param key Key that is searched from the map
* @param def Default value to be used if key is not found from the map
* @return <code>int</code> value attached to the key in the map. If the key is not found
* from the map it will be added with the value described in the param
* <code>def</code> which is then returned.
*/
int getInt(const QString& key, int def = 0);
/**
* @brief Returns the uint value attached to the key.
*
* Values are stored as <code>QString</code>s in the map and when queried
* with this method value attached to the key is converted to an int. If
* the conversion fails value of the parameter <code>def</code> will be returned.
* If key is not found from the map it will be added there with the
* value given as a parameter <code>def</code>. In such case <code>def</code>
* will also be returned.
* @param key Key that is searched from the map
* @param def Default value to be used if key is not found from the map
* @return <code>uint</code> value attached to the key in the map. If the key is not found
* from the map it will be added with the value described in the param
* <code>def</code> which is then returned.
*/
uint getUInt(const QString& key, uint def = 0);
/**
* @brief Returns the double value attached to the key.
*
* Values are stored as <code>QString</code>s in the map and when queried
* with this method value attached to the key is converted to a double. If
* the conversion fails value of the parameter <code>def</code> will be returned.
* If key is not found from the map it will be added there with the
* value given as a parameter def. In such case <code>def</code> will also be returned.
* @param key Key that is searched from the map
* @param def Default value to be used if key is not found from the map
* @return <code>Double</code> value attached to the key in the map. If the key is not found
* from the map it will be added with the value described in the parameter
* <code>def</code> which is then returned.
*/
double getDouble(const QString& key, double def = 0.0);
/**
* @brief Returns the boolean value attached to the key.
*
* Values are stored as <code>QString</code>s in the map and when queried
* with this method value attached to the key is converted to a bool. If
* the conversion fails value of the parameter <code>def</code> will be returned.
* If key is not found from the map it will be added there with the
* value given as a parameter def. In such case <code>def</code> will also be returned.
* @param key Key that is searched from the map
* @param def Default value to be used if key is not found from the map
* @return <code>Bool</code> value attached to the key in the map. If the key is not found
* from the map it will be added with the value described in the parameter
* <code>def</code> which is then returned.
*/
bool getBool(const QString& key, bool def = false);
/**
* @brief Set a value for the key.
* @param key Key that can be later used to query the value.
* @param value Value attached to the key.
*/
void set(const QString& key, const QString& value);
/**
* @brief Set a value for the key.
* @param key Key that can be later used to query the value.
* @param value Value attached to the key.
*/
void set(const QString& key, int value);
/**
* @brief Set a value for the key.
* @param key Key that can be later used to query the value.
* @param value Value attached to the key.
*/
void set(const QString& key, uint value);
/**
* @brief Set a value for the key.
* @param key Key that can be later used to query the value.
* @param value Value attached to the key.
*/
void set(const QString& key, double value);
/**
* @brief Set a value for the key.
* @param key Key that can be later used to query the value.
* @param value Value attached to the key.
*/
void set(const QString& key, bool value);
private:
/** @brief QMap to store key-value pairs */
QMap<QString, QVariant> values_;
QVariant variant(const QString& key, const QVariant& def);
};
/*** ItemState ***************************************************************************/
template<class C>
class ItemState : public SimpleState
{
public:
ItemState(const QString& name, const QString& description = 0, QPixmap* pixmap = 0)
: SimpleState(name, description, pixmap) {}
~ItemState() {}
void setItem(const C &c) { item_ = c; }
C getItem() const { return item_; }
private:
C item_;
};
#endif
|