Subversion Repositories Scribus

Rev

Rev 6139 | Rev 6266 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
1111 tsoots 7
/***************************************************************************
8
 *   Copyright (C) 2005 by Riku Leino                                      *
5116 tsoots 9
 *   riku@scribus.info                                                     *
1111 tsoots 10
 *                                                                         *
11
 *   This program is free software; you can redistribute it and/or modify  *
12
 *   it under the terms of the GNU General Public License as published by  *
13
 *   the Free Software Foundation; either version 2 of the License, or     *
14
 *   (at your option) any later version.                                   *
15
 *                                                                         *
16
 *   This program is distributed in the hope that it will be useful,       *
17
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
18
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
19
 *   GNU General Public License for more details.                          *
20
 *                                                                         *
21
 *   You should have received a copy of the GNU General Public License     *
22
 *   along with this program; if not, write to the                         *
23
 *   Free Software Foundation, Inc.,                                       *
24
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
25
 ***************************************************************************/
26
 
27
#ifndef UNDOMANAGER_H
28
#define UNDOMANAGER_H
29
 
30
#include <vector>
31
#include <utility>
32
#include <qobject.h>
2969 craig 33
 
34
#include "scribusapi.h"
1111 tsoots 35
#include "undostate.h"
36
#include "undoobject.h"
5215 mrdocs 37
#include "undostack.h"
1111 tsoots 38
 
5116 tsoots 39
class QString;
40
class QPixmap;
1142 tsoots 41
class UndoGui;
1197 tsoots 42
class PrefsContext;
1142 tsoots 43
 
5116 tsoots 44
/** @brief Key is the doc name, value is it's undo stack */
45
typedef QMap<QString, UndoStack> StackMap;
1111 tsoots 46
 
47
/**
5116 tsoots 48
 * @brief TransactionState provides a container where multiple UndoStates can be stored
49
 * @brief as a single action which then appears in the attached <code>UndoGui</code>s.
50
 * @author Riku Leino riku@scribus.info
51
 * @date January 2005
52
 */
53
class TransactionState : public UndoState
54
{
55
public:
56
        /** @brief Creates a new TransactionState instance */
57
        TransactionState();
58
        /** @brief Destroys the TransactionState instance */
59
        ~TransactionState();
60
        /**
61
         * @brief Add a new <code>UndoState</code> object to the transaction.
62
         * @param state state to be added to the transaction
63
         */
64
        void pushBack(UndoObject *target, UndoState *state);
65
        /**
66
         * @brief Returns the count of the <code>UndoState</code> objects in this transaction.
67
         * @return count of the <code>UndoState</code> objects in this transaction
68
         */
69
        uint sizet();
70
        /** @brief Use the name from last action added to this <code>TransactionState</code> */
71
        void useActionName();
72
        /**
73
         * @brief Returns an <code>UndoState</code> object at <code>index</code>.
74
         * @param index index from where an <code>UndoState</code> object is returned.
75
         * If <code>index</code> is out of scope <code>NULL</code> will be rerturned.
76
         * @return <code>UndoState</code> object from <code>index</code> or <code>NULL</code>
77
         * if <code>index</code> is out of scope.
78
         */
79
        UndoState* at(int index);
80
        /**
81
         * @brief Returns true if this transaction contains UndoObject with the id <code>uid</code>
82
         * @brief otherwise returns false.
83
         * @return true if this transaction contains UndoObject with the ide <code>uid</code>
84
         * @return otherwise returns false.
85
         */
86
        bool contains(int uid) const;
87
 
88
        /**
89
         * @brief Tells if this transaction contains only UndoObject with ID uid
90
         *
91
         * If a transaction contains only single UndoObject it will be safe to include
92
         * it in the object specific undo.
93
         * @param uid UndoObject's id to look for
94
         * @return true if this transaction only contains actions of the UndoObject whose
95
         *         id is uid
96
         */
97
        bool containsOnly(int uid) const;
98
        /**
99
         * @brief Replace object with id uid with new UndoObject newUndoObject.
100
         * @param uid id of the object that is wanted to be replaced
101
         * @param newUndoObject object that is used for replacing
102
         * @return UndoObject which was replaced
103
         */
104
        UndoObject* replace(ulong uid, UndoObject *newUndoObject);
105
 
106
        /** @brief undo all UndoStates in this transaction */
107
        void undo();
108
        /** @brief redo all UndoStates in this transaction */
109
        void redo();
110
private:
111
        /** @brief Number of undo states stored in this transaction */
112
        uint size_;
113
        /** @brief vector to keep the states in */
114
        std::vector<UndoState*> states_;
115
};
116
 
