Subversion Repositories Scribus

Rev

Rev 9055 | 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;
9055 subik 433
        static QString DelVAGuide;
434
        static QString DelHAGuide;
2199 cbradney 435
        static QString MoveVGuide;
436
        static QString MoveHGuide;
7896 tsoots 437
        static QString RemoveAllGuides;
9068 subik 438
        static QString RemoveAllPageGuides;
2199 cbradney 439
        static QString LockGuides;
440
        static QString UnlockGuides;
441
        static QString Move;
442
        static QString Resize;
443
        static QString Rotate;
444
        static QString MoveFromTo;
445
        static QString ResizeFromTo;
4821 cbradney 446
        static QString ImageOffset;
447
        static QString ImageScale;
448
        static QString ImageOffsetFromTo;
449
        static QString ImageScaleFromTo;
2199 cbradney 450
        static QString Selection;
451
        static QString Group;
452
        static QString SelectionGroup;
453
        static QString Create;
454
        static QString CreateTo;
455
        static QString AlignDistribute;
456
        static QString ItemsInvolved;
457
        static QString Cancel;
458
        static QString SetFill;
459
        static QString ColorFromTo;
460
        static QString SetShade;
461
        static QString SetLineColor;
462
        static QString SetLineShade;
463
        static QString FlipH;
464
        static QString FlipV;
465
        static QString Lock;
466
        static QString UnLock;
467
        static QString SizeLock;
468
        static QString SizeUnLock;
4698 cbradney 469
        static QString EnablePrint;
470
        static QString DisablePrint;
2199 cbradney 471
        static QString Ungroup;
472
        static QString Delete;
473
        static QString Rename;
474
        static QString FromTo;
475
        static QString ApplyMasterPage;
476
        static QString Paste;
477
        static QString Cut;
478
        static QString Transparency;
479
        static QString LineTransparency;
480
        static QString LineStyle;
481
        static QString LineEnd;
482
        static QString LineJoin;
483
        static QString LineWidth;
484
        static QString NoStyle;
485
        static QString CustomLineStyle;
486
        static QString NoLineStyle;
487
        static QString StartArrow;
488
        static QString EndArrow;
7676 cbradney 489
        static QString StartAndEndArrow;
2199 cbradney 490
        static QString CreateTable;
491
        static QString RowsCols;
492
        static QString SetFont;
493
        static QString SetFontSize;
494
        static QString SetFontWidth;
2230 fschmid 495
        static QString SetFontHeight;
2199 cbradney 496
        static QString SetFontFill;
497
        static QString SetFontStroke;
498
        static QString SetFontFillShade;
499
        static QString SetFontStrokeShade;
500
        static QString SetKerning;
501
        static QString SetLineSpacing;
502
        static QString SetStyle;
503
        static QString SetLanguage;
504
        static QString AlignText;
505
        static QString SetFontEffect;
506
        static QString ImageFrame;
507
        static QString TextFrame;
508
        static QString Polygon;
509
        static QString BezierCurve;
510
        static QString Polyline;
3676 cbradney 511
        static QString PathText;
2199 cbradney 512
        static QString ConvertTo;
513
        static QString ImportSVG;
514
        static QString ImportEPS;
515
        static QString ImportOOoDraw;
516
        static QString ScratchSpace;
5620 jghali 517
        //static QString TextFlow;
518
        static QString ObjectFrame;
2199 cbradney 519
        static QString BoundingBox;
520
        static QString ContourLine;
8445 fschmid 521
        static QString ImageClip;
2199 cbradney 522
        static QString NoTextFlow;
5620 jghali 523
        static QString NoObjectFrame;
2199 cbradney 524
        static QString NoBoundingBox;
525
        static QString NoContourLine;
526
        static QString PageNmbr;
527
        static QString ImageScaling;
528
        static QString FrameSize;
529
        static QString FreeScaling;
530
        static QString KeepRatio;
531
        static QString BreakRatio;
532
        static QString EditContourLine;
533
        static QString EditShape;
534
        static QString ResetContourLine;
535
        static QString AddPage;
536
        static QString AddPages;
537
        static QString DeletePage;
538
        static QString DeletePages;
539
        static QString AddLayer;
540
        static QString DeleteLayer;
541
        static QString RenameLayer;
542
        static QString RaiseLayer;
543
        static QString LowerLayer;
544
        static QString SendToLayer;
545
        static QString PrintLayer;
