Subversion Repositories Scribus

Rev

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