Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
2217 cbradney 1
$/***************************************************************************
1111 tsoots 2
 *   Copyright (C) 2005 by Riku Leino                                      *
3
 *   tsoots@gmail.com                                                      *
4
 *                                                                         *
5
 *   This program is free software; you can redistribute it and/or modify  *
6
 *   it under the terms of the GNU General Public License as published by  *
7
 *   the Free Software Foundation; either version 2 of the License, or     *
8
 *   (at your option) any later version.                                   *
9
 *                                                                         *
10
 *   This program is distributed in the hope that it will be useful,       *
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13
 *   GNU General Public License for more details.                          *
14
 *                                                                         *
15
 *   You should have received a copy of the GNU General Public License     *
16
 *   along with this program; if not, write to the                         *
17
 *   Free Software Foundation, Inc.,                                       *
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19
 ***************************************************************************/
20
 
21
#include "undomanager.h"
1119 fschmid 22
#include "undomanager.moc"
1142 tsoots 23
#include "undogui.h"
1190 tsoots 24
#include "config.h"
1197 tsoots 25
#include "prefscontext.h"
26
#include "prefsfile.h"
1111 tsoots 27
#include <qvaluelist.h>
28
 
1693 craig 29
#include "scpaths.h"
30
 
1197 tsoots 31
extern PrefsFile *prefsFile;
1190 tsoots 32
extern QPixmap loadIcon(QString nam);
33
 
1430 tsoots 34
UndoManager* UndoManager::_instance          = 0;
35
bool         UndoManager::_undoEnabled       = true;
36
int          UndoManager::undoEnabledCounter = 0;
1111 tsoots 37
 
38
UndoManager* UndoManager::instance()
39
{
40
        if (_instance == 0)
41
                _instance = new UndoManager();
42
 
43
        return _instance;
44
}
45
 
46
void UndoManager::setUndoEnabled(bool isEnabled)
47
{
1430 tsoots 48
        if (isEnabled && undoEnabledCounter == 0)
49
                return; // nothing to do undo is already enabled.
50
        else if (isEnabled && undoEnabledCounter > 0)
51
                --undoEnabledCounter;
52
        else if (!isEnabled)
53
                ++undoEnabledCounter;
54
 
55
        _undoEnabled = undoEnabledCounter == 0;
56
        if (_undoEnabled)
1111 tsoots 57
                connectGuis();
1430 tsoots 58
        else if (undoEnabledCounter == 1)
59
                disconnectGuis(); // disconnect only once when setUndoEnabled(false) has been called
60
                                  // no need to call again if next setUndoEnabled() call will also be false.
1111 tsoots 61
}
62
 
63
bool UndoManager::undoEnabled()
64
{
65
        return _undoEnabled;
66
}
67
 
68
UndoManager::UndoManager()
69
{
70
        currentUndoObjectId = -1;
1190 tsoots 71
        if (!UndoManager::IGuides)
72
                initIcons();
1197 tsoots 73
        prefs = prefsFile->getContext("undo");
74
        historyLength = prefs->getInt("historyLength", 10);
75
        if (historyLength < 0)
76
                historyLength = 10;
1213 tsoots 77
        transaction = NULL;
78
        transactionTarget = NULL;
2198 cbradney 79
        languageChange();
1111 tsoots 80
}
81
 
1213 tsoots 82
void UndoManager::beginTransaction(const QString &targetName,
1250 tsoots 83
                                   QPixmap *targetPixmap,
1213 tsoots 84
                                   const QString &name,
85
                                   const QString &description,
1250 tsoots 86
                                   QPixmap *actionPixmap)
1213 tsoots 87
{
1340 tsoots 88
        if (!_undoEnabled)
89
                return;
1238 tsoots 90
        if (transaction) // begin a transaction inside transaction
91
                transactions.push_back(
92
                        std::pair<TransactionObject*, TransactionState*>(transactionTarget, transaction));
1213 tsoots 93
        transaction = new TransactionState();
94
        transactionTarget = new TransactionObject();
1228 tsoots 95
        transactionTarget->setUName(targetName); // Name which will be in action history
1250 tsoots 96
        if (targetPixmap)
97
                transactionTarget->setUPixmap(targetPixmap);
1228 tsoots 98
        if (name.length() > 0)          // if left to 0 length action will be fetched from the
99
                transaction->setName(name); // last added UndoState in this transaction
1238 tsoots 100
        if (description.length() > 0)
1228 tsoots 101
                transaction->setDescription(description); // tool tip for action history
1250 tsoots 102
        if (actionPixmap)
103
                transaction->setPixmap(actionPixmap); // for action history
1213 tsoots 104
}
105
 
106
void UndoManager::cancelTransaction()
107
{
108
        delete transaction;
109
        transaction = NULL;
110
        delete transactionTarget;
111
        transactionTarget = NULL;
1238 tsoots 112
        if (!transactions.empty())
113
        {
114
                // fetch the next transaction from the vector
115
                transactionTarget = transactions[transactions.size() - 1].first;
116
                transaction = transactions[transactions.size() - 1].second;
117
//              delete transactions[transactions.size() - 1];
118
                transactions.erase(transactions.end() - 1);
119
        }
1213 tsoots 120
}
121
 
122
void UndoManager::commit(const QString &targetName,
1250 tsoots 123
                         QPixmap *targetPixmap,
1213 tsoots 124
                         const QString &name,
125
                         const QString &description,
1250 tsoots 126
                         QPixmap *actionPixmap)
1213 tsoots 127
{
1340 tsoots 128
        if (!transaction || !transactionTarget || !_undoEnabled)
1213 tsoots 129
        {
130
                cancelTransaction();
131
                return;
132
        }
133
        if (targetName.length() > 0)
134
                transactionTarget->setUName(targetName);
1250 tsoots 135
        if (targetPixmap)
136
                transactionTarget->setUPixmap(targetPixmap);
1213 tsoots 137
        if (name.length() > 0)
138
                transaction->setName(name);
139
        if (description.length() > 0)
140
                transaction->setDescription(description);
1250 tsoots 141
        if (actionPixmap)
142
                transaction->setPixmap(actionPixmap);
1213 tsoots 143
 
144
        UndoObject *tmpu = transactionTarget;
145
        TransactionState *tmps = transaction;
1238 tsoots 146
 
147
        if (!transactions.empty())
1226 tsoots 148
        {
1238 tsoots 149
                // fetch the next transaction to be an active transaction
150
                transactionTarget = transactions[transactions.size() - 1].first;
151
                transaction = transactions[transactions.size() - 1].second;
152
//              delete transactions[transactions.size() - 1]
153
                transactions.erase(transactions.end() - 1);
154
        }
155
        else
156
        {
157
                transaction = NULL;
158
                transactionTarget = NULL;
159
        }
160
 
161
        if (tmps->sizet() > 0) // are there any actions inside the commited transaction
162
        {
1226 tsoots 163
                if (tmps->getName() == "")
164
                        tmps->useActionName();
1213 tsoots 165
                action(tmpu, tmps);
1238 tsoots 166
        } // if not just delete objects
1226 tsoots 167
        else
168
        {
169
                delete tmpu;
170
                tmpu = NULL;
171
                delete tmps;
172
                tmps = NULL;
173
        }
1213 tsoots 174
}
175
 
176
bool UndoManager::isTransactionMode()
177
{
178
        return transaction ? true : false;
179
}
180
 
1111 tsoots 181
void UndoManager::registerGui(UndoGui* gui)
182
{
183
        if (gui == NULL)
184
                return;
185
 
186
        setUndoEnabled(false);
187
        setState(gui);
188
        undoGuis.push_back(gui);
1431 tsoots 189
        setUndoEnabled(true);
1111 tsoots 190
}
191
 