546
        static QString DoNotPrintLayer;
547
        static QString SetLayerName;
548
        static QString GetImage;
4739 tsoots 549
        static QString MultipleDuplicate;
5184 avox 550
        static QString ApplyTextStyle;
5116 tsoots 551
        static QString MenuUndo;
552
        static QString MenuUndoEmpty;
553
        static QString MenuRedo;
554
        static QString MenuRedoEmpty;
6139 tsoots 555
        static QString EditContour;
6263 tsoots 556
        static QString ResetControlPoint;
557
        static QString ResetControlPoints;
6266 tsoots 558
        static QString ImageEffects;
6820 tsoots 559
        static QString InsertFrame;
7100 tsoots 560
        static QString AdjustFrameToImage;
7897 tsoots 561
        static QString Copy;
562
        static QString CopyPage;
8944 tsoots 563
        static QString ToOutlines;
1190 tsoots 564
        /*@}*/
1204 tsoots 565
 
1190 tsoots 566
        /**
567
         * @name Action icons
568
         * Icons for undo actions
569
         */
570
        /*@{*/
1250 tsoots 571
/*** Icons for UndoObjects *******************************************/
572
        static QPixmap *IImageFrame;
573
        static QPixmap *ITextFrame;
574
        static QPixmap *ILine;
575
        static QPixmap *IPolygon;
576
        static QPixmap *IPolyline;
577
        static QPixmap *IPathText;
1254 tsoots 578
        static QPixmap *IGroup;
1688 tsoots 579
        static QPixmap *ILayer;
1250 tsoots 580
/*** Icons for actions ***********************************************/
581
        static QPixmap *IMove;
582
        static QPixmap *IResize;
583
        static QPixmap *IRotate;
1190 tsoots 584
        static QPixmap *IGuides;
585
        static QPixmap *ILockGuides;
1247 tsoots 586
        static QPixmap *IAlignDistribute;
1286 tsoots 587
        static QPixmap *IFill;
588
        static QPixmap *IShade;
1287 tsoots 589
        static QPixmap *IFlipH;
590
        static QPixmap *IFlipV;
1290 tsoots 591
        static QPixmap *ILock;
592
        static QPixmap *IUnLock;
4698 cbradney 593
        static QPixmap *IEnablePrint;
594
        static QPixmap *IDisablePrint;
1340 tsoots 595
        static QPixmap *IDelete;
596
        static QPixmap *ICreate;
1369 tsoots 597
        static QPixmap *IPaste;
598
        static QPixmap *ICut;
1371 tsoots 599
        static QPixmap *ITransparency;
1383 tsoots 600
        static QPixmap *ILineStyle;
1391 tsoots 601
        static QPixmap *IArrow;
1396 tsoots 602
        static QPixmap *ITable;
1399 tsoots 603
        static QPixmap *IFont;
1440 tsoots 604
        static QPixmap *ISVG;
605
        static QPixmap *IEPS;
1434 tsoots 606
        static QPixmap *IImportOOoDraw;
1495 tsoots 607
        static QPixmap *IImageScaling;
1509 tsoots 608
        static QPixmap *IBorder;
1658 tsoots 609
        static QPixmap *IDocument;
1688 tsoots 610
        static QPixmap *ILayerAction;
1697 tsoots 611
        static QPixmap *IUp;
612
        static QPixmap *IDown;
613
        static QPixmap *IPrint;
1832 tsoots 614
        static QPixmap *IGetImage;
4739 tsoots 615
        static QPixmap *IMultipleDuplicate;
1190 tsoots 616
        /*@}*/
617
 
1111 tsoots 618
protected:
619
        /** @brief Creates a new UndoManager instance */
620
        UndoManager();
621
 
622
        /** @brief Destroys the UndoManager instance */
623
        ~UndoManager();
624
 
625
public slots:
626
        /**
2198 cbradney 627
         * @brief Updates strings when the GUI language is changed.
628
         */
629
        void languageChange();
630
 
631
        /**
1111 tsoots 632
         * @brief Adds a new action to the undo stack.
633
         *
634
         * If _unodEnabled is true the action will be stored otherwise it will
635
         * be just ignored. When a new action is added redo items from the stack
636
         * will be removed and the current action will be set to the one which was
637
         * added.
638
         * @param target Source of the action. When undoing/redoing this action
639
         * restore() method of this UndoObject will be called.
640
         * @param state UndoSate describing the state (action).
1356 tsoots 641
         * @param targetPixmap Is used to override the default target icon in this action.
1111 tsoots 642
         */
