Subversion Repositories Scribus

Rev

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