Back to index

scribus-ng  1.3.4.dfsg+svn20071115
undomanager.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /***************************************************************************
00008  *   Copyright (C) 2005 by Riku Leino                                      *
00009  *   riku@scribus.info                                                     *
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  *   This program is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00019  *   GNU General Public License for more details.                          *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU General Public License     *
00022  *   along with this program; if not, write to the                         *
00023  *   Free Software Foundation, Inc.,                                       *
00024  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00025  ***************************************************************************/
00026 
00027 #include "undomanager.h"
00028 #include "undomanager.moc"
00029 #include "undogui.h"
00030 #include "scconfig.h"
00031 #include "prefsmanager.h"
00032 #include "prefscontext.h"
00033 #include "prefsfile.h"
00034 #include "scraction.h"
00035 #include "scribuscore.h"
00036 #include "undostack.h"
00037 #include <qvaluelist.h>
00038 
00039 #include "scpaths.h"
00040 
00041 extern QPixmap loadIcon(QString nam);
00042 
00043 UndoManager* UndoManager::instance_          = 0;
00044 bool         UndoManager::undoEnabled_       = true;
00045 int          UndoManager::undoEnabledCounter_ = 0;
00046 
00047 UndoManager* UndoManager::instance()
00048 {
00049        if (instance_ == 0)
00050               instance_ = new UndoManager();
00051 
00052        return instance_;
00053 }
00054 
00055 void UndoManager::setUndoEnabled(bool isEnabled)
00056 {
00057        if (isEnabled && undoEnabledCounter_ == 0)
00058               return; // nothing to do undo is already enabled.
00059        else if (isEnabled && undoEnabledCounter_ > 0)
00060               --undoEnabledCounter_;
00061        else if (!isEnabled)
00062               ++undoEnabledCounter_;
00063 
00064        undoEnabled_ = undoEnabledCounter_ == 0;
00065        if (undoEnabled_)
00066               connectGuis();
00067        else if (undoEnabledCounter_ == 1)
00068               disconnectGuis(); // disconnect only once when setUndoEnabled(false) has been called
00069                                 // no need to call again if next setUndoEnabled() call will also be false.
00070 }
00071 
00072 bool UndoManager::undoEnabled()
00073 {
00074        return undoEnabled_;
00075 }
00076 
00077 UndoManager::UndoManager()
00078 {
00079        currentUndoObjectId_ = -1;
00080        if (!UndoManager::IGuides)
00081               initIcons();
00082        prefs_ = PrefsManager::instance()->prefsFile->getContext("undo");
00083        transaction_= 0;
00084        transactionTarget_ = 0;
00085        languageChange();
00086        setUndoEnabled(prefs_->getBool("enabled", true));
00087 }
00088 
00089 void UndoManager::beginTransaction(const QString &targetName,
00090                                    QPixmap *targetPixmap,
00091                                    const QString &name,
00092                                    const QString &description,
00093                                    QPixmap *actionPixmap)
00094 {
00095        if (!undoEnabled_)
00096               return;
00097        if (transaction_) // begin a transaction_inside transaction
00098               transactions_.push_back(
00099                      std::pair<TransactionObject*, TransactionState*>(transactionTarget_, transaction_));
00100        transaction_= new TransactionState();
00101        transactionTarget_ = new TransactionObject();
00102        transactionTarget_->setUName(targetName); // Name which will be in action history
00103        if (targetPixmap)
00104               transactionTarget_->setUPixmap(targetPixmap);
00105        if (name.length() > 0)          // if left to 0 length action will be fetched from the
00106               transaction_->setName(name); // last added UndoState in this transaction
00107        if (description.length() > 0)
00108               transaction_->setDescription(description); // tool tip for action history
00109        if (actionPixmap)
00110               transaction_->setPixmap(actionPixmap); // for action history
00111 }
00112 
00113 void UndoManager::cancelTransaction()
00114 {
00115        delete transaction_;
00116        transaction_= 0;
00117        delete transactionTarget_;
00118        transactionTarget_ = 0;
00119        if (!transactions_.empty())
00120        {
00121               // fetch the next transaction_from the vector
00122               transactionTarget_ = transactions_[transactions_.size() - 1].first;
00123               transaction_= transactions_[transactions_.size() - 1].second;
00124 //            delete transactions_[transactions_.size() - 1];
00125               transactions_.erase(transactions_.end() - 1);
00126        }
00127 }
00128 
00129 void UndoManager::commit(const QString &targetName,
00130                          QPixmap *targetPixmap,
00131                          const QString &name,
00132                          const QString &description,
00133                          QPixmap *actionPixmap)
00134 {
00135        if (!transaction_ || !transactionTarget_ || !undoEnabled_)
00136        {
00137               cancelTransaction();
00138               return;
00139        }
00140        if (targetName.length() > 0)
00141               transactionTarget_->setUName(targetName);
00142        if (targetPixmap)
00143               transactionTarget_->setUPixmap(targetPixmap);
00144        if (name.length() > 0)
00145               transaction_->setName(name);
00146        if (description.length() > 0)
00147               transaction_->setDescription(description);
00148        if (actionPixmap)
00149               transaction_->setPixmap(actionPixmap);
00150 
00151        UndoObject *tmpu = transactionTarget_;
00152        TransactionState *tmps = transaction_;
00153 
00154        if (!transactions_.empty())
00155        {
00156               // fetch the next transaction_to be an active transaction
00157               transactionTarget_ = transactions_[transactions_.size() - 1].first;
00158               transaction_= transactions_[transactions_.size() - 1].second;
00159 //            delete transactions_[transactions_.size() - 1]
00160               transactions_.erase(transactions_.end() - 1);
00161        }
00162        else
00163        {
00164               transaction_ = 0;
00165               transactionTarget_ = 0;
00166        }
00167 
00168        if (tmps->sizet() > 0) // are there any actions inside the commited transaction
00169        {
00170               if (tmps->getName().isEmpty())
00171                      tmps->useActionName();
00172               action(tmpu, tmps);
00173        } // if not just delete objects
00174        else
00175        {
00176               delete tmpu;
00177               tmpu = 0;
00178               delete tmps;
00179               tmps = 0;
00180        }
00181 }
00182 
00183 bool UndoManager::isTransactionMode()
00184 {
00185        return transaction_ ? true : false;
00186 }
00187 
00188 void UndoManager::registerGui(UndoGui* gui)
00189 {
00190        if (gui == 0)
00191               return;
00192 
00193        setUndoEnabled(false);
00194        setState(gui);
00195        undoGuis_.push_back(gui);
00196        setUndoEnabled(true);
00197 }
00198 
00199 void UndoManager::setState(UndoGui* gui, int uid)
00200 {
00201        gui->clear();
00202 
00203        if ( stacks_[currentDoc_].size() == 0 )
00204               return;
00205 
00206        StateList::iterator itstartU = stacks_[currentDoc_].undoActions_.begin(); // undo actions
00207        StateList::iterator itendU   = stacks_[currentDoc_].undoActions_.end();
00208 
00209        StateList::iterator itstartR = stacks_[currentDoc_].redoActions_.begin(); // redo actions
00210        StateList::iterator itendR   = stacks_[currentDoc_].redoActions_.end();
00211 
00212        if (uid > -1)
00213        { // find the range from where actions are added when in obj. spec. mode
00214               StateList::iterator it2;
00215               for (it2 = stacks_[currentDoc_].undoActions_.begin();
00216                    it2 != stacks_[currentDoc_].undoActions_.end(); ++it2)
00217               {
00218                      UndoState*  tmp  = *it2;
00219                      TransactionState *ts = dynamic_cast<TransactionState*>(tmp);
00220                      if (ts && !ts->containsOnly(uid))
00221                      {
00222                             if (it2 != stacks_[currentDoc_].undoActions_.begin())
00223                                    itendU = --it2;
00224                             break;
00225                      }
00226               }
00227               StateList::iterator it3;
00228               for (it3 = stacks_[currentDoc_].redoActions_.begin();
00229                    it3 != stacks_[currentDoc_].redoActions_.end(); ++it3)
00230               {
00231                      UndoState*  tmp  = *it3;
00232                      TransactionState *ts = dynamic_cast<TransactionState*>(tmp);
00233                      if (ts && !ts->containsOnly(uid))
00234                      {
00235                             itendR = it3;
00236                             break;
00237                      }
00238               }
00239        }
00240 
00241        if (stacks_[currentDoc_].undoItems() > 0)
00242        {
00243               if (itendU == stacks_[currentDoc_].undoActions_.end())
00244                      --itendU;
00245               for (; itendU >= itstartU; --itendU) // insert undo actions
00246               {
00247                      UndoState*  state  = *itendU;
00248                      UndoObject* target = state->undoObject();
00249 
00250                      if (target && (uid == -1 || target->getUId() == static_cast<uint>(uid)))
00251                             gui->insertUndoItem(target, state);
00252                      if (itendU == itstartU)
00253                             break;
00254               }
00255        }
00256 
00257        if (stacks_[currentDoc_].redoItems() > 0)
00258        {
00259               --itendR;
00260               for (; itstartR <= itendR; ++itstartR) // insert redo actions
00261               {
00262                      UndoState*  state  = *itstartR;
00263                      UndoObject* target = state->undoObject();
00264 
00265                      if (target && (uid == -1 || target->getUId() == static_cast<uint>(uid)))
00266                             gui->insertRedoItem(target, state);
00267                      if (itendR == itstartR)
00268                             break;
00269               }
00270        }
00271 }
00272 
00273 void UndoManager::connectGuis()
00274 {
00275        for (uint i = 0; i < undoGuis_.size(); ++i)
00276        {
00277               UndoGui *gui = undoGuis_[i];
00278 
00279               connect(gui, SIGNAL(undo(int)), this, SLOT(undo(int)));
00280               connect(gui, SIGNAL(redo(int)), this, SLOT(redo(int)));
00281               connect(this, SIGNAL(newAction(UndoObject*, UndoState*)),
00282                 gui, SLOT(insertUndoItem(UndoObject*, UndoState*)));
00283               connect(this, SIGNAL(popBack()), gui, SLOT(popBack()));
00284               connect(this, SIGNAL(undoSignal(int)), gui, SLOT(updateUndo(int)));
00285               connect(this, SIGNAL(redoSignal(int)), gui, SLOT(updateRedo(int)));
00286               connect(this, SIGNAL(clearRedo()), gui, SLOT(clearRedo()));
00287               gui->setEnabled(true);
00288               gui->updateUndoActions();
00289        }
00290 }
00291 
00292 void UndoManager::disconnectGuis()
00293 {
00294        for (uint i = 0; i < undoGuis_.size(); ++i)
00295        {
00296               UndoGui *gui = undoGuis_[i];
00297 
00298               disconnect(gui, SIGNAL(undo(int)), this, SLOT(undo(int)));
00299               disconnect(gui, SIGNAL(redo(int)), this, SLOT(redo(int)));
00300               disconnect(this, SIGNAL(newAction(UndoObject*, UndoState*)),
00301                    gui, SLOT(insertUndoItem(UndoObject*, UndoState*)));
00302               disconnect(this, SIGNAL(popBack()), gui, SLOT(popBack()));
00303               disconnect(this, SIGNAL(undoSignal(int)), gui, SLOT(updateUndo(int)));
00304               disconnect(this, SIGNAL(redoSignal(int)), gui, SLOT(updateRedo(int)));
00305               disconnect(this, SIGNAL(clearRedo()), gui, SLOT(clearRedo()));
00306               gui->setEnabled(false);
00307        }
00308 }
00309 
00310 void UndoManager::removeGui(UndoGui* gui)
00311 {
00312        std::vector<UndoGui*>::iterator it;
00313        for (it = undoGuis_.begin(); it != undoGuis_.end(); ++it)
00314               if (*it == gui)
00315                      undoGuis_.erase(it);
00316 }
00317 
00318 void UndoManager::switchStack(const QString& stackName)
00319 {
00320        if (stackName == currentDoc_)
00321               return; // already current stack
00322        currentDoc_ = stackName;
00323        if (!stacks_.contains(currentDoc_))
00324               stacks_[currentDoc_] = UndoStack();
00325 
00326        stacks_[currentDoc_].setMaxSize(prefs_->getInt("historylength", 20));
00327        for (uint i = 0; i < undoGuis_.size(); ++i)
00328               setState(undoGuis_[i]);
00329 
00330        setMenuTexts();
00331 }
00332 
00333 void UndoManager::renameStack(const QString& newName)
00334 {
00335        if (currentDoc_ == newName)
00336               return;
00337 
00338        if (stacks_[currentDoc_].size() == 0) {
00339               currentDoc_ = newName;
00340               return;
00341        }
00342        
00343        UndoStack tmp(stacks_[currentDoc_]);
00344        stacks_.erase(currentDoc_);
00345        stacks_[newName] = tmp;
00346        currentDoc_ = newName;
00347 }
00348 
00349 void UndoManager::removeStack(const QString& stackName)
00350 {
00351        if (stacks_.contains(stackName))
00352        {
00353               stacks_[stackName].clear();
00354               stacks_.erase(stackName);
00355               if (currentDoc_ == stackName)
00356               {
00357                      for (uint i = 0; i < undoGuis_.size(); ++i)
00358                             undoGuis_[i]->clear();
00359                      currentDoc_ = "__no_name__";
00360               }
00361        }
00362 }
00363 
00364 void UndoManager::clearStack()
00365 {
00366        stacks_[currentDoc_].clear();
00367        for (uint i = 0; i < undoGuis_.size(); ++i)
00368        {
00369               undoGuis_[i]->clear();
00370               setState(undoGuis_[i]);
00371        }
00372 }
00373 
00374 void UndoManager::action(UndoObject* target, UndoState* state, QPixmap *targetPixmap)
00375 {
00376        QPixmap *oldIcon = 0;
00377        if (targetPixmap)
00378        {
00379               oldIcon = target->getUPixmap();
00380               target->setUPixmap(targetPixmap);
00381        }
00382 
00383        if (!undoEnabled_) // if so flush down the state
00384        {
00385               TransactionState *ts = dynamic_cast<TransactionState*>(state);
00386               if (ts) // flush the TransactionObject too
00387                      delete target;
00388               delete state;
00389               return;
00390        }
00391 
00392        if ((!transaction_) &&
00393         (currentUndoObjectId_ == -1 || currentUndoObjectId_ == static_cast<long>(target->getUId())))
00394               emit newAction(target, state); // send action to the guis
00395        else
00396               emit clearRedo();
00397 
00398        if (transaction_)
00399               transaction_->pushBack(target, state);
00400        else
00401        {
00402               state->setUndoObject(target);
00403               stacks_[currentDoc_].action(state);
00404        }
00405        if (targetPixmap)
00406               target->setUPixmap(oldIcon);
00407 
00408        setMenuTexts();
00409 }
00410 
00411 void UndoManager::action(UndoObject* target, UndoState* state,
00412                          const QString &targetName, QPixmap *targetPixmap)
00413 {
00414        QString oldName = target->getUName();
00415        if (!targetName.isEmpty())
00416               target->setUName(targetName);
00417        action(target, state, targetPixmap);
00418        target->setUName(oldName);
00419 }
00420 
00421 void UndoManager::undo(int steps)
00422 {
00423        if (!undoEnabled_)
00424               return;
00425 
00426        setUndoEnabled(false);
00427        stacks_[currentDoc_].undo(steps, currentUndoObjectId_);
00428        setUndoEnabled(true);
00429        emit undoSignal(steps);
00430        emit undoRedoDone();
00431        setMenuTexts();
00432 }
00433 
00434 void UndoManager::redo(int steps)
00435 {
00436        if (!undoEnabled_)
00437               return;
00438 
00439        setUndoEnabled(false);
00440        stacks_[currentDoc_].redo(steps, currentUndoObjectId_);
00441        setUndoEnabled(true);
00442        emit redoSignal(steps);
00443        emit undoRedoDone();
00444        setMenuTexts();
00445 }
00446 
00447 bool UndoManager::hasUndoActions(int )
00448 {
00449        // TODO Needs to fixed for object specific mode
00450        return stacks_[currentDoc_].undoItems() > 0;
00451 }
00452 
00453 bool UndoManager::hasRedoActions(int )
00454 {
00455        // TODO Needs to be fixed for object specific mode
00456        return stacks_[currentDoc_].redoItems() > 0;
00457 }
00458 
00459 void UndoManager::showObject(int uid)
00460 {
00461        if (currentUndoObjectId_ == uid)
00462               return;
00463        setUndoEnabled(false);
00464        currentUndoObjectId_ = uid;
00465        for (uint i = 0; i < undoGuis_.size(); ++i)
00466        {
00467               if (uid == -2)
00468                      undoGuis_[i]->clear();
00469               else
00470                      setState(undoGuis_[i], currentUndoObjectId_);
00471        }
00472        setUndoEnabled(true);
00473        setMenuTexts();
00474 }
00475 
00476 UndoObject* UndoManager::replaceObject(ulong uid, UndoObject *newUndoObject)
00477 {
00478        UndoObject *tmp = 0;
00479        for (uint i = 0; i < stacks_[currentDoc_].undoActions_.size(); ++i)
00480        {
00481               UndoState *tmpState = stacks_[currentDoc_].undoActions_[i];
00482               TransactionState *ts = dynamic_cast<TransactionState*>(tmpState);
00483               if (ts)
00484                      tmp = ts->replace(uid, newUndoObject);
00485               else if (tmpState->undoObject() && tmpState->undoObject()->getUId() == uid)
00486               {
00487                      tmp = tmpState->undoObject();
00488                      tmpState->setUndoObject(newUndoObject);
00489               }
00490        }
00491        if (transaction_) // replace also in the currently open transaction
00492               tmp = transaction_->replace(uid, newUndoObject);
00493        return tmp;
00494 }
00495 
00496 void UndoManager::setHistoryLength(int steps)
00497 {
00498        if (steps >= 0)
00499        {
00500               stacks_[currentDoc_].setMaxSize(static_cast<uint>(steps));
00501               prefs_->set("historylength", stacks_[currentDoc_].maxSize());
00502        }
00503 }
00504 
00505 void UndoManager::setAllHistoryLengths(int steps)
00506 {
00507        if (steps >= 0)
00508        {
00509               for (StackMap::Iterator it = stacks_.begin(); it != stacks_.end(); ++it )
00510               {
00511                      it.data().setMaxSize(static_cast<uint>(steps));
00512               }
00513               prefs_->set("historylength", steps);
00514        }
00515 }
00516 
00517 int UndoManager::getHistoryLength()
00518 {
00519        if (stacks_.size() > 0 && stacks_[currentDoc_].redoItems() > 0)
00520               return -1;
00521        return static_cast<int>(stacks_[currentDoc_].maxSize());
00522 }
00523 
00524 bool UndoManager::isGlobalMode()
00525 {
00526        return currentUndoObjectId_ == -1;
00527 }
00528 
00529 void UndoManager::setMenuTexts()
00530 {
00531        if (stacks_[currentDoc_].undoItems() > 0)
00532        {
00533               UndoState *state = stacks_[currentDoc_].getNextUndo(currentUndoObjectId_);
00534               if (state)
00535                      ScCore->primaryMainWindow()->scrActions["editUndoAction"]->setTexts(QString(Um::MenuUndo).arg(state->getName()));
00536               else
00537                      ScCore->primaryMainWindow()->scrActions["editUndoAction"]->setTexts(Um::MenuUndoEmpty);
00538        }
00539        else
00540               ScCore->primaryMainWindow()->scrActions["editUndoAction"]->setTexts(Um::MenuUndoEmpty);
00541 
00542        if (stacks_[currentDoc_].redoItems() > 0)
00543        {
00544               UndoState *state = stacks_[currentDoc_].getNextRedo(currentUndoObjectId_);
00545               if (state)
00546                      ScCore->primaryMainWindow()->scrActions["editRedoAction"]->setTexts(QString(Um::MenuRedo).arg(state->getName()));
00547               else
00548                      ScCore->primaryMainWindow()->scrActions["editRedoAction"]->setTexts(Um::MenuRedoEmpty);
00549        }
00550        else
00551               ScCore->primaryMainWindow()->scrActions["editRedoAction"]->setTexts(Um::MenuRedoEmpty);
00552 }
00553 
00554 void UndoManager::deleteInstance()
00555 {
00556        if (instance_)
00557               delete instance_;
00558        instance_ = 0;
00559 }
00560 
00561 UndoManager::~UndoManager()
00562 {
00563        StackMap::iterator it;
00564        for (it = stacks_.begin(); it != stacks_.end(); ++it)
00565        {
00566               for (uint i = 0; i < (*it).size(); ++i)
00567               {
00568                      (*it).clear();
00569               }
00570        }
00571        stacks_.clear();
00572 }
00573 
00574 /*** TransactionState *****************************************************/
00575 
00576 TransactionState::TransactionState() : UndoState("")
00577 {
00578        size_ = 0;
00579 }
00580 
00581 UndoState* TransactionState::at(int index)
00582 {
00583        if (index >= 0 && static_cast<uint>(index) < sizet())
00584               return states_[index];
00585        else
00586               return 0;
00587 }
00588 
00589 bool TransactionState::contains(int uid) const
00590 {
00591        for (uint i = 0; i < states_.size(); ++i)
00592        {
00593               if (states_[i]->undoObject()->getUId() == static_cast<uint>(uid))
00594                      return true;
00595        }
00596        return false;
00597 }
00598 
00599 bool TransactionState::containsOnly(int uid) const
00600 {
00601        for (uint i = 0; i < states_.size(); ++i)
00602        {
00603               if (states_[i]->undoObject()->getUId() != static_cast<uint>(uid))
00604                      return false;
00605        }
00606        return true;
00607 }
00608 
00609 void TransactionState::pushBack(UndoObject *target, UndoState *state)
00610 {
00611        if (target && state)
00612        {
00613               state->setUndoObject(target);
00614               states_.push_back(state);
00615               ++size_;
00616        }
00617 }
00618 
00619 uint TransactionState::sizet()
00620 {
00621        return size_;
00622 }
00623 
00624 void TransactionState::useActionName()
00625 {
00626        if (size_ > 0)
00627               setName(states_[size_ - 1]->getName());
00628 }
00629 
00630 UndoObject* TransactionState::replace(ulong uid, UndoObject *newUndoObject)
00631 {
00632        UndoObject *tmp = 0;
00633        for (uint i = 0; i < states_.size(); ++i)
00634        {
00635               TransactionState *ts = dynamic_cast<TransactionState*>(states_[i]);
00636               if (ts) // are we having a transaction_inside a transaction
00637                      ts->replace(uid, newUndoObject);
00638               else if (states_[i]->undoObject() && states_[i]->undoObject()->getUId() == uid)
00639               {
00640                      tmp = states_[i]->undoObject();
00641                      states_[i]->setUndoObject(newUndoObject);
00642               }
00643        }
00644        return tmp;
00645 }
00646 
00647 void TransactionState::undo() // undo all attached states
00648 {
00649        for (int i = sizet() - 1; i > -1; --i)
00650               at(i)->undo();
00651 }
00652 
00653 void TransactionState::redo() // redo all attached states
00654 {
00655        for (uint i = 0; i < sizet(); ++i)
00656               at(i)->redo();
00657 }
00658 
00659 TransactionState::~TransactionState()
00660 {
00661        for (uint i = 0; i < states_.size(); ++i)
00662        {
00663               if (states_[i])
00664               {
00665                      delete states_[i];
00666                      states_[i] = 0;
00667               }
00668        }
00669 }
00670 
00671 /*************************************************************************************/
00672 
00673 void UndoManager::languageChange()
00674 {
00675        UndoManager::AddVGuide          = tr("Add vertical guide");
00676        UndoManager::AddHGuide          = tr("Add horizontal guide");
00677        UndoManager::DelVGuide          = tr("Remove vertical guide");
00678        UndoManager::DelHGuide          = tr("Remove horizontal guide");
00679        UndoManager::DelVAGuide         = tr("Remove vertical auto guide");
00680        UndoManager::DelHAGuide         = tr("Remove horizontal auto guide");
00681        UndoManager::MoveVGuide         = tr("Move vertical guide");
00682        UndoManager::MoveHGuide         = tr("Move horizontal guide");
00683        UndoManager::LockGuides         = tr("Lock guides");
00684        UndoManager::UnlockGuides       = tr("Unlock guides");
00685        UndoManager::Move               = tr("Move");
00686        UndoManager::Resize             = tr("Resize");
00687        UndoManager::Rotate             = tr("Rotate");
00688        UndoManager::MoveFromTo         = tr("X1: %1, Y1: %2, %3\nX2: %4, Y2: %5, %6");
00689        UndoManager::ResizeFromTo       = tr("W1: %1, H1: %2\nW2: %3, H2: %4");
00690        UndoManager::ImageOffset        = tr("Change Image Offset");
00691        UndoManager::ImageScale         = tr("Change Image Scale");
00692        UndoManager::ImageOffsetFromTo  = tr("X1: %1, Y1: %2\nX2: %4, Y2: %5");
00693        UndoManager::ImageScaleFromTo   = tr("X: %1, Y: %2\nX: %4, Y: %5");
00694        UndoManager::Selection          = tr("Selection");
00695        UndoManager::Group              = tr("Group");
00696        UndoManager::SelectionGroup     = tr("Selection/Group");
00697        UndoManager::Create             = tr("Create");
00698        UndoManager::CreateTo           = tr("X: %1, Y: %2\nW: %3, H: %4");
00699        UndoManager::AlignDistribute    = tr("Align/Distribute");
00700        UndoManager::ItemsInvolved      = tr("Items involved");
00701        UndoManager::Cancel             = tr("Cancel");
00702        UndoManager::SetFill            = tr("Set fill color");
00703        UndoManager::ColorFromTo        = tr("Color1: %1, Color2: %2");
00704        UndoManager::SetShade           = tr("Set fill color shade");
00705        UndoManager::SetLineColor       = tr("Set line color");
00706        UndoManager::SetLineShade       = tr("Set line color shade");
00707        UndoManager::FlipH              = tr("Flip horizontally");
00708        UndoManager::FlipV              = tr("Flip vertically");
00709        UndoManager::Lock               = tr("Lock");
00710        UndoManager::UnLock             = tr("Unlock");
00711        UndoManager::SizeLock           = tr("Lock size");
00712        UndoManager::SizeUnLock         = tr("Unlock size");
00713        UndoManager::EnablePrint        = tr("Enable Item Printing");
00714        UndoManager::DisablePrint       = tr("Disable Item Printing");
00715        UndoManager::Ungroup            = tr("Ungroup");
00716        UndoManager::Delete             = tr("Delete");
00717        UndoManager::Rename             = tr("Rename");
00718        UndoManager::FromTo             = tr("From %1\nto %2");
00719        UndoManager::ApplyMasterPage    = tr("Apply Master Page");
00720        UndoManager::Paste              = tr("Paste");
00721        UndoManager::Cut                = tr("Cut");
00722        UndoManager::Transparency       = tr("Set fill color transparency");
00723        UndoManager::LineTransparency   = tr("Set line color transparency");
00724        UndoManager::LineStyle          = tr("Set line style");
00725        UndoManager::LineEnd            = tr("Set the style of line end");
00726        UndoManager::LineJoin           = tr("Set the style of line join");
00727        UndoManager::LineWidth          = tr("Set line width");
00728        UndoManager::NoStyle            = tr("No style");
00729        UndoManager::CustomLineStyle    = tr("Set custom line style");
00730        UndoManager::NoLineStyle        = tr("Do not use custom line style");
00731        UndoManager::StartArrow         = tr("Set start arrow");
00732        UndoManager::EndArrow           = tr("Set end arrow");
00733        UndoManager::StartAndEndArrow   = tr("Set start and end arrows");
00734        UndoManager::CreateTable        = tr("Create table");
00735        UndoManager::RowsCols           = tr("Rows: %1, Cols: %2");
00736        UndoManager::SetFont            = tr("Set font");
00737        UndoManager::SetFontSize        = tr("Set font size");
00738        UndoManager::SetFontWidth       = tr("Set font width");
00739        UndoManager::SetFontHeight       = tr("Set font height");
00740        UndoManager::SetFontFill        = tr("Set font fill color");
00741        UndoManager::SetFontStroke      = tr("Set font stroke color");
00742        UndoManager::SetFontFillShade   = tr("Set font fill color shade");
00743        UndoManager::SetFontStrokeShade = tr("Set font stroke color shade");
00744        UndoManager::SetKerning         = tr("Set kerning");
00745        UndoManager::SetLineSpacing     = tr("Set line spacing");
00746        UndoManager::SetStyle           = tr("Set paragraph style");
00747        UndoManager::SetLanguage        = tr("Set language");
00748        UndoManager::AlignText          = tr("Align text");
00749        UndoManager::SetFontEffect      = tr("Set font effect");
00750        UndoManager::ImageFrame         = tr("Image frame");
00751        UndoManager::TextFrame          = tr("Text frame");
00752        UndoManager::Polygon            = tr("Polygon");
00753        UndoManager::BezierCurve        = tr("Bezier curve");
00754        UndoManager::Polyline           = tr("Polyline");
00755        UndoManager::PathText           = tr("Text on a Path");
00756        UndoManager::ConvertTo          = tr("Convert to");
00757        UndoManager::ImportSVG          = tr("Import SVG image");
00758        UndoManager::ImportEPS          = tr("Import EPS image");
00759        UndoManager::ImportOOoDraw      = tr("Import OpenOffice.org Draw image");
00760        UndoManager::ScratchSpace       = tr("Scratch space");
00761        //UndoManager::TextFlow           = tr("Text flows around the frame");
00762        UndoManager::ObjectFrame        = tr("Text flows around the frame");
00763        UndoManager::BoundingBox        = tr("Text flows around bounding box");
00764        UndoManager::ContourLine        = tr("Text flows around contour line");
00765        UndoManager::ImageClip        = tr("Text flows around image clipping path");
00766        UndoManager::NoTextFlow         = tr("No text flow");
00767        UndoManager::NoObjectFrame      = tr("No object frame");
00768        UndoManager::NoBoundingBox      = tr("No bounding box");
00769        UndoManager::NoContourLine      = tr("No contour line");
00770        UndoManager::PageNmbr           = tr("Page %1");
00771        UndoManager::ImageScaling       = tr("Set image scaling");
00772        UndoManager::FrameSize          = tr("Frame size");
00773        UndoManager::FreeScaling        = tr("Free scaling");
00774        UndoManager::KeepRatio          = tr("Keep aspect ratio");
00775        UndoManager::BreakRatio         = tr("Break aspect ratio");
00776        UndoManager::EditContourLine    = tr("Edit contour line");
00777        UndoManager::EditShape          = tr("Edit shape");
00778        UndoManager::ResetContourLine   = tr("Reset contour line");
00779        UndoManager::AddPage            = tr("Add page");
00780        UndoManager::AddPages           = tr("Add pages");
00781        UndoManager::DeletePage         = tr("Delete page");
00782        UndoManager::DeletePages        = tr("Delete pages");
00783        UndoManager::AddLayer           = tr("Add layer");
00784        UndoManager::DeleteLayer        = tr("Delete layer");
00785        UndoManager::RenameLayer        = tr("Rename layer");
00786        UndoManager::RaiseLayer         = tr("Raise layer");
00787        UndoManager::LowerLayer         = tr("Lower layer");
00788        UndoManager::SendToLayer        = tr("Send to layer");
00789        UndoManager::PrintLayer         = tr("Enable printing of layer");
00790        UndoManager::DoNotPrintLayer    = tr("Disable printing of layer");
00791        UndoManager::SetLayerName       = tr("Change name of the layer");
00792        UndoManager::GetImage           = tr("Get image");
00793        UndoManager::MultipleDuplicate  = tr("Multiple duplicate");
00794        UndoManager::ApplyTextStyle     = tr("Apply text style");
00795        UndoManager::MenuUndo           = tr("&Undo: %1", "f.e. Undo: Move");
00796        UndoManager::MenuUndoEmpty      = tr("&Undo");
00797        UndoManager::MenuRedo           = tr("&Redo: %1", "f.e. Redo: Move");
00798        UndoManager::MenuRedoEmpty      = tr("&Redo");
00799        UndoManager::EditContour        = tr("Edit contour line");
00800        UndoManager::ResetControlPoint  = tr("Reset control point");
00801        UndoManager::ResetControlPoints = tr("Reset control points");
00802        UndoManager::ImageEffects       = tr("Apply image effects");
00803        UndoManager::InsertFrame        = tr("Insert frame");
00804        UndoManager::AdjustFrameToImage = tr("Adjust frame to the image size");
00805        UndoManager::RemoveAllGuides    = tr("Remove all guides");
00806        UndoManager::RemoveAllPageGuides = tr("Remove page guides");
00807        UndoManager::Copy               = tr("Copy");
00808        UndoManager::CopyPage           = tr("Copy page");
00809        UndoManager::ToOutlines         = tr("Convert to outlines");
00810 }
00811 
00812 void UndoManager::initIcons()
00813 {
00814        QString iconDir = ScPaths::instance().iconDir();
00815 
00816 /*** Icons for UndoObjects *******************************************/
00817        UndoManager::IImageFrame      = new QPixmap(iconDir + "16/insert-image.png");
00818        UndoManager::ITextFrame       = new QPixmap(iconDir + "16/insert-text-frame.png");
00819        UndoManager::ILine            = new QPixmap(iconDir + "Stift.xpm");
00820        UndoManager::IPolygon         = new QPixmap(iconDir + "16/draw-polygon.png");
00821        UndoManager::IPolyline        = new QPixmap(iconDir + "16/draw-bezier-curves.png");
00822 //     UndoManager::IPathText        = new QPixmap(iconDir + "?";
00823        UndoManager::IGroup           = new QPixmap(iconDir + "u_group.png");
00824 /*** Icons for actions ***********************************************/
00825        UndoManager::IMove            = new QPixmap(iconDir + "u_move.png");
00826        UndoManager::IResize          = new QPixmap(iconDir + "u_resize.png");
00827        UndoManager::IRotate          = new QPixmap(iconDir + "u_rotate.png");
00828        UndoManager::IAlignDistribute = new QPixmap(iconDir + "u_align.png");
00829        UndoManager::IGuides          = new QPixmap(iconDir + "u_margins.png");
00830        UndoManager::ILockGuides      = new QPixmap(iconDir + "u_margins_locked.png");
00831        UndoManager::IFill            = new QPixmap(iconDir + "u_fill.png");
00832        UndoManager::IShade           = new QPixmap(iconDir + "u_shade.png");
00833        UndoManager::IFlipH           = new QPixmap(iconDir + "u_fliph.png");
00834        UndoManager::IFlipV           = new QPixmap(iconDir + "u_flipv.png");
00835        UndoManager::ILock            = new QPixmap(iconDir + "u_lock.png");
00836        UndoManager::IUnLock          = new QPixmap(iconDir + "u_unlock.png");
00837        UndoManager::IEnablePrint     = new QPixmap(iconDir + "u_enableprint.png");
00838        UndoManager::IDisablePrint    = new QPixmap(iconDir + "u_disableprint.png");
00839        UndoManager::IDelete          = new QPixmap(iconDir + "u_delete.png");
00840        UndoManager::ICreate          = new QPixmap(iconDir + "u_create.png");
00841        UndoManager::IPaste           = new QPixmap(iconDir + "16/edit-paste.png");
00842        UndoManager::ICut             = new QPixmap(iconDir + "u_cut.png");
00843        UndoManager::ITransparency    = new QPixmap(iconDir + "u_transp.png");
00844        UndoManager::ILineStyle       = new QPixmap(iconDir + "u_line.png");
00845        UndoManager::IArrow           = new QPixmap(iconDir + "u_arrow.png");
00846        UndoManager::ITable           = new QPixmap(iconDir + "frame_table.png");
00847        UndoManager::IFont            = new QPixmap(iconDir + "u_font.png");
00848        UndoManager::IImportOOoDraw   = new QPixmap(iconDir + "ooo_draw.png");
00849        UndoManager::ISVG             = new QPixmap(iconDir + "u_svg.png");
00850        UndoManager::IEPS             = new QPixmap(iconDir + "u_eps.png");
00851        UndoManager::IImageScaling    = new QPixmap(iconDir + "u_scale_image.png");
00852        UndoManager::IBorder          = new QPixmap(iconDir + "u_shape.png");
00853        UndoManager::IDocument        = new QPixmap(iconDir + "16/document-new.png");
00854 //     UndoManager::ILayer           = new QPixmap(iconDir + "u_layer.png");
00855 //     UndoManager::ILayerAction     = new QPixmap(iconDir + "u_layer_action.png");
00856 //     UndoManager::IUp              = new QPixmap(iconDir + "u_up.png");
00857 //     UndoManager::IDown            = new QPixmap(iconDir + "u_down.png");
00858 //     UndoManager::IGetImage        = new QPixmap(iconDir + "u_get_image.png");
00859        UndoManager::IMultipleDuplicate = new QPixmap(iconDir + "u_multiple.png");
00860 }
00861 QString UndoManager::AddVGuide          = "";
00862 QString UndoManager::AddHGuide          = "";
00863 QString UndoManager::DelVGuide          = "";
00864 QString UndoManager::DelHGuide          = "";
00865 QString UndoManager::DelVAGuide         = "";
00866 QString UndoManager::DelHAGuide         = "";
00867 QString UndoManager::MoveVGuide         = "";
00868 QString UndoManager::MoveHGuide         = "";
00869 QString UndoManager::LockGuides         = "";
00870 QString UndoManager::UnlockGuides       = "";
00871 QString UndoManager::Move               = "";
00872 QString UndoManager::Resize             = "";
00873 QString UndoManager::Rotate             = "";
00874 QString UndoManager::MoveFromTo         = "";
00875 QString UndoManager::ImageOffset        = "";
00876 QString UndoManager::ImageScale         = "";
00877 QString UndoManager::ImageOffsetFromTo  = "";
00878 QString UndoManager::ImageScaleFromTo   = "";
00879 QString UndoManager::ResizeFromTo       = "";
00880 QString UndoManager::Selection          = "";
00881 QString UndoManager::Group              = "";
00882 QString UndoManager::SelectionGroup     = "";
00883 QString UndoManager::Create             = "";
00884 QString UndoManager::CreateTo           = "";
00885 QString UndoManager::AlignDistribute    = "";
00886 QString UndoManager::ItemsInvolved      = "";
00887 QString UndoManager::Cancel             = "";
00888 QString UndoManager::SetFill            = "";
00889 QString UndoManager::ColorFromTo        = "";
00890 QString UndoManager::SetShade           = "";
00891 QString UndoManager::SetLineColor       = "";
00892 QString UndoManager::SetLineShade       = "";
00893 QString UndoManager::FlipH              = "";
00894 QString UndoManager::FlipV              = "";
00895 QString UndoManager::Lock               = "";
00896 QString UndoManager::UnLock             = "";
00897 QString UndoManager::SizeLock           = "";
00898 QString UndoManager::SizeUnLock         = "";
00899 QString UndoManager::EnablePrint        = "";
00900 QString UndoManager::DisablePrint       = "";
00901 QString UndoManager::Ungroup            = "";
00902 QString UndoManager::Delete             = "";
00903 QString UndoManager::Rename             = "";
00904 QString UndoManager::FromTo             = "";
00905 QString UndoManager::ApplyMasterPage    = "";
00906 QString UndoManager::Paste              = "";
00907 QString UndoManager::Cut                = "";
00908 QString UndoManager::Transparency       = "";
00909 QString UndoManager::LineTransparency   = "";
00910 QString UndoManager::LineStyle          = "";
00911 QString UndoManager::LineEnd            = "";
00912 QString UndoManager::LineJoin           = "";
00913 QString UndoManager::LineWidth          = "";
00914 QString UndoManager::NoStyle            = "";
00915 QString UndoManager::CustomLineStyle    = "";
00916 QString UndoManager::NoLineStyle        = "";
00917 QString UndoManager::StartArrow         = "";
00918 QString UndoManager::EndArrow           = "";
00919 QString UndoManager::StartAndEndArrow   = "";
00920 QString UndoManager::CreateTable        = "";
00921 QString UndoManager::RowsCols           = "";
00922 QString UndoManager::SetFont            = "";
00923 QString UndoManager::SetFontSize        = "";
00924 QString UndoManager::SetFontWidth       = "";
00925 QString UndoManager::SetFontHeight      = "";
00926 QString UndoManager::SetFontFill        = "";
00927 QString UndoManager::SetFontStroke      = "";
00928 QString UndoManager::SetFontFillShade   = "";
00929 QString UndoManager::SetFontStrokeShade = "";
00930 QString UndoManager::SetKerning         = "";
00931 QString UndoManager::SetLineSpacing     = "";
00932 QString UndoManager::SetStyle           = "";
00933 QString UndoManager::SetLanguage        = "";
00934 QString UndoManager::AlignText          = "";
00935 QString UndoManager::SetFontEffect      = "";
00936 QString UndoManager::ImageFrame         = "";
00937 QString UndoManager::TextFrame          = "";
00938 QString UndoManager::Polygon            = "";
00939 QString UndoManager::BezierCurve        = "";
00940 QString UndoManager::Polyline           = "";
00941 QString UndoManager::PathText           = "";
00942 QString UndoManager::ConvertTo          = "";
00943 QString UndoManager::ImportSVG          = "";
00944 QString UndoManager::ImportEPS          = "";
00945 QString UndoManager::ImportOOoDraw      = "";
00946 QString UndoManager::ScratchSpace       = "";
00947 //QString UndoManager::TextFlow           = "";
00948 QString UndoManager::ObjectFrame        = "";
00949 QString UndoManager::BoundingBox        = "";
00950 QString UndoManager::ContourLine        = "";
00951 QString UndoManager::ImageClip        = "";
00952 QString UndoManager::NoTextFlow         = "";
00953 QString UndoManager::NoObjectFrame      = "";
00954 QString UndoManager::NoBoundingBox      = "";
00955 QString UndoManager::NoContourLine      = "";
00956 QString UndoManager::PageNmbr           = "";
00957 QString UndoManager::ImageScaling       = "";
00958 QString UndoManager::FrameSize          = "";
00959 QString UndoManager::FreeScaling        = "";
00960 QString UndoManager::KeepRatio          = "";
00961 QString UndoManager::BreakRatio         = "";
00962 QString UndoManager::EditContourLine    = "";
00963 QString UndoManager::EditShape          = "";
00964 QString UndoManager::ResetContourLine   = "";
00965 QString UndoManager::AddPage            = "";
00966 QString UndoManager::AddPages           = "";
00967 QString UndoManager::DeletePage         = "";
00968 QString UndoManager::DeletePages        = "";
00969 QString UndoManager::AddLayer           = "";
00970 QString UndoManager::DeleteLayer        = "";
00971 QString UndoManager::RenameLayer        = "";
00972 QString UndoManager::RaiseLayer         = "";
00973 QString UndoManager::LowerLayer         = "";
00974 QString UndoManager::SendToLayer        = "";
00975 QString UndoManager::PrintLayer         = "";
00976 QString UndoManager::DoNotPrintLayer    = "";
00977 QString UndoManager::SetLayerName       = "";
00978 QString UndoManager::GetImage           = "";
00979 QString UndoManager::MultipleDuplicate  = "";
00980 QString UndoManager::ApplyTextStyle     = "";
00981 QString UndoManager::MenuUndo           = "";
00982 QString UndoManager::MenuUndoEmpty      = "";
00983 QString UndoManager::MenuRedo           = "";
00984 QString UndoManager::MenuRedoEmpty      = "";
00985 QString UndoManager::EditContour        = "";
00986 QString UndoManager::ResetControlPoint  = "";
00987 QString UndoManager::ResetControlPoints = "";
00988 QString UndoManager::ImageEffects       = "";
00989 QString UndoManager::InsertFrame        = "";
00990 QString UndoManager::AdjustFrameToImage = "";
00991 QString UndoManager::RemoveAllGuides    = "";
00992 QString UndoManager::RemoveAllPageGuides = "";
00993 QString UndoManager::Copy               = "";
00994 QString UndoManager::CopyPage           = "";
00995 QString UndoManager::ToOutlines         = "";
00996 
00997 /*** Icons for UndoObjects *******************************************/
00998 QPixmap *UndoManager::IImageFrame      = 0;
00999 QPixmap *UndoManager::ITextFrame       = 0;
01000 QPixmap *UndoManager::ILine            = 0;
01001 QPixmap *UndoManager::IPolygon         = 0;
01002 QPixmap *UndoManager::IPolyline        = 0;
01003 QPixmap *UndoManager::IPathText        = 0;
01004 QPixmap *UndoManager::IGroup           = 0;
01005 QPixmap *UndoManager::ITable           = 0;
01006 /*** Icons for actions ***********************************************/
01007 QPixmap *UndoManager::IMove            = 0;
01008 QPixmap *UndoManager::IResize          = 0;
01009 QPixmap *UndoManager::IRotate          = 0;
01010 QPixmap *UndoManager::IGuides          = 0;
01011 QPixmap *UndoManager::ILockGuides      = 0;
01012 QPixmap *UndoManager::IAlignDistribute = 0;
01013 QPixmap *UndoManager::IFill            = 0;
01014 QPixmap *UndoManager::IShade           = 0;
01015 QPixmap *UndoManager::IFlipH           = 0;
01016 QPixmap *UndoManager::IFlipV           = 0;
01017 QPixmap *UndoManager::ILock            = 0;
01018 QPixmap *UndoManager::IUnLock          = 0;
01019 QPixmap *UndoManager::IEnablePrint     = 0;
01020 QPixmap *UndoManager::IDisablePrint    = 0;
01021 QPixmap *UndoManager::IDelete          = 0;
01022 QPixmap *UndoManager::ICreate          = 0;
01023 QPixmap *UndoManager::IPaste           = 0;
01024 QPixmap *UndoManager::ICut             = 0;
01025 QPixmap *UndoManager::ITransparency    = 0;
01026 QPixmap *UndoManager::ILineStyle       = 0;
01027 QPixmap *UndoManager::IArrow           = 0;
01028 QPixmap *UndoManager::IFont            = 0;
01029 QPixmap *UndoManager::ISVG             = 0;
01030 QPixmap *UndoManager::IEPS             = 0;
01031 QPixmap *UndoManager::IImportOOoDraw   = 0;
01032 QPixmap *UndoManager::IImageScaling    = 0;
01033 QPixmap *UndoManager::IBorder          = 0;
01034 QPixmap *UndoManager::IDocument        = 0;
01035 QPixmap *UndoManager::ILayer           = 0;
01036 QPixmap *UndoManager::ILayerAction     = 0;
01037 QPixmap *UndoManager::IUp              = 0;
01038 QPixmap *UndoManager::IDown            = 0;
01039 QPixmap *UndoManager::IPrint           = 0;
01040 QPixmap *UndoManager::IGetImage        = 0;
01041 QPixmap *UndoManager::IMultipleDuplicate = 0;
01042