Subversion Repositories Scribus

Rev

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