192
void UndoManager::setState(UndoGui* gui, int uid)
193
{
194
        gui->clear();
1443 tsoots 195
 
1477 tsoots 196
        ActionList::iterator itstart = stacks[currentDoc].second.begin() - 1;;
197
        ActionList::iterator itend   = stacks[currentDoc].second.end() - 1;;
1443 tsoots 198
        if (uid > -1)
1477 tsoots 199
        { // find the range from where actions are added when in obj. spec. mode
1461 tsoots 200
                ActionList::iterator it2;
1477 tsoots 201
                for (it2 = stacks[currentDoc].first - 1; it2 != stacks[currentDoc].second.begin() - 1; --it2)
1443 tsoots 202
                {
203
                        UndoState*  tmp  = (*it2).second;
204
                        TransactionState *ts = dynamic_cast<TransactionState*>(tmp);
205
                        if (ts && ts->contains(uid))
206
                        {
1477 tsoots 207
                                itstart = it2 - 1;
1443 tsoots 208
                                break;
209
                        }
210
                }
1477 tsoots 211
                for (it2 = stacks[currentDoc].first; it2 != stacks[currentDoc].second.end(); ++it2)
212
                {
213
                        UndoState*  tmp  = (*it2).second;
214
                        TransactionState *ts = dynamic_cast<TransactionState*>(tmp);
215
                        if (ts && ts->contains(uid))
216
                        {
217
                                itend = it2 - 1;
218
                                break;
219
                        }
220
                }
1443 tsoots 221
        }
1477 tsoots 222
 
223
        for (; itend > itstart; --itend)
1443 tsoots 224
        {
1477 tsoots 225
                ActionPair pair = *itend;
1111 tsoots 226
                UndoObject* target = pair.first;
227
                UndoState*  state  = pair.second;
1443 tsoots 228
 
229
                if (uid == -1 || target->getUId() == static_cast<uint>(uid))
230
                {
1477 tsoots 231
                        if (itend > stacks[currentDoc].first - 1)
1443 tsoots 232
                                gui->insertUndoItem(target, state);
233
                        else
234
                                gui->insertRedoItem(target, state);
235
                }
1111 tsoots 236
        }
237
}
238
 
239
void UndoManager::connectGuis()
240
{
241
        for (uint i = 0; i < undoGuis.size(); ++i)
242
        {
243
                UndoGui *gui = undoGuis[i];
244
 
245
                connect(gui, SIGNAL(undo(int)), this, SLOT(doUndo(int)));
246
                connect(gui, SIGNAL(redo(int)), this, SLOT(doRedo(int)));
247
                connect(this, SIGNAL(newAction(UndoObject*, UndoState*)),
248
                gui, SLOT(insertUndoItem(UndoObject*, UndoState*)));
249
                connect(this, SIGNAL(popBack()), gui, SLOT(popBack()));
250
                connect(this, SIGNAL(undoSignal(int)), gui, SLOT(updateUndo(int)));
251
                connect(this, SIGNAL(redoSignal(int)), gui, SLOT(updateRedo(int)));
1457 tsoots 252
                connect(this, SIGNAL(clearRedo()), gui, SLOT(clearRedo()));
1111 tsoots 253
        }
254
}
255
 
256
void UndoManager::disconnectGuis()
257
{
258
        for (uint i = 0; i < undoGuis.size(); ++i)
259
        {
260
                UndoGui *gui = undoGuis[i];
261
 
262
                disconnect(gui, SIGNAL(undo(int)), this, SLOT(doUndo(int)));
263
                disconnect(gui, SIGNAL(redo(int)), this, SLOT(doRedo(int)));
264
                disconnect(this, SIGNAL(newAction(UndoObject*, UndoState*)),
265
                   gui, SLOT(insertUndoItem(UndoObject*, UndoState*)));
266
                disconnect(this, SIGNAL(popBack()), gui, SLOT(popBack()));
267
                disconnect(this, SIGNAL(undoSignal(int)), gui, SLOT(updateUndo(int)));
268
                disconnect(this, SIGNAL(redoSignal(int)), gui, SLOT(updateRedo(int)));
1457 tsoots 269
                disconnect(this, SIGNAL(clearRedo()), gui, SLOT(clearRedo()));
1111 tsoots 270
        }
271
}
272
 
273
void UndoManager::removeGui(UndoGui* gui)
274
{
275
        std::vector<UndoGui*>::iterator it;
276
        for (it = undoGuis.begin(); it != undoGuis.end(); ++it)
277
                if (*it == gui)
278
                        undoGuis.erase(it);
279
}
280
 
281
void UndoManager::switchStack(const QString& stackName)
282
{
283
        currentDoc = stackName;
284
        if (!stacks.contains(currentDoc))
285
        {
286
                ActionList alist;
287
                ActionList::iterator it = alist.begin();
288
                stacks[currentDoc] = StackPair(it, alist);
289
        }
290
 
291
        for (uint i = 0; i < undoGuis.size(); ++i)
292
                setState(undoGuis[i]);
293
}
294
 
1252 tsoots 295
void UndoManager::renameStack(const QString& newName)
1111 tsoots 296
{
1190 tsoots 297
        if (currentDoc == newName)
298
                return;
1829 tsoots 299
 
1880 tsoots 300
        if (stacks[currentDoc].second.empty()) {
301
                currentDoc = newName;
302
                return;
303
        }
304
 
1829 tsoots 305
        ActionPair pair = *(stacks[currentDoc].first);
306
        StackPair tmp(stacks[currentDoc].first, stacks[currentDoc].second);
1111 tsoots 307
        stacks.erase(currentDoc);
308
        stacks[newName] = tmp;
309
        currentDoc = newName;
1829 tsoots 310
        ActionList::iterator it;
311
        for (it = stacks[currentDoc].second.begin(); it != stacks[currentDoc].second.end(); ++it)
312
        {
313
                if ((*it) == pair)
314
                        break;
315
        }
316
        stacks[currentDoc].first = it;
1111 tsoots 317
}
318
 
1252 tsoots 319
void UndoManager::removeStack(const QString& stackName)
1111 tsoots 320
{
321
        if (stacks.contains(stackName))
322
        {
323
                for (uint i = 0; i < stacks[stackName].second.size(); ++i)
324
                {
325
                        delete stacks[stackName].second[i].second;
326
                        stacks[stackName].second[i].second = NULL;
327
                }
328
                stacks.erase(stackName);
329
                if (currentDoc == stackName)
330
                {
331
                        for (uint i = 0; i < undoGuis.size(); ++i)
332
                                undoGuis[i]->clear();
1190 tsoots 333
                        currentDoc = "__no_name__";
1111 tsoots 334
                }
335
        }
336
}
337
 