1340 tsoots 643
        void action(UndoObject* target, UndoState* state, QPixmap *targetPixmap = 0);
1111 tsoots 644
 
645
        /**
1356 tsoots 646
         * @brief Adds a new action to the undo stack.
647
         *
648
         * If _unodEnabled is true the action will be stored otherwise it will
649
         * be just ignored. When a new action is added redo items from the stack
650
         * will be removed and the current action will be set to the one which was
651
         * added.
652
         * @param target Source of the action. When undoing/redoing this action
653
         * restore() method of this UndoObject will be called.
654
         * @param state UndoSate describing the state (action).
655
         * @param targetName Is used to override the default target name in this action.
656
         * @param targetPixmap Is used to override the default target icon in this action.
657
         */
658
        void action(UndoObject* target, UndoState* state, const QString &targetName, QPixmap *targetPixmap = 0);
659
 
660
        /**
1111 tsoots 661
         * @brief Informs UndoManager to perform undo
662
         *
663
         * If an undo is wanted and the caller is not registered UndoGui this method
664
         * can be used. Useful for example with the menu entry for undo.
665
         * @param steps Number of undo steps to take
666
         */
667
        void undo(int steps);
668
 
669
        /**
670
         * @brief Informs UndoManager to perform redo
671
         * @param steps Number of redo steps to take
672
         * @sa UndoManager::undo(int steps)
673
         */
674
        void redo(int steps);
675
 
1197 tsoots 676
        /**
1443 tsoots 677
         * @brief Switches the state of UndoManager (global/object specific undo).
678
         *
679
         * If parameter uid is less than 0 global undo is used else the undo state
680
         * is object specific using the object whose uid is given as a parameter.
681
         * @param uid UndoObject's id for what the object specific undo is wanted or
682
         * -1 if global undo is wanted.
683
         */
684
        void showObject(int uid);
685
 
686
        /**
1197 tsoots 687
         * @brief Sets the length of the undo stack.
688
         *
689
         * Tells how many UndoStates are stored.
690
         * @param steps number of UndoStates to store in the undo stack
691
         */
692
        void setHistoryLength(int steps);
7880 fschmid 693
        void setAllHistoryLengths(int steps);
1197 tsoots 694
 
1111 tsoots 695
signals:
696
        /**
697
         * @brief Emitted when a new undo action is stored to the undo stack.
698
         *
1477 tsoots 699
         * This signal is connected to the registered UndoGuis for them to update the
1111 tsoots 700
         * visual representation of the undo stack.
701
         * @param target Source of the action
702
         * @param state UndoState describing the action
703
         */
704
        void newAction(UndoObject* target, UndoState* state);
705
 
706
        /**
707
         * @brief Emitted when an undo action has been done.
708
         *
709
         * It is connected to attached guis to inform them to update the visual
1190 tsoots 710
         * representation of the undo stack. This signal will be also sent to the
711
         * <code>UndoGui</code> where it came from.
1111 tsoots 712
         * @param steps Number of steps to take
713
         */
714
        void undoSignal(int steps);
715
 
716
        /**
717
         * @brief Emitted when a redo action has been done.
718
         * @param steps Number of steps to take
719
         * @sa UndoManager::undoSignal(int steps)
720
         */
721
        void redoSignal(int steps);
722
 
1477 tsoots 723
        /**
1457 tsoots 724
         * @brief Emitted when a new actions comes in and UndoManager is in object
725
         * @brief specific mode and action does not belong to the currently selected
726
         * @brief object.
727
         */
728
        void clearRedo();
729
 
1111 tsoots 730
        /**
731
         * @brief This signal is used to notify registered UndoGui instances that
1477 tsoots 732
         * @brief history limit is reached and the last item from the stack
1111 tsoots 733
         * @brief representation should be removed.
734
         */
735
        void popBack();
736
 
737
        /**
738
         * @brief This signal is emitted when all requested undo/redo actions have been done.
739
         *
740
         * It could be used in the application as a signal when the view can be rendered
741
         * again after undo/redo.
742
         */
743
        void undoRedoDone();
1190 tsoots 744
 
1111 tsoots 745
};
746
 
1190 tsoots 747
typedef UndoManager Um;
748
 
1111 tsoots 749
#endif