117
/**
1111 tsoots 118
 * @brief UndoManager handles the undo stack.
119
 *
120
 * UndoManager is the engine of the undo/redo handling. When ever an undoable
121
 * action happens an UndoState object will be sent to the UndoManager which then
1477 tsoots 122
 * stores the state in the undo stack. When an undo is requested the state is
1111 tsoots 123
 * send back to it's creator which is then responsible for doing the actual undo or
124
 * redo.
125
 *
126
 * UndoManager also handles the UndoGuis by linking them together and reporting
127
 * all undo/redo actions to the guis for them to update the visual representation.
128
 * For this to work all UndoGuis need to be registered to the UndoManager with the
129
 * registerGui() method.
130
 *
131
 * @author Riku Leino tsoots@gmail.com
132
 * @date December 2004
133
 */
2969 craig 134
class SCRIBUS_API UndoManager : public QObject
1111 tsoots 135
{
136
        Q_OBJECT
137
public:
1477 tsoots 138
        /** @brief Marks for a global undo mode where ever UndoOjbect id is requested. */
139
        static const int GLOBAL_UNDO_MODE = -1;
5116 tsoots 140
 
1111 tsoots 141
        /**
1485 tsoots 142
         * @brief When object specific mode is requested but no suitable object is selected
143
         * @brief this can be passed to showObject() to clear the undo stack representations.
144
         */
145
        static const int NO_UNDO_STACK = -2;
5116 tsoots 146
 
1485 tsoots 147
        /**
1111 tsoots 148
         * @brief Returns a pointer to the UndoManager instance
149
         * @return A pointer to the UndoManager instance
150
         */
151
        static UndoManager* instance();
5116 tsoots 152
 
1111 tsoots 153
        /**
154
         * @brief Deletes the UndoManager Instance
155
         *
156
         * Must be called when UndoManager is no more needed.
157
         */
158
        static void deleteInstance();
5116 tsoots 159
 
1111 tsoots 160
        /**
161
         * @brief Sets the undo action tracking enabled or disabled.
162
         * @param isEnabled If true undo stack is updated with the states sent
163
         * to the UndoManager else undo stack is not updated and attached UndoGuis
164
         * are not informed of the actions.
165
         */
166
        void setUndoEnabled(bool isEnabled);
5116 tsoots 167
 
1111 tsoots 168
        /**
169
         * @brief Returns true if undo actions are stored, if not will return false.
170
         * @return true if undo actions are stored, if not will return false
171
         */
172
        static bool undoEnabled();
5116 tsoots 173
 
1111 tsoots 174
        /**
1477 tsoots 175
         * @brief Start a transaction.
1213 tsoots 176
         *
177
         * After this method has been invoked <code>UndoManager</code> will switch to the
1477 tsoots 178
     * transaction (silent) mode where it does not report actions to the attached
1357 tsoots 179
         * <code>UndoGui</code> widgets but stores all incoming <code>UndoState</code> objects into
1213 tsoots 180
         * the transaction container which after call to the method commit() will be sent
181
         * to the guis as a single undo action. Transaction can be named when starting it or
182
         * naming can be done when commiting it.
183
         * @param targetName name for the target of this transaction (f.e. "Selection")
1262 tsoots 184
         * @param targetPixmap Icon for the target on which this transaction works.
185
         * this icon will be drawn first when the action is presented in Action History
186
         * window and icon for the action will be drawn over this one.
1213 tsoots 187
         * @param name name for the transaction (f.e. "Move" would make with the above
188
         * "Move Selection")
189
         * @param description description for the transaction
1250 tsoots 190
         * @param actionPixmap icon for the action performed by the transaction
1213 tsoots 191
         * @sa commit()
192
         */
193
        void beginTransaction(const QString &targetName = "",
5116 tsoots 194
                              QPixmap *targetPixmap = 0,
195
                              const QString &actionName = "",
196
                              const QString &description = "",
197
                              QPixmap *actionPixmap = 0);
198
 
1477 tsoots 199
        /**
1213 tsoots 200
         * @brief Cancels the current transaction and deletes groupped <code>UndoState</code>s.
201
         * @brief Nothing from canceled transaction will be sent to the undo gui widgets.
202
         */
203
        void cancelTransaction();
5116 tsoots 204
 
1477 tsoots 205
        /**
1213 tsoots 206
         * @brief Commit the current transaction.
207
         *
208
         * Current transaction will be commited and <code>UndoManager</code> will be switched
1477 tsoots 209
         * to the normal mode. Commited transaction will be sent to the attached undo gui
1213 tsoots 210
         * widgets and it will show up there as a single undo action. Details used as a parameter
211
         * will be details shown in the gui widgets.
212
         * @param targetName name for the target of this transaction (f.e. "Selection")
1262 tsoots 213
         * @param targetPixmap Icon for the target on which this transaction works.
214
         * this icon will be drawn first when the action is presented in Action History
215
         * window and icon for the action will be drawn over this one.
1213 tsoots 216
         * @param name name for the action
217
         * @param description description for the action
1250 tsoots 218
         * @param actionPixmap icon for the action performed by the transaction
1213 tsoots 219
         * @sa beginTransaction()
220
         */
221
        void commit(const QString &targetName = "",
5116 tsoots 222
                    QPixmap *targetPixmap = 0,
223
                    const QString &name = "",
224
                    const QString &description = "",
225
                    QPixmap *actionPixmap = 0);
226
 
1213 tsoots 227
        /**
228
         * @brief Returns true if in transaction mode if not will return false.
229
         * @return true if in transaction mode if not will return false
230
         */
231
        bool isTransactionMode();
5116 tsoots 232
 
1213 tsoots 233
        /**
1111 tsoots 234
         * @brief Register an UndoGui to the UndoManager.
235
         *
236
         * After registering a gui to the manager the gui will be updated with the
237
         * undo action information received by the UndoManager. Actions done with the
238
         * UndoGui to be registered are also handled after registering.
239
         * @param gui A pointer to the UndoGui that is wanted to be registered.
240
         */
241
        void registerGui(UndoGui* gui);
5116 tsoots 242
 
1111 tsoots 243
        /**
244
         * @brief Removes an UndoGui from UndoManager.
245
         * @param gui UndoGui to be removed from the UndoManager.
246
         */
247
        void removeGui(UndoGui* gui);
5116 tsoots 248
 
1111 tsoots 249
        /**
250
         * @brief Changes the active undo stack.
251
         *
252
         * Sets the stack connected to the name <code>stackName</code> active. Calling
253
         * this method will send clear() signal to the attached <code>UndoGui</code>s and
254
         * will update their undo stack representations.
255
         * @param stackName Name of the stack to be used
256
         */
257
        void switchStack(const QString& stackName);
5116 tsoots 258
 
1111 tsoots 259
        /**
260
         * @brief Rename the current stack
261
         * @param newName New name for the current stack.
262
         */
1252 tsoots 263
        void renameStack(const QString& newName);
5116 tsoots 264
 
1111 tsoots 265
        /**
266
         * @brief Remove the stack with the name <code>stackName</code>
267
         * @param stackName Name of the stack that is wanted to be removed
268
         */
1252 tsoots 269
        void removeStack(const QString& stackName);
5938 tsoots 270
 
271
        /** clear the current undo stack */
272
        void clearStack();
273
 
1111 tsoots 274
        /**
275
         * @brief Returns true if there are actions that can be undone otherwise returns false.
276
         *
277
         * This is useful when undo/redo actions are handled with a gui that is not attached to
278
         * the UndoManager (f.e. menu items) and when those gui items are wanted to set enabled
279
         * or disabled depending on the status of the undo stack.
280
         * @return true if there are actions that can be undone otherwise returns false
281
         */
1443 tsoots 282
        bool hasUndoActions(int uid = -1);
5116 tsoots 283
 
1111 tsoots 284
        /**
285
         * @brief Returns true if there are actions that can be redone otherwise returns false.
286
         * @return true if there are actions that can be redone otherwise returns false
287
         * @sa UndoManager::hasUndoActions()
288
         */
1443 tsoots 289
        bool hasRedoActions(int uid = -1);
5116 tsoots 290
 
1111 tsoots 291
        /**
1238 tsoots 292
         * @brief Replace an UndoObject with the id uid with a new UndoObject new.
293
         * @param uid Id for the UndoObject that is wanted to be replaced.
294
         * @param newUndoObject UndoObject which will replace an old UndoObject in the stack.
1658 tsoots 295
         * @return UndoObject which was replaced
1238 tsoots 296
         */
1658 tsoots 297
        UndoObject* replaceObject(ulong uid, UndoObject *newUndoObject);
5116 tsoots 298
 
1238 tsoots 299
        /**
1111 tsoots 300
         * @brief Returns the maximum length of the undostack.
301
         * @return the maximum length of the undostack
302
         */
303
        int getHistoryLength();
5938 tsoots 304
 
1477 tsoots 305
        /**
1461 tsoots 306
         * @brief Returns true if in global mode and false if in object specific mode.
307
         * @return true if in global mode and false if in object specific mode
308
         */
309
        bool isGlobalMode();
310
 
5116 tsoots 311
private:
312
 
313
/*** UndoManager::TransactionObject ***************************************************/
314
 
1199 tsoots 315
        /**
5116 tsoots 316
         * @brief Dummy subclass of <code>UndoObject</code> which is used for holding the name
317
         * @brief for the transaction's target object(group) (f.e "Selection", "Group", "Script"...).
318
         * @author Riku Leino tsoots@gmail.com
319
         * @date January 2005
320
         */
321
        class TransactionObject : public UndoObject
322
        {
323
        public:
324
                TransactionObject() {};
325
                virtual ~TransactionObject() {};
326
                void restore(UndoState*, bool) {};
327
        };
328
 
329
/**************************************************************************************/
330
 
331
        /**
332
         * @brief The only instance of UndoManager available.
333
         *
334
         * UndoManager is singleton and the instance can be queried with the method
335
         * instance().
336
         */
337
        static UndoManager* instance_;
338
 
339
        /** @brief Should undo states be stored or ignored */
340
        static bool undoEnabled_;
341
 
342
        /**
343
         * @brief Tracks the state of _undoEnabled.
344
         *
345
         * This value is increased whenever setUndoEnabled(true) is called and decreased
346
         * when setUndoEnabled(false) is called. This means _undoEnabled == true when this
347
         * value is 0 and when its above zero _undoEnabled == false. Counting setUndoEnabled()
348
         * calls this way guarantees that undo is not enabled accidentally calling
349
         * setUndoEnabled(true) even it has been set false before this false-true pair touched it.
350
         */
351
        static int undoEnabledCounter_;
352
 
353
        PrefsContext *prefs_;
354
 
355
        /** @brief Doc to which the currently active stack belongs */
356
        QString currentDoc_;
357
 
358
        /**
359
         * @brief Id number of the object for what the object specific undo is shown
360
         * @brief or -1 if global undo is used.
361
         */
362
        int currentUndoObjectId_;
363
 
364
        /**
365
         * @brief Stores the transactions which are currently started but not
366
         * @brief canceled or commited.
367
         */
368
        std::vector<std::pair<TransactionObject*, TransactionState*> > transactions_;
369
 
370
        /**
371
         * @brief If in transaction mode this is the container for incoming <code>UndoState</code>
372
         * @brief objects.
373
         *
374
         * It is also used to detect if we are in the transaction mode. When it is <code>NULL</code>
375
         * normal mode is on.
376
         */
377
        TransactionState *transaction_;
378
 
379
        /** @brief Dummy object for storing transaction target's name */
380
        TransactionObject *transactionTarget_;
381
 
382
        /**
383
         * @brief UndoGuis attached to this UndoManager
384
         * @sa UndoGui
385
         * @sa UndoWidget
386
         * @sa UndoPalette
387
         */
388
        std::vector<UndoGui*> undoGuis_;
389
 
390
        /**
391
         * @brief Undo stacks for all open document
392
         *
393
         * Whenever current stack is used it's referred with <code>stacks_[currentDoc_]</code>
394
         */
395
        StackMap stacks_;
396
 
397
        /**
398
         * @brief Initializes the UndoGui.
399
         * @param gui UndoGui to be initialized
400
         * @param uid UndoObject's id if in object specific mode or -1 to tell
401
         * that global undo is used.
402
         */
403
        void setState(UndoGui* gui, int uid = -1);
404
 
405
        /**
406
         * @brief Disconnect all attached UndoGui instances from signals provided by this
407
         * @brief class and other UndoGui objects.
408
         */
409
        void connectGuis();
410
        /**
411
         * @brief Connect all attached UndoGui instances to signals provided by this
412
         * @brief class and other UndoGui objects.
413
         */
414
        void disconnectGuis();
415
        /**
416
         * @brief Load icons needed for Action History window.
417
         */
418
        void initIcons();
419
 
420
        void setMenuTexts();
421
 
422
public:
423
 
424
        /**
1190 tsoots 425
        * @name Action strings
426
        * Strings describing undo actions
427
        */
428
        /*@{*/
2199 cbradney 429
        static QString AddVGuide;
430
        static QString AddHGuide;
431
        static QString DelVGuide;
432
        static QString DelHGuide;
433
        static QString MoveVGuide;
434
        static QString MoveHGuide;
435
        static QString LockGuides;
436
        static QString UnlockGuides;
437
        static QString Move;
438
        static QString Resize;
439
        static QString Rotate;
440
        static QString MoveFromTo;
441
        static QString ResizeFromTo;
4821 cbradney 442
        static QString ImageOffset;
443
        static QString ImageScale;
444
        static QString ImageOffsetFromTo;
445
        static QString ImageScaleFromTo;
2199 cbradney 446
        static QString Selection;
447
        static QString Group;
448
        static QString SelectionGroup;
449
        static QString Create;
450
        static QString CreateTo;
451
        static QString AlignDistribute;
452
        static QString ItemsInvolved;
453
        static QString Cancel;
454
        static QString SetFill;
455
        static QString ColorFromTo;
456
        static QString SetShade;
457
        static QString SetLineColor;
458
        static QString SetLineShade;
459
        static QString FlipH;
460
        static QString FlipV;
461
        static QString Lock;
462
        static QString UnLock;
463
        static QString SizeLock;
464
        static QString SizeUnLock;
4698 cbradney 465
        static QString EnablePrint;
466
        static QString DisablePrint;
2199 cbradney 467
        static QString Ungroup;
468
        static QString Delete;
469
        static QString Rename;
470
        static QString FromTo;
471
        static QString ApplyMasterPage;
472
        static QString Paste;
473
        static QString Cut;
474
        static QString Transparency;
475
        static QString LineTransparency;
476
        static QString LineStyle;
477
        static QString LineEnd;
478
        static QString LineJoin;
479
        static QString LineWidth;
480
        static QString NoStyle;
481
        static QString CustomLineStyle;
482
        static QString NoLineStyle;
483
        static QString StartArrow;
484
        static QString EndArrow;
485
        static QString CreateTable;
486
        static QString RowsCols;
487
        static QString SetFont;
488
        static QString SetFontSize;
489
        static QString SetFontWidth;
2230 fschmid 490
        static QString SetFontHeight;
2199 cbradney 491
        static QString SetFontFill;
492
        static QString SetFontStroke;
493
        static QString SetFontFillShade;
494
        static QString SetFontStrokeShade;
495
        static QString SetKerning;
496
        static QString SetLineSpacing;
497
        static QString SetStyle;
498
        static QString SetLanguage;
499
        static QString AlignText;
500
        static QString SetFontEffect;
501
        static QString ImageFrame;
502
        static QString TextFrame;
503
        static QString Polygon;
504
        static QString BezierCurve;
505
        static QString Polyline;
3676 cbradney 506
        static QString PathText;
2199 cbradney 507
        static QString ConvertTo;
508
        static QString ImportSVG;
509
        static QString ImportEPS;
510
        static QString ImportOOoDraw;
511
        static QString ScratchSpace;
5620 jghali 512
        //static QString TextFlow;
513
        static QString ObjectFrame;
2199 cbradney 514
        static QString BoundingBox;
515
        static QString ContourLine;
516
        static QString NoTextFlow;
5620 jghali 517
        static QString NoObjectFrame;
2199 cbradney 518
        static QString NoBoundingBox;
519
        static QString NoContourLine;
520
        static QString PageNmbr;
521
        static QString ImageScaling;
522
        static QString FrameSize;
523
        static QString FreeScaling;
524
        static QString KeepRatio;
525
        static QString BreakRatio;
526
        static QString EditContourLine;
527
        static QString EditShape;
528
        static QString ResetContourLine;
529
        static QString AddPage;
530
        static QString AddPages;
531
        static QString DeletePage;
532
        static QString DeletePages;
533
        static QString AddLayer;
534
        static QString DeleteLayer;
535
        static QString RenameLayer;
536
        static QString RaiseLayer;
537
        static QString LowerLayer;
538
        static QString SendToLayer;
539
        static QString PrintLayer;
540
        static QString DoNotPrintLayer;
541
        static QString SetLayerName;
542
        static QString GetImage;
4739 tsoots 543
        static QString MultipleDuplicate;
5184 avox 544
        static QString ApplyTextStyle;
5116 tsoots 545
        static QString MenuUndo;
546
        static QString MenuUndoEmpty;
547
        static QString MenuRedo;
548
        static QString MenuRedoEmpty;
6139 tsoots 549
        static QString EditContour;
6263 tsoots 550
        static QString ResetControlPoint;
551
        static QString ResetControlPoints;
1190 tsoots 552
        /*@}*/
1204 tsoots 553
 
1190 tsoots 554
        /**
555
         * @name Action icons
556
         * Icons for undo actions
557
         */
558
        /*@{*/
1250 tsoots 559
/*** Icons for UndoObjects *******************************************/
560
        static QPixmap *IImageFrame;
561
        static QPixmap *ITextFrame;
562
        static QPixmap *ILine;
563
        static QPixmap *IPolygon;
564
        static QPixmap *IPolyline;
565
        static QPixmap *IPathText;
1254 tsoots 566
        static QPixmap *IGroup;
1688 tsoots 567
        static QPixmap *ILayer;
1250 tsoots 568
/*** Icons for actions ***********************************************/
569
        static QPixmap *IMove;
570
        static QPixmap *IResize;
571
        static QPixmap *IRotate;
1190 tsoots 572
        static QPixmap *IGuides;
573
        static QPixmap *ILockGuides;
1247 tsoots 574
        static QPixmap *IAlignDistribute;
1286 tsoots 575
        static QPixmap *IFill;
576
        static QPixmap *IShade;
1287 tsoots 577
        static QPixmap *IFlipH;
578
        static QPixmap *IFlipV;
1290 tsoots 579
        static QPixmap *ILock;
580
        static QPixmap *IUnLock;
4698 cbradney 581
        static QPixmap *IEnablePrint;
582
        static QPixmap *IDisablePrint;
1340 tsoots 583
        static QPixmap *IDelete;
584
        static QPixmap *ICreate;
1369 tsoots 585
        static QPixmap *IPaste;
586
        static QPixmap *ICut;
1371 tsoots 587
        static QPixmap *ITransparency;
1383 tsoots 588
        static QPixmap *ILineStyle;
1391 tsoots 589
        static QPixmap *IArrow;
1396 tsoots 590
        static QPixmap *ITable;
1399 tsoots 591
        static QPixmap *IFont;
1440 tsoots 592
        static QPixmap *ISVG;
593
        static QPixmap *IEPS;
1434 tsoots 594
        static QPixmap *IImportOOoDraw;
1495 tsoots 595
        static QPixmap *IImageScaling;
1509 tsoots 596
        static QPixmap *IBorder;
1658 tsoots 597
        static QPixmap *IDocument;
1688 tsoots 598
        static QPixmap *ILayerAction;
1697 tsoots 599
        static QPixmap *IUp;
600
        static QPixmap *IDown;
601
        static QPixmap *IPrint;
1832 tsoots 602
        static QPixmap *IGetImage;
4739 tsoots 603
        static QPixmap *IMultipleDuplicate;
1190 tsoots 604
        /*@}*/
605
 
1111 tsoots 606
protected:
607
        /** @brief Creates a new UndoManager instance */
608
        UndoManager();
609
 
610
        /** @brief Destroys the UndoManager instance */
611
        ~UndoManager();
612
 
613
public slots:
614
        /**
2198 cbradney 615
         * @brief Updates strings when the GUI language is changed.
616
         */
617
        void languageChange();
618
 
619
        /**
1111 tsoots 620
         * @brief Adds a new action to the undo stack.
621
         *
622
         * If _unodEnabled is true the action will be stored otherwise it will
623
         * be just ignored. When a new action is added redo items from the stack
624
         * will be removed and the current action will be set to the one which was
625
         * added.
626
         * @param target Source of the action. When undoing/redoing this action
627
         * restore() method of this UndoObject will be called.
628
         * @param state UndoSate describing the state (action).
1356 tsoots 629
         * @param targetPixmap Is used to override the default target icon in this action.
1111 tsoots 630
         */
1340 tsoots 631
        void action(UndoObject* target, UndoState* state, QPixmap *targetPixmap = 0);
1111 tsoots 632
 
633
        /**
1356 tsoots 634
         * @brief Adds a new action to the undo stack.
635
         *
636
         * If _unodEnabled is true the action will be stored otherwise it will
637
         * be just ignored. When a new action is added redo items from the stack
638
         * will be removed and the current action will be set to the one which was
639
         * added.
640
         * @param target Source of the action. When undoing/redoing this action
641
         * restore() method of this UndoObject will be called.
642
         * @param state UndoSate describing the state (action).
643
         * @param targetName Is used to override the default target name in this action.
644
         * @param targetPixmap Is used to override the default target icon in this action.
645
         */
646
        void action(UndoObject* target, UndoState* state, const QString &targetName, QPixmap *targetPixmap = 0);
647
 
648
        /**
1111 tsoots 649
         * @brief Informs UndoManager to perform undo
650
         *
651
         * If an undo is wanted and the caller is not registered UndoGui this method
652
         * can be used. Useful for example with the menu entry for undo.
653
         * @param steps Number of undo steps to take
654
         */
655
        void undo(int steps);
656
 
657
        /**
658
         * @brief Informs UndoManager to perform redo
659
         * @param steps Number of redo steps to take
660
         * @sa UndoManager::undo(int steps)
661
         */
662
        void redo(int steps);
663
 
1197 tsoots 664
        /**
1443 tsoots 665
         * @brief Switches the state of UndoManager (global/object specific undo).
666
         *
667
         * If parameter uid is less than 0 global undo is used else the undo state
668
         * is object specific using the object whose uid is given as a parameter.
669
         * @param uid UndoObject's id for what the object specific undo is wanted or
670
         * -1 if global undo is wanted.
671
         */
672
        void showObject(int uid);
673
 
674
        /**
1197 tsoots 675
         * @brief Sets the length of the undo stack.
676
         *
677
         * Tells how many UndoStates are stored.
678
         * @param steps number of UndoStates to store in the undo stack
679
         */
680
        void setHistoryLength(int steps);
681
 
1111 tsoots 682
signals:
683
        /**
684
         * @brief Emitted when a new undo action is stored to the undo stack.
685
         *
1477 tsoots 686
         * This signal is connected to the registered UndoGuis for them to update the
1111 tsoots 687
         * visual representation of the undo stack.
688
         * @param target Source of the action
689
         * @param state UndoState describing the action
690
         */
691
        void newAction(UndoObject* target, UndoState* state);
692
 
693
        /**
694
         * @brief Emitted when an undo action has been done.
695
         *
696
         * It is connected to attached guis to inform them to update the visual
1190 tsoots 697
         * representation of the undo stack. This signal will be also sent to the
698
         * <code>UndoGui</code> where it came from.
1111 tsoots 699
         * @param steps Number of steps to take
700
         */
701
        void undoSignal(int steps);
702
 
703
        /**
704
         * @brief Emitted when a redo action has been done.
705
         * @param steps Number of steps to take
706
         * @sa UndoManager::undoSignal(int steps)
707
         */
708
        void redoSignal(int steps);
709
 
1477 tsoots 710
        /**
1457 tsoots 711
         * @brief Emitted when a new actions comes in and UndoManager is in object
712
         * @brief specific mode and action does not belong to the currently selected
713
         * @brief object.
714
         */
715
        void clearRedo();
716
 
1111 tsoots 717
        /**
718
         * @brief This signal is used to notify registered UndoGui instances that
1477 tsoots 719
         * @brief history limit is reached and the last item from the stack
1111 tsoots 720
         * @brief representation should be removed.
721
         */
722
        void popBack();
723
 
724
        /**
725
         * @brief This signal is emitted when all requested undo/redo actions have been done.
726
         *
727
         * It could be used in the application as a signal when the view can be rendered
728
         * again after undo/redo.
729
         */
730
        void undoRedoDone();
1190 tsoots 731
 
1111 tsoots 732
};
733
 
1190 tsoots 734
typedef UndoManager Um;
735
 
1111 tsoots 736
#endif