1340 tsoots 338
void UndoManager::action(UndoObject* target, UndoState* state, QPixmap *targetPixmap)
1111 tsoots 339
{
1340 tsoots 340
        QPixmap *oldIcon = NULL;
341
        if (targetPixmap)
342
        {
343
                oldIcon = target->getUPixmap();
344
                target->setUPixmap(targetPixmap);
345
        }
1485 tsoots 346
 
1228 tsoots 347
        if (!_undoEnabled) // if so flush down the state
348
        {
349
                TransactionState *ts = dynamic_cast<TransactionState*>(state);
350
                if (ts) // flush the TransactionObject too
351
                        delete target;
352
                delete state;
353
                return;
354
        }
355
 
1213 tsoots 356
        if ((!transaction) &&
357
        (currentUndoObjectId == -1 || currentUndoObjectId == static_cast<long>(target->getUId())))
1226 tsoots 358
                emit newAction(target, state); // send action to the guis
1457 tsoots 359
        else
360
                emit clearRedo();
1111 tsoots 361
 
1228 tsoots 362
        if (stacks[currentDoc].second.size() > 1 && !transaction) // delete redo states
1111 tsoots 363
        {
364
                ActionList::iterator it;
365
                for (it = stacks[currentDoc].second.begin(); it != stacks[currentDoc].first; ++it)
1226 tsoots 366
                {
367
                        TransactionState *ts = dynamic_cast<TransactionState*>((*it).second);
368
                        if (ts)
1228 tsoots 369
                        {
1226 tsoots 370
                                delete (*it).first; // delete TransactionObject
1228 tsoots 371
                                (*it).first = NULL;
372
                        }
1111 tsoots 373
                        delete (*it).second;
1226 tsoots 374
                        (*it).second = NULL;
375
                }
1111 tsoots 376
                stacks[currentDoc].second.erase(stacks[currentDoc].second.begin(), stacks[currentDoc].first);
377
        }
378
 
1213 tsoots 379
        if (transaction)
380
                transaction->pushBack(target, state);
381
        else
382
        {
1226 tsoots 383
                checkStackLength(); // check that history length
1213 tsoots 384
                stacks[currentDoc].second.insert(stacks[currentDoc].second.begin(), ActionPair(target, state));
385
                stacks[currentDoc].first = stacks[currentDoc].second.begin();
386
        }
1340 tsoots 387
        if (targetPixmap)
388
                target->setUPixmap(oldIcon);
1111 tsoots 389
}
1477 tsoots 390
 
1356 tsoots 391
void UndoManager::action(UndoObject* target, UndoState* state,
392
                         const QString &targetName, QPixmap *targetPixmap)
393
{
394
        QString oldName = target->getUName();
395
        if (targetName != "")
396
                target->setUName(targetName);
397
        action(target, state, targetPixmap);
398
        target->setUName(oldName);
399
}
1111 tsoots 400
 
401
void UndoManager::undo(int steps)
402
{
403
        if (_undoEnabled);
404
                doUndo(steps);
405
}
406
 
407
void UndoManager::redo(int steps)
408
{
409
        if (_undoEnabled)
410
                doRedo(steps);
411
}
412
 
413
void UndoManager::doUndo(int steps)
414
{
1190 tsoots 415
        if (steps > 0 && _undoEnabled && stacks.size() > 0)
1111 tsoots 416
        {
417
                setUndoEnabled(false);
1190 tsoots 418
                UndoState* tmpUndoState = NULL;
1477 tsoots 419
                currentAction = stacks[currentDoc].first;
1111 tsoots 420
                for (int i = 0; i < steps; ++i)
421
                {
1477 tsoots 422
                        ActionPair &aPair = getNextUndoPair();
1111 tsoots 423
                        UndoObject* tmpUndoObject = aPair.first;
1190 tsoots 424
                        tmpUndoState = aPair.second;
1213 tsoots 425
                        TransactionState *ts = dynamic_cast<TransactionState*>(tmpUndoState);
1477 tsoots 426
 
1251 tsoots 427
                        if (tmpUndoObject && tmpUndoState && !ts)
1190 tsoots 428
                                tmpUndoObject->restore(tmpUndoState, true);
1228 tsoots 429
                        else if (tmpUndoState && ts)
1213 tsoots 430
                                doTransactionUndo(ts);
1228 tsoots 431
                        ts = NULL;
1111 tsoots 432
                }
1477 tsoots 433
                reorderUndoStack(steps);
1431 tsoots 434
                setUndoEnabled(true);
1190 tsoots 435
                if (tmpUndoState)
436
                {
437
                        emit undoSignal(steps);
438
                        emit undoRedoDone();
439
                }
1111 tsoots 440
        }
441
}
442
 
1477 tsoots 443
ActionPair& UndoManager::getNextUndoPair()
444
{
445
        if (currentUndoObjectId == GLOBAL_UNDO_MODE)
446
                ++currentAction;
447
        else
448
                for (; currentAction != stacks[currentDoc].second.end(); ++currentAction)
1485 tsoots 449
                        if ((*currentAction).first->getUId() == static_cast<uint>(currentUndoObjectId))
1477 tsoots 450
                        {
451
                                ++currentAction;
452
                                break;
453
                        }
454
        return *(currentAction - 1);
455
}
456
 
457
void UndoManager::reorderUndoStack(int steps)
458
{
459
        if (currentUndoObjectId == GLOBAL_UNDO_MODE)
460
                stacks[currentDoc].first += steps;
461
        else
462
        {
463
                int pos = -1;
464
                ActionList::iterator it;
465
                for (it = stacks[currentDoc].second.begin(); it != stacks[currentDoc].first + 1; ++it)
466
                {
467
                        ++pos;
468
                }
469
 
470
                // TODO Move the items around here
471
                for (int i = 0; i < steps; ++i)
472
                {
473
                        ActionList::iterator it = stacks[currentDoc].second.begin() + pos;
1485 tsoots 474
                        while ((*it).first->getUId() != static_cast<uint>(currentUndoObjectId)) ++it;
1477 tsoots 475
                        ActionPair pair = *it;
476
                        stacks[currentDoc].second.erase(it);
477
                        stacks[currentDoc].second.insert(stacks[currentDoc].second.begin() + pos, pair);
478
                        ++pos;
479
                }
480
 
481
                stacks[currentDoc].first = stacks[currentDoc].second.begin() += pos;
482
        }
483
}
484
 
1213 tsoots 485
void UndoManager::doTransactionUndo(TransactionState *tstate)
486
{
487
        for (int i = tstate->sizet() - 1; i > -1; --i)
488
        {
489
                ActionPair *pair = tstate->at(i);
1262 tsoots 490
                TransactionState *ts = dynamic_cast<TransactionState*>(pair->second);
491
                if (pair && pair->first && pair->second && !ts)
1213 tsoots 492
                        pair->first->restore(pair->second, true);
1262 tsoots 493
                else if (pair && pair->second && ts)
494
                        doTransactionUndo(ts);
1213 tsoots 495
        }
496
}
497
 
1111 tsoots 498
void UndoManager::doRedo(int steps)
499
{
1190 tsoots 500
        if (steps > 0 && _undoEnabled && stacks.size() > 0)
1111 tsoots 501
        {
502
                setUndoEnabled(false);
1190 tsoots 503
                UndoState* tmpUndoState = NULL;
1477 tsoots 504
                currentAction = stacks[currentDoc].first;
1228 tsoots 505
                for (int i = 0; i < steps; ++i) // TODO compare to stack size too
1111 tsoots 506
                {
1477 tsoots 507
                        ActionPair &aPair = getNextRedoPair();
1111 tsoots 508
                        UndoObject* tmpUndoObject = aPair.first;
1190 tsoots 509
                        tmpUndoState = aPair.second;
1213 tsoots 510
                        TransactionState *ts = dynamic_cast<TransactionState*>(tmpUndoState);
1477 tsoots 511
 
1247 tsoots 512
                        if (tmpUndoObject && tmpUndoState && !ts)
1190 tsoots 513
                                tmpUndoObject->restore(tmpUndoState, false);
1228 tsoots 514
                        else if (tmpUndoState && ts)
1213 tsoots 515
                                doTransactionRedo(ts);
1228 tsoots 516
                        ts = NULL;
1111 tsoots 517
                }
1228 tsoots 518
 
1477 tsoots 519
                reorderRedoStack(steps);
1431 tsoots 520
                setUndoEnabled(true);
1228 tsoots 521
 
1190 tsoots 522
                if (tmpUndoState)
523
                {
524
                        emit redoSignal(steps);
525
                        emit undoRedoDone();
526
                }
1111 tsoots 527
        }
528
}
529
 
1477 tsoots 530
ActionPair& UndoManager::getNextRedoPair()
531
{
532
        if (currentUndoObjectId == GLOBAL_UNDO_MODE)
533
                --currentAction;
534
        else
535
                for (--currentAction; currentAction != stacks[currentDoc].second.begin() - 1; --currentAction)
1485 tsoots 536
                        if ((*currentAction).first->getUId() == static_cast<uint>(currentUndoObjectId))
1477 tsoots 537
                                break;
538
 
539
        return *currentAction;
540
}
541
 
542
void UndoManager::reorderRedoStack(int steps)
543
{
544
        if (currentUndoObjectId == GLOBAL_UNDO_MODE)
545
                stacks[currentDoc].first -= steps;
546
        else
547
        {
548
                int pos = -1;
549
                ActionList::iterator it;
550
                for (it = stacks[currentDoc].second.begin(); it != stacks[currentDoc].first + 1; ++it)
551
                        ++pos;
552
                for (int i = 0; i < steps; ++i)
553
                {
554
                        ActionList::iterator it = stacks[currentDoc].second.begin() + pos - 1;
1485 tsoots 555
                        while ((*it).first->getUId() != static_cast<uint>(currentUndoObjectId)) --it;
1477 tsoots 556
                        ActionPair pair = *it;
557
                        stacks[currentDoc].second.erase(it);
558
                        --pos;
559
                        stacks[currentDoc].second.insert(stacks[currentDoc].second.begin() + pos, pair);
560
                }
561
                stacks[currentDoc].first = stacks[currentDoc].second.begin() += pos;
562
        }
563
}
564
 
1213 tsoots 565
void UndoManager::doTransactionRedo(TransactionState *tstate)
566
{
567
        for (uint i = 0; i < tstate->sizet(); ++i)
568
        {
1262 tsoots 569
                ActionPair *pair = tstate->at(i);
570
                TransactionState *ts = dynamic_cast<TransactionState*>(pair->second);
571
                if (pair && pair->first && pair->second && !ts)
572
                        pair->first->restore(pair->second, false);
573
                else if (pair && pair->second && ts)
574
                        doTransactionRedo(ts);
1213 tsoots 575
        }
576
}
577
 
1443 tsoots 578
bool UndoManager::hasUndoActions(int uid)
1111 tsoots 579
{
1457 tsoots 580
        // TODO Needs to fixed for object specific mode
1111 tsoots 581
        return stacks[currentDoc].first < stacks[currentDoc].second.end();
582
}
583
 
1443 tsoots 584
bool UndoManager::hasRedoActions(int uid)
1111 tsoots 585
{
1457 tsoots 586
        // TODO Needs to be fixed for object specific mode
1111 tsoots 587
        return stacks[currentDoc].first > stacks[currentDoc].second.begin();
588
}
589
 
590
void UndoManager::showObject(int uid)
591
{
1443 tsoots 592
        if (currentUndoObjectId == uid)
593
                return;
594
        setUndoEnabled(false);
595
        currentUndoObjectId = uid;
596
        for (uint i = 0; i < undoGuis.size(); ++i)
597
        {
598
                if (uid == -2)
599
                        undoGuis[i]->clear();
600
                else
601
                        setState(undoGuis[i], currentUndoObjectId);
602
        }
603
        setUndoEnabled(true);
1111 tsoots 604
}
605
 
1658 tsoots 606
UndoObject* UndoManager::replaceObject(ulong uid, UndoObject *newUndoObject)
1238 tsoots 607
{
1658 tsoots 608
        UndoObject *tmp = NULL;
1238 tsoots 609
        for (uint i = 0; i < stacks[currentDoc].second.size(); ++i)
610
        {
611
                ActionPair &apair = stacks[currentDoc].second[i];
612
                TransactionState *ts = dynamic_cast<TransactionState*>(apair.second);
613
                if (ts)
1658 tsoots 614
                        tmp = ts->replace(uid, newUndoObject);
1258 tsoots 615
                else if (apair.first && apair.first->getUId() == uid)
1658 tsoots 616
                {
617
                        tmp = apair.first;
1238 tsoots 618
                        apair.first = newUndoObject;
1658 tsoots 619
                }
1238 tsoots 620
        }
1663 tsoots 621
        if (transaction) // replace also in the currently open transaction
1664 tsoots 622
                tmp = transaction->replace(uid, newUndoObject);
1658 tsoots 623
        return tmp;
1238 tsoots 624
}
625
 
1111 tsoots 626
void UndoManager::setHistoryLength(int steps)
627
{
1197 tsoots 628
        if (steps >= 0)
629
        {
1111 tsoots 630
                historyLength = steps;
1197 tsoots 631
                prefs->set("historyLength", historyLength);
632
                checkStackLength();
633
        }
1111 tsoots 634
}
635
 
636
int UndoManager::getHistoryLength()
637
{
1197 tsoots 638
        if (stacks.size() > 0 && stacks[currentDoc].first != stacks[currentDoc].second.begin())
639
                return -1;
1111 tsoots 640
        return historyLength;
641
}
642
 
1461 tsoots 643
bool UndoManager::isGlobalMode()
644
{
645
        return currentUndoObjectId == -1;
646
}
647
 
1197 tsoots 648
void UndoManager::checkStackLength()
649
{
650
        if ((stacks[currentDoc].second.size() >= static_cast<uint>(historyLength)) && (historyLength != 0))
651
        {
652
                while (stacks[currentDoc].second.size() >= static_cast<uint>(historyLength))
653
                {
654
                        ActionList::iterator it = stacks[currentDoc].second.end() - 1;
655
                        if (stacks[currentDoc].first == it)
656
                                stacks[currentDoc].first = it - 1;
1226 tsoots 657
                        TransactionState *ts = dynamic_cast<TransactionState*>((*it).second);
658
                        if (ts)
659
                                delete (*it).first; // delete TransactionObject
1197 tsoots 660
                        delete (*it).second;
661
                        stacks[currentDoc].second.erase(it);
662
                        emit popBack();
663
                }
664
        }
665
}
666
 
1111 tsoots 667
void UndoManager::deleteInstance()
668
{
669
        if (_instance)
670
                delete _instance;
671
        _instance = NULL;
672
}
673
 
674
UndoManager::~UndoManager()
675
{
676
        StackMap::iterator it;
677
        for (it = stacks.begin(); it != stacks.end(); ++it)
678
        {
679
                for (uint i = 0; i < (*it).second.size(); ++i)
680
                {
681
                        delete ((*it).second)[i].second;
682
                        ((*it).second)[i].second = NULL;
683
                }
684
        }
685
}
1190 tsoots 686
 
2199 cbradney 687
 
2198 cbradney 688
void UndoManager::languageChange()
689
{
2199 cbradney 690
        UndoManager::AddVGuide          = tr("Add vertical guide");
691
        UndoManager::AddHGuide          = tr("Add horizontal guide");
692
        UndoManager::DelVGuide          = tr("Remove vertical guide");
693
        UndoManager::DelHGuide          = tr("Remove horizontal guide");
694
        UndoManager::MoveVGuide         = tr("Move vertical guide");
695
        UndoManager::MoveHGuide         = tr("Move horizontal guide");
696
        UndoManager::LockGuides         = tr("Lock guides");
697
        UndoManager::UnlockGuides       = tr("Unlock guides");
698
        UndoManager::Move               = tr("Move");
699
        UndoManager::Resize             = tr("Resize");
700
        UndoManager::Rotate             = tr("Rotate");
701
        UndoManager::MoveFromTo         = tr("X1: %1, Y1: %2, %3\nX2: %4, Y2: %5, %6");
702
        UndoManager::ResizeFromTo       = tr("W1: %1, H1: %2\nW2: %3, H2: %4");
703
        UndoManager::Selection          = tr("Selection");
704
        UndoManager::Group              = tr("Group");
705
        UndoManager::SelectionGroup     = tr("Selection/Group");
706
        UndoManager::Create             = tr("Create");
707
        UndoManager::CreateTo           = tr("X: %1, Y: %2\nW: %3, H: %4");
708
        UndoManager::AlignDistribute    = tr("Align/Distribute");
709
        UndoManager::ItemsInvolved      = tr("Items involved");
710
        UndoManager::Cancel             = tr("Cancel");
711
        UndoManager::SetFill            = tr("Set fill color");
712
        UndoManager::ColorFromTo        = tr("Color1: %1, Color2: %2");
713
        UndoManager::SetShade           = tr("Set fill color shade");
714
        UndoManager::SetLineColor       = tr("Set line color");
715
        UndoManager::SetLineShade       = tr("Set line color shade");
716
        UndoManager::FlipH              = tr("Flip horizontally");
717
        UndoManager::FlipV              = tr("Flip vertically");
718
        UndoManager::Lock               = tr("Lock");
719
        UndoManager::UnLock             = tr("Unlock");
720
        UndoManager::SizeLock           = tr("Lock size");
721
        UndoManager::SizeUnLock         = tr("Unlock size");
722
        UndoManager::Ungroup            = tr("Ungroup");
723
        UndoManager::Delete             = tr("Delete");
724
        UndoManager::Rename             = tr("Rename");
725
        UndoManager::FromTo             = tr("From %1\nto %2");
726
        UndoManager::ApplyMasterPage    = tr("Apply Master Page");
727
        UndoManager::Paste              = tr("Paste");
728
        UndoManager::Cut                = tr("Cut");
729
        UndoManager::Transparency       = tr("Set fill color transparency");
730
        UndoManager::LineTransparency   = tr("Set line color transparency");
731
        UndoManager::LineStyle          = tr("Set line style");
732
        UndoManager::LineEnd            = tr("Set the style of line end");
733
        UndoManager::LineJoin           = tr("Set the style of line join");
734
        UndoManager::LineWidth          = tr("Set line width");
735
        UndoManager::NoStyle            = tr("No style");
736
        UndoManager::CustomLineStyle    = tr("Set custom line style");
737
        UndoManager::NoLineStyle        = tr("Do not use custom line style");
738
        UndoManager::StartArrow         = tr("Set start arrow");
739
        UndoManager::EndArrow           = tr("Set end arrow");
740
        UndoManager::CreateTable        = tr("Create table");
741
        UndoManager::RowsCols           = tr("Rows: %1, Cols: %2");
742
        UndoManager::SetFont            = tr("Set font");
743
        UndoManager::SetFontSize        = tr("Set font size");
744
        UndoManager::SetFontWidth       = tr("Set font width");
745
        UndoManager::SetFontFill        = tr("Set font fill color");
746
        UndoManager::SetFontStroke      = tr("Set font stroke color");
747
        UndoManager::SetFontFillShade   = tr("Set font fill color shade");
748
        UndoManager::SetFontStrokeShade = tr("Set font stroke color shade");
749
        UndoManager::SetKerning         = tr("Set kerning");
750
        UndoManager::SetLineSpacing     = tr("Set line spacing");
751
        UndoManager::SetStyle           = tr("Set paragraph style");
752
        UndoManager::SetLanguage        = tr("Set language");
753
        UndoManager::AlignText          = tr("Align text");
754
        UndoManager::SetFontEffect      = tr("Set font effect");
755
        UndoManager::ImageFrame         = tr("Image frame");
756
        UndoManager::TextFrame          = tr("Text frame");
757
        UndoManager::Polygon            = tr("Polygon");
758
        UndoManager::BezierCurve        = tr("Bezier curve");
759
        UndoManager::Polyline           = tr("Polyline");
760
        UndoManager::ConvertTo          = tr("Convert to");
761
        UndoManager::ImportSVG          = tr("Import SVG image");
762
        UndoManager::ImportEPS          = tr("Import EPS image");
2217 cbradney 763
        UndoManager::ImportOOoDraw      = tr("Import OpenOffice.org Draw image");
2199 cbradney 764
        UndoManager::ScratchSpace       = tr("Scratch space");
765
        UndoManager::TextFlow           = tr("Text flows around the frame");
766
        UndoManager::BoundingBox        = tr("Text flows around bounding box");
767
        UndoManager::ContourLine        = tr("Text flows around contour line");
768
        UndoManager::NoTextFlow         = tr("No text flow");
769
        UndoManager::NoBoundingBox      = tr("No bounding box");
770
        UndoManager::NoContourLine      = tr("No contour line");
771
        UndoManager::PageNmbr           = tr("Page %1");
772
        UndoManager::ImageScaling       = tr("Set image scaling");
773
        UndoManager::FrameSize          = tr("Frame size");
774
        UndoManager::FreeScaling        = tr("Free scaling");
775
        UndoManager::KeepRatio          = tr("Keep aspect ratio");
776
        UndoManager::BreakRatio         = tr("Break aspect ratio");
777
        UndoManager::EditContourLine    = tr("Edit contour line");
778
        UndoManager::EditShape          = tr("Edit shape");
779
        UndoManager::ResetContourLine   = tr("Reset contour line");
780
        UndoManager::AddPage            = tr("Add page");
781
        UndoManager::AddPages           = tr("Add pages");
782
        UndoManager::DeletePage         = tr("Delete page");
783
        UndoManager::DeletePages        = tr("Delete pages");
784
        UndoManager::AddLayer           = tr("Add layer");
785
        UndoManager::DeleteLayer        = tr("Delete layer");
786
        UndoManager::RenameLayer        = tr("Rename layer");
787
        UndoManager::RaiseLayer         = tr("Raise layer");
788
        UndoManager::LowerLayer         = tr("Lower layer");
789
        UndoManager::SendToLayer        = tr("Send to layer");
790
        UndoManager::PrintLayer         = tr("Enable printing of layer");
791
        UndoManager::DoNotPrintLayer    = tr("Disable printing of layer");
792
        UndoManager::SetLayerName       = tr("Change name of the layer");
793
        UndoManager::GetImage           = tr("Get image");
2198 cbradney 794
}
795
 
1213 tsoots 796
/*** UndoManager::TransactionState *****************************************************/
797
 
1226 tsoots 798
UndoManager::TransactionState::TransactionState() : UndoState("")
1213 tsoots 799
{
800
        _size = 0;
801
}
802
 
803
ActionPair* UndoManager::TransactionState::at(int index)
804
{
805
        if (index >= 0 && static_cast<uint>(index) < sizet())
806
                return states[index];
807
        else
808
                return NULL;
809
}
810
 
1443 tsoots 811
bool UndoManager::TransactionState::contains(int uid)
812
{
813
        bool ret = false;
814
        for (uint i = 0; i < states.size(); ++i)
815
        {
816
                if (states[i]->first->getUId() == static_cast<uint>(uid))
817
                {
818
                        ret = true;
819
                        break;
820
                }
821
        }
822
        return ret;
823
}
824
 
1213 tsoots 825
void UndoManager::TransactionState::pushBack(UndoObject *target, UndoState *state)
826
{
827
        if (target && state)
828
        {
829
                states.push_back(new ActionPair(target, state));
830
                ++_size;
831
        }
832
}
833
 
834
uint UndoManager::TransactionState::sizet()
835
{
836
        return _size;
837
}
838
 
1226 tsoots 839
void UndoManager::TransactionState::useActionName()
840
{
841
        if (_size > 0)
842
        {
843
                setName(states[_size - 1]->second->getName());
844
        }
845
}
846
 
1658 tsoots 847
UndoObject* UndoManager::TransactionState::replace(ulong uid, UndoObject *newUndoObject)
1238 tsoots 848
{
1658 tsoots 849
        UndoObject *tmp = NULL;
1238 tsoots 850
        for (uint i = 0; i < states.size(); ++i)
1658 tsoots 851
        {
1663 tsoots 852
                TransactionState *ts = dynamic_cast<TransactionState*>(states[i]->second);
853
                if (ts) // are we having a transaction inside a transaction
854
                        ts->replace(uid, newUndoObject);
855
                else if (states[i]->first && states[i]->first->getUId() == uid)
1658 tsoots 856
                {
857
                        tmp = states[i]->first;
1238 tsoots 858
                        states[i]->first = newUndoObject;
1658 tsoots 859
                }
860
        }
861
        return tmp;
1238 tsoots 862
}
863
 
1213 tsoots 864
UndoManager::TransactionState::~TransactionState()
865
{
866
        for (uint i = 0; i < states.size(); ++i)
867
        {
1226 tsoots 868
                if (states[i])
869
                {
870
                        if (states[i]->second)
871
                        {
872
                                delete states[i]->second;
873
                                states[i]->second = NULL;
874
                        }
875
                        delete states[i];
876
                        states[i] = NULL;
877
                }
1213 tsoots 878
        }
879
}
880
 
881
/*************************************************************************************/
882
 
1190 tsoots 883
void UndoManager::initIcons()
884
{
1693 craig 885
        QString iconDir = ScPaths::instance().iconDir();
1247 tsoots 886
 
1250 tsoots 887
/*** Icons for UndoObjects *******************************************/
888
        UndoManager::IImageFrame      = new QPixmap(iconDir + "Bild.xpm");
889
        UndoManager::ITextFrame       = new QPixmap(iconDir + "Text.xpm");
890
        UndoManager::ILine            = new QPixmap(iconDir + "Stift.xpm");
891
        UndoManager::IPolygon         = new QPixmap(iconDir + "spline.png");
892
        UndoManager::IPolyline        = new QPixmap(iconDir + "beziertool.png");
893
//      UndoManager::IPathText        = new QPixmap(iconDir + "?";
1254 tsoots 894
        UndoManager::IGroup           = new QPixmap(iconDir + "u_group.png");
1250 tsoots 895
/*** Icons for actions ***********************************************/
896
        UndoManager::IMove            = new QPixmap(iconDir + "u_move.png");
897
        UndoManager::IResize          = new QPixmap(iconDir + "u_resize.png");
898
        UndoManager::IRotate          = new QPixmap(iconDir + "u_rotate.png");
1247 tsoots 899
        UndoManager::IAlignDistribute = new QPixmap(iconDir + "u_align.png");
1250 tsoots 900
        UndoManager::IGuides          = new QPixmap(iconDir + "u_margins.png");
901
        UndoManager::ILockGuides      = new QPixmap(iconDir + "u_margins_locked.png");
1286 tsoots 902
        UndoManager::IFill            = new QPixmap(iconDir + "u_fill.png");
903
        UndoManager::IShade           = new QPixmap(iconDir + "u_shade.png");
1340 tsoots 904
        UndoManager::IFlipH           = new QPixmap(iconDir + "u_fliph.png");
905
        UndoManager::IFlipV           = new QPixmap(iconDir + "u_flipv.png");
1290 tsoots 906
        UndoManager::ILock            = new QPixmap(iconDir + "u_lock.png");
907
        UndoManager::IUnLock          = new QPixmap(iconDir + "u_unlock.png");
1340 tsoots 908
        UndoManager::IDelete          = new QPixmap(iconDir + "u_delete.png");
909
        UndoManager::ICreate          = new QPixmap(iconDir + "u_create.png");
1369 tsoots 910
        UndoManager::IPaste           = new QPixmap(iconDir + "editpaste.png");
911
        UndoManager::ICut             = new QPixmap(iconDir + "u_cut.png");
1371 tsoots 912
        UndoManager::ITransparency    = new QPixmap(iconDir + "u_transp.png");
1383 tsoots 913
        UndoManager::ILineStyle       = new QPixmap(iconDir + "u_line.png");
1391 tsoots 914
        UndoManager::IArrow           = new QPixmap(iconDir + "u_arrow.png");
1396 tsoots 915
        UndoManager::ITable           = new QPixmap(iconDir + "frame_table.png");
1399 tsoots 916
        UndoManager::IFont            = new QPixmap(iconDir + "u_font.png");
1440 tsoots 917
        UndoManager::IImportOOoDraw   = new QPixmap(iconDir + "ooo_draw.png");
918
        UndoManager::ISVG             = new QPixmap(iconDir + "u_svg.png");
919
        UndoManager::IEPS             = new QPixmap(iconDir + "u_eps.png");
1495 tsoots 920
        UndoManager::IImageScaling    = new QPixmap(iconDir + "u_scale_image.png");
1509 tsoots 921
        UndoManager::IBorder          = new QPixmap(iconDir + "u_shape.png");
1664 tsoots 922
        UndoManager::IDocument        = new QPixmap(iconDir + "DateiNeu.xpm");
1688 tsoots 923
//      UndoManager::ILayer           = new QPixmap(iconDir + "u_layer.png");
924
//      UndoManager::ILayerAction     = new QPixmap(iconDir + "u_layer_action.png");
1697 tsoots 925
//      UndoManager::IUp              = new QPixmap(iconDir + "u_up.png");
926
//      UndoManager::IDown            = new QPixmap(iconDir + "u_down.png");
1832 tsoots 927
//      UndoManager::IGetImage        = new QPixmap(iconDir + "u_get_image.png");
1190 tsoots 928
}
2199 cbradney 929
QString UndoManager::AddVGuide          = "";
930
QString UndoManager::AddHGuide          = "";
931
QString UndoManager::DelVGuide          = "";
932
QString UndoManager::DelHGuide          = "";
933
QString UndoManager::MoveVGuide         = "";
934
QString UndoManager::MoveHGuide         = "";
935
QString UndoManager::LockGuides         = "";
936
QString UndoManager::UnlockGuides       = "";
937
QString UndoManager::Move               = "";
938
QString UndoManager::Resize             = "";
939
QString UndoManager::Rotate             = "";
940
QString UndoManager::MoveFromTo         = "";
941
QString UndoManager::ResizeFromTo       = "";
942
QString UndoManager::Selection          = "";
943
QString UndoManager::Group              = "";
944
QString UndoManager::SelectionGroup     = "";
945
QString UndoManager::Create             = "";
946
QString UndoManager::CreateTo           = "";
947
QString UndoManager::AlignDistribute    = "";
948
QString UndoManager::ItemsInvolved      = "";
949
QString UndoManager::Cancel             = "";
950
QString UndoManager::SetFill            = "";
951
QString UndoManager::ColorFromTo        = "";
952
QString UndoManager::SetShade           = "";
953
QString UndoManager::SetLineColor       = "";
954
QString UndoManager::SetLineShade       = "";
955
QString UndoManager::FlipH              = "";
956
QString UndoManager::FlipV              = "";
957
QString UndoManager::Lock               = "";
958
QString UndoManager::UnLock             = "";
959
QString UndoManager::SizeLock           = "";
960
QString UndoManager::SizeUnLock         = "";
961
QString UndoManager::Ungroup            = "";
962
QString UndoManager::Delete             = "";
963
QString UndoManager::Rename             = "";
964
QString UndoManager::FromTo             = "";
965
QString UndoManager::ApplyMasterPage    = "";
966
QString UndoManager::Paste              = "";
967
QString UndoManager::Cut                = "";
968
QString UndoManager::Transparency       = "";
969
QString UndoManager::LineTransparency   = "";
970
QString UndoManager::LineStyle          = "";
971
QString UndoManager::LineEnd            = "";
972
QString UndoManager::LineJoin           = "";
973
QString UndoManager::LineWidth          = "";
974
QString UndoManager::NoStyle            = "";
975
QString UndoManager::CustomLineStyle    = "";
976
QString UndoManager::NoLineStyle        = "";
977
QString UndoManager::StartArrow         = "";
978
QString UndoManager::EndArrow           = "";
979
QString UndoManager::CreateTable        = "";
980
QString UndoManager::RowsCols           = "";
981
QString UndoManager::SetFont            = "";
982
QString UndoManager::SetFontSize        = "";
983
QString UndoManager::SetFontWidth       = "";
984
QString UndoManager::SetFontFill        = "";
985
QString UndoManager::SetFontStroke      = "";
986
QString UndoManager::SetFontFillShade   = "";
987
QString UndoManager::SetFontStrokeShade = "";
988
QString UndoManager::SetKerning         = "";
989
QString UndoManager::SetLineSpacing     = "";
990
QString UndoManager::SetStyle           = "";
991
QString UndoManager::SetLanguage        = "";
992
QString UndoManager::AlignText          = "";
993
QString UndoManager::SetFontEffect      = "";
994
QString UndoManager::ImageFrame         = "";
995
QString UndoManager::TextFrame          = "";
996
QString UndoManager::Polygon            = "";
997
QString UndoManager::BezierCurve        = "";
998
QString UndoManager::Polyline           = "";
999
QString UndoManager::ConvertTo          = "";
1000
QString UndoManager::ImportSVG          = "";
1001
QString UndoManager::ImportEPS          = "";
1002
QString UndoManager::ImportOOoDraw      = "";
1003
QString UndoManager::ScratchSpace       = "";
1004
QString UndoManager::TextFlow           = "";
1005
QString UndoManager::BoundingBox        = "";
1006
QString UndoManager::ContourLine        = "";
1007
QString UndoManager::NoTextFlow         = "";
1008
QString UndoManager::NoBoundingBox      = "";
1009
QString UndoManager::NoContourLine      = "";
1010
QString UndoManager::PageNmbr           = "";
1011
QString UndoManager::ImageScaling       = "";
1012
QString UndoManager::FrameSize          = "";
1013
QString UndoManager::FreeScaling        = "";
1014
QString UndoManager::KeepRatio          = "";
1015
QString UndoManager::BreakRatio         = "";
1016
QString UndoManager::EditContourLine    = "";
1017
QString UndoManager::EditShape          = "";
1018
QString UndoManager::ResetContourLine   = "";
1019
QString UndoManager::AddPage            = "";
1020
QString UndoManager::AddPages           = "";
1021
QString UndoManager::DeletePage         = "";
1022
QString UndoManager::DeletePages        = "";
1023
QString UndoManager::AddLayer           = "";
1024
QString UndoManager::DeleteLayer        = "";
1025
QString UndoManager::RenameLayer        = "";
1026
QString UndoManager::RaiseLayer         = "";
1027
QString UndoManager::LowerLayer         = "";
1028
QString UndoManager::SendToLayer        = "";
1029
QString UndoManager::PrintLayer         = "";
1030
QString UndoManager::DoNotPrintLayer    = "";
1031
QString UndoManager::SetLayerName       = "";
1032
QString UndoManager::GetImage           = "";
1033
/*
1402 tsoots 1034
const QString UndoManager::AddVGuide          = tr("Add vertical guide");
1035
const QString UndoManager::AddHGuide          = tr("Add horizontal guide");
1036
const QString UndoManager::DelVGuide          = tr("Remove vertical guide");
1037
const QString UndoManager::DelHGuide          = tr("Remove horizontal guide");
1038
const QString UndoManager::MoveVGuide         = tr("Move vertical guide");
1039
const QString UndoManager::MoveHGuide         = tr("Move horizontal guide");
1040
const QString UndoManager::LockGuides         = tr("Lock guides");
1041
const QString UndoManager::UnlockGuides       = tr("Unlock guides");
1042
const QString UndoManager::Move               = tr("Move");
1043
const QString UndoManager::Resize             = tr("Resize");
1044
const QString UndoManager::Rotate             = tr("Rotate");
1490 tsoots 1045
const QString UndoManager::MoveFromTo         = tr("X1: %1, Y1: %2, %3\nX2: %4, Y2: %5, %6");
1402 tsoots 1046
const QString UndoManager::ResizeFromTo       = tr("W1: %1, H1: %2\nW2: %3, H2: %4");
1047
const QString UndoManager::Selection          = tr("Selection");
1048
const QString UndoManager::Group              = tr("Group");
1049
const QString UndoManager::SelectionGroup     = tr("Selection/Group");
1050
const QString UndoManager::Create             = tr("Create");
1051
const QString UndoManager::CreateTo           = tr("X: %1, Y: %2\nW: %3, H: %4");
1052
const QString UndoManager::AlignDistribute    = tr("Align/Distribute");
1053
const QString UndoManager::ItemsInvolved      = tr("Items involved");
1054
const QString UndoManager::Cancel             = tr("Cancel");
1055
const QString UndoManager::SetFill            = tr("Set fill color");
1056
const QString UndoManager::ColorFromTo        = tr("Color1: %1, Color2: %2");
1057
const QString UndoManager::SetShade           = tr("Set fill color shade");
1058
const QString UndoManager::SetLineColor       = tr("Set line color");
1059
const QString UndoManager::SetLineShade       = tr("Set line color shade");
1060
const QString UndoManager::FlipH              = tr("Flip horizontally");
1061
const QString UndoManager::FlipV              = tr("Flip vertically");
1062
const QString UndoManager::Lock               = tr("Lock");
1063
const QString UndoManager::UnLock             = tr("Unlock");
1064
const QString UndoManager::SizeLock           = tr("Lock size");
1065
const QString UndoManager::SizeUnLock         = tr("Unlock size");
1066
const QString UndoManager::Ungroup            = tr("Ungroup");
1067
const QString UndoManager::Delete             = tr("Delete");
1068
const QString UndoManager::Rename             = tr("Rename");
1069
const QString UndoManager::FromTo             = tr("From %1\nto %2");
2093 cbradney 1070
const QString UndoManager::ApplyMasterPage    = tr("Apply Master Page");
1402 tsoots 1071
const QString UndoManager::Paste              = tr("Paste");
1072
const QString UndoManager::Cut                = tr("Cut");
1073
const QString UndoManager::Transparency       = tr("Set fill color transparency");
1074
const QString UndoManager::LineTransparency   = tr("Set line color transparency");
1075
const QString UndoManager::LineStyle          = tr("Set line style");
1076
const QString UndoManager::LineEnd            = tr("Set the style of line end");
1077
const QString UndoManager::LineJoin           = tr("Set the style of line join");
1078
const QString UndoManager::LineWidth          = tr("Set line width");
1079
const QString UndoManager::NoStyle            = tr("No style");
1080
const QString UndoManager::CustomLineStyle    = tr("Set custom line style");
1081
const QString UndoManager::NoLineStyle        = tr("Do not use custom line style");
1082
const QString UndoManager::StartArrow         = tr("Set start arrow");
1083
const QString UndoManager::EndArrow           = tr("Set end arrow");
1084
const QString UndoManager::CreateTable        = tr("Create table");
1085
const QString UndoManager::RowsCols           = tr("Rows: %1, Cols: %2");
1086
const QString UndoManager::SetFont            = tr("Set font");
1087
const QString UndoManager::SetFontSize        = tr("Set font size");
1088
const QString UndoManager::SetFontWidth       = tr("Set font width");
1089
const QString UndoManager::SetFontFill        = tr("Set font fill color");
1090
const QString UndoManager::SetFontStroke      = tr("Set font stroke color");
1091
const QString UndoManager::SetFontFillShade   = tr("Set font fill color shade");
1092
const QString UndoManager::SetFontStrokeShade = tr("Set font stroke color shade");
1403 tsoots 1093
const QString UndoManager::SetKerning         = tr("Set kerning");
1094
const QString UndoManager::SetLineSpacing     = tr("Set line spacing");
1095
const QString UndoManager::SetStyle           = tr("Set paragraph style");
1096
const QString UndoManager::SetLanguage        = tr("Set language");
1404 tsoots 1097
const QString UndoManager::AlignText          = tr("Align text");
1415 tsoots 1098
const QString UndoManager::SetFontEffect      = tr("Set font effect");
1416 tsoots 1099
const QString UndoManager::ImageFrame         = tr("Image frame");
1100
const QString UndoManager::TextFrame          = tr("Text frame");
1101
const QString UndoManager::Polygon            = tr("Polygon");
1102
const QString UndoManager::BezierCurve        = tr("Bezier curve");
1103
const QString UndoManager::Polyline           = tr("Polyline");
1104
const QString UndoManager::ConvertTo          = tr("Convert to");
1434 tsoots 1105
const QString UndoManager::ImportSVG          = tr("Import SVG image");
1106
const QString UndoManager::ImportEPS          = tr("Import EPS image");
2217 cbradney 1107
const QString UndoManager::ImportOOoDraw      = tr("Import OpenOffice.org Draw image");
1485 tsoots 1108
const QString UndoManager::ScratchSpace       = tr("Scratch space");
1489 tsoots 1109
const QString UndoManager::TextFlow           = tr("Text flows around the frame");
1110
const QString UndoManager::BoundingBox        = tr("Text flows around bounding box");
1111
const QString UndoManager::ContourLine        = tr("Text flows around contour line");
1112
const QString UndoManager::NoTextFlow         = tr("No text flow");
1113
const QString UndoManager::NoBoundingBox      = tr("No bounding box");
1114
const QString UndoManager::NoContourLine      = tr("No contour line");
1490 tsoots 1115
const QString UndoManager::PageNmbr           = tr("Page %1");
1495 tsoots 1116
const QString UndoManager::ImageScaling       = tr("Set image scaling");
1117
const QString UndoManager::FrameSize          = tr("Frame size");
1118
const QString UndoManager::FreeScaling        = tr("Free scaling");
1119
const QString UndoManager::KeepRatio          = tr("Keep aspect ratio");
1120
const QString UndoManager::BreakRatio         = tr("Break aspect ratio");
1509 tsoots 1121
const QString UndoManager::EditContourLine    = tr("Edit contour line");
1122
const QString UndoManager::EditShape          = tr("Edit shape");
1518 tsoots 1123
const QString UndoManager::ResetContourLine   = tr("Reset contour line");
1663 tsoots 1124
const QString UndoManager::AddPage            = tr("Add page");
1125
const QString UndoManager::AddPages           = tr("Add pages");
1126
const QString UndoManager::DeletePage         = tr("Delete page");
1127
const QString UndoManager::DeletePages        = tr("Delete pages");
1688 tsoots 1128
const QString UndoManager::AddLayer           = tr("Add layer");
1129
const QString UndoManager::DeleteLayer        = tr("Delete layer");
1130
const QString UndoManager::RenameLayer        = tr("Rename layer");
1697 tsoots 1131
const QString UndoManager::RaiseLayer         = tr("Raise layer");
1132
const QString UndoManager::LowerLayer         = tr("Lower layer");
1688 tsoots 1133
const QString UndoManager::SendToLayer        = tr("Send to layer");
1697 tsoots 1134
const QString UndoManager::PrintLayer         = tr("Enable printing of layer");
1135
const QString UndoManager::DoNotPrintLayer    = tr("Disable printing of layer");
1700 tsoots 1136
const QString UndoManager::SetLayerName       = tr("Change name of the layer");
1832 tsoots 1137
const QString UndoManager::GetImage           = tr("Get image");
2199 cbradney 1138
*/
1250 tsoots 1139
/*** Icons for UndoObjects *******************************************/
1140
QPixmap *UndoManager::IImageFrame      = NULL;
1141
QPixmap *UndoManager::ITextFrame       = NULL;
1142
QPixmap *UndoManager::ILine            = NULL;
1143
QPixmap *UndoManager::IPolygon         = NULL;
1144
QPixmap *UndoManager::IPolyline        = NULL;
1145
QPixmap *UndoManager::IPathText        = NULL;
1254 tsoots 1146
QPixmap *UndoManager::IGroup           = NULL;
1396 tsoots 1147
QPixmap *UndoManager::ITable           = NULL;
1250 tsoots 1148
/*** Icons for actions ***********************************************/
1149
QPixmap *UndoManager::IMove            = NULL;
1150
QPixmap *UndoManager::IResize          = NULL;
1151
QPixmap *UndoManager::IRotate          = NULL;
1247 tsoots 1152
QPixmap *UndoManager::IGuides          = NULL;
1153
QPixmap *UndoManager::ILockGuides      = NULL;
1154
QPixmap *UndoManager::IAlignDistribute = NULL;
1286 tsoots 1155
QPixmap *UndoManager::IFill            = NULL;
1156
QPixmap *UndoManager::IShade           = NULL;
1287 tsoots 1157
QPixmap *UndoManager::IFlipH           = NULL;
1158
QPixmap *UndoManager::IFlipV           = NULL;
1290 tsoots 1159
QPixmap *UndoManager::ILock            = NULL;
1160
QPixmap *UndoManager::IUnLock          = NULL;
1340 tsoots 1161
QPixmap *UndoManager::IDelete          = NULL;
1162
QPixmap *UndoManager::ICreate          = NULL;
1369 tsoots 1163
QPixmap *UndoManager::IPaste           = NULL;
1164
QPixmap *UndoManager::ICut             = NULL;
1371 tsoots 1165
QPixmap *UndoManager::ITransparency    = NULL;
1383 tsoots 1166
QPixmap *UndoManager::ILineStyle       = NULL;
1391 tsoots 1167
QPixmap *UndoManager::IArrow           = NULL;
1399 tsoots 1168
QPixmap *UndoManager::IFont            = NULL;
1440 tsoots 1169
QPixmap *UndoManager::ISVG             = NULL;
1170
QPixmap *UndoManager::IEPS             = NULL;
1434 tsoots 1171
QPixmap *UndoManager::IImportOOoDraw   = NULL;
1495 tsoots 1172
QPixmap *UndoManager::IImageScaling    = NULL;
1509 tsoots 1173
QPixmap *UndoManager::IBorder          = NULL;
1658 tsoots 1174
QPixmap *UndoManager::IDocument        = NULL;
1688 tsoots 1175
QPixmap *UndoManager::ILayer           = NULL;
1176
QPixmap *UndoManager::ILayerAction     = NULL;
1697 tsoots 1177
QPixmap *UndoManager::IUp              = NULL;
1178
QPixmap *UndoManager::IDown            = NULL;
1179
QPixmap *UndoManager::IPrint           = NULL;
1832 tsoots 1180
QPixmap *UndoManager::IGetImage        = NULL;
1658 tsoots 1181