r19421 by jghali - adapt more code to latest UndoTransaction api changes
scribus-commit
scribus-commit at lists.scribus.net
Thu Aug 14 03:13:08 UTC 2014
Author: jghali
Date: Thu Aug 14 03:13:08 2014
New Revision: 19421
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19421
Log:
adapt more code to latest UndoTransaction api changes
Modified:
trunk/Scribus/scribus/canvasmode_editpolygon.cpp
trunk/Scribus/scribus/canvasmode_editspiral.cpp
trunk/Scribus/scribus/canvasmode_objimport.cpp
trunk/Scribus/scribus/gtaction.cpp
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/pageitem_textframe.cpp
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/scribusview.cpp
trunk/Scribus/scribus/ui/cpalette.cpp
trunk/Scribus/scribus/ui/guidemanager.cpp
trunk/Scribus/scribus/ui/layers.cpp
trunk/Scribus/scribus/ui/loremipsum.cpp
trunk/Scribus/scribus/ui/masterpagepalette.cpp
trunk/Scribus/scribus/ui/propertiespalette.cpp
Modified: trunk/Scribus/scribus/canvasmode_editpolygon.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19421&path=/trunk/Scribus/scribus/canvasmode_editpolygon.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editpolygon.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editpolygon.cpp Thu Aug 14 03:13:08 2014
@@ -456,7 +456,7 @@
}
else
m_polygonPoint = noPointDefined;
- if(m_polygonPoint != noPointDefined && UndoManager::undoEnabled())
+ if (m_polygonPoint != noPointDefined && UndoManager::undoEnabled())
trans = new UndoTransaction(undoManager->beginTransaction(Um::Polygon,Um::IPolygon,Um::EditPolygon,"",Um::IPolygon));
m_view->setCursor(QCursor(Qt::CrossCursor));
QPainterPath path = itemMatrix.map(RegularPolygonPath(currItem->width(), currItem->height(), polyCorners, polyUseFactor, polyFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature));
Modified: trunk/Scribus/scribus/canvasmode_editspiral.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19421&path=/trunk/Scribus/scribus/canvasmode_editspiral.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editspiral.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editspiral.cpp Thu Aug 14 03:13:08 2014
@@ -361,7 +361,7 @@
m_arcPoint = useControlEnd;
else
m_arcPoint = noPointDefined;
- if(m_arcPoint != noPointDefined)
+ if (m_arcPoint != noPointDefined)
trans = new UndoTransaction(undoManager->beginTransaction(Um::Polygon,Um::IPolygon,Um::EditSpiral,"",Um::IPolygon));
m_canvas->m_viewMode.m_MouseButtonPressed = true;
m_view->setCursor(QCursor(Qt::CrossCursor));
Modified: trunk/Scribus/scribus/canvasmode_objimport.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19421&path=/trunk/Scribus/scribus/canvasmode_objimport.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_objimport.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_objimport.cpp Thu Aug 14 03:13:08 2014
@@ -176,10 +176,10 @@
m->accept();
if ((m->button() == Qt::LeftButton) && m_mimeData)
{
- UndoTransaction* undoTransaction = NULL;
+ UndoTransaction undoTransaction;
if (m_trSettings && UndoManager::undoEnabled())
{
- undoTransaction = new UndoTransaction(UndoManager::instance()->beginTransaction(*m_trSettings));
+ undoTransaction = UndoManager::instance()->beginTransaction(*m_trSettings);
}
// Creating QDragEnterEvent outside of Qt is not recommended per docs :S
QPoint dropPos = m_view->widget()->mapFromGlobal(m->globalPos());
@@ -195,9 +195,7 @@
// Commit undo transaction if necessary
if (undoTransaction)
{
- undoTransaction->commit();
- delete undoTransaction;
- undoTransaction = NULL;
+ undoTransaction.commit();
}
// Return to normal mode
m_view->requestMode(modeNormal);
Modified: trunk/Scribus/scribus/gtaction.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19421&path=/trunk/Scribus/scribus/gtaction.cpp
==============================================================================
--- trunk/Scribus/scribus/gtaction.cpp (original)
+++ trunk/Scribus/scribus/gtaction.cpp Thu Aug 14 03:13:08 2014
@@ -117,13 +117,13 @@
void gtAction::writeUnstyled(const QString& text, bool isNote)
{
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
if (isFirstWrite && it->itemText.length() > 0)
{
if (!doAppend)
{
if (UndoManager::undoEnabled())
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Selection, Um::IGroup, Um::ImportText, "", Um::IDelete));
+ activeTransaction = undoManager->beginTransaction(Um::Selection, Um::IGroup, Um::ImportText, "", Um::IDelete);
if (it->nextInChain() != 0)
{
PageItem *nextItem = it->nextInChain();
@@ -218,9 +218,7 @@
isFirstWrite = false;
if (activeTransaction)
{
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
+ activeTransaction.commit();
}
}
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19421&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Thu Aug 14 03:13:08 2014
@@ -1599,19 +1599,15 @@
void PageItem::setTextToFrameDist(double newLeft, double newRight, double newTop, double newBottom)
{
- UndoTransaction* activeTransaction = NULL;
- if (UndoManager::undoEnabled())
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::TextFrame, Um::IDocument, Um::TextFrameDist, "", Um::ITextFrame));
+ UndoTransaction activeTransaction;
+ if (UndoManager::undoEnabled())
+ activeTransaction = undoManager->beginTransaction(Um::TextFrame, Um::IDocument, Um::TextFrameDist, "", Um::ITextFrame);
setTextToFrameDistLeft(newLeft);
setTextToFrameDistRight(newRight);
setTextToFrameDistTop(newTop);
setTextToFrameDistBottom(newBottom);
if (activeTransaction)
- {
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
- }
+ activeTransaction.commit();
//emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
}
@@ -2966,44 +2962,36 @@
void PageItem::set4ColorTransparency(double t1, double t2, double t3, double t4)
{
- UndoTransaction *trans = NULL;
- if (UndoManager::undoEnabled())
- trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill));
+ UndoTransaction trans;
+ if (UndoManager::undoEnabled())
+ trans = undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill);
setGradientTransp1(t1);
setGradientTransp2(t2);
setGradientTransp3(t3);
setGradientTransp4(t4);
if (trans)
- {
- trans->commit();
- delete trans;
- trans = NULL;
- }
+ trans.commit();
}
void PageItem::set4ColorShade(int t1, int t2, int t3, int t4)
{
- UndoTransaction *trans = NULL;
- if (UndoManager::undoEnabled())
- trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill));
+ UndoTransaction trans;
+ if (UndoManager::undoEnabled())
+ trans = undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill);
setGradientShade1(t1);
setGradientShade2(t2);
setGradientShade3(t3);
setGradientShade4(t4);
if (trans)
- {
- trans->commit();
- delete trans;
- trans = NULL;
- }
+ trans.commit();
}
void PageItem::set4ColorColors(QString col1, QString col2, QString col3, QString col4)
{
QColor tmp;
- UndoTransaction *trans = NULL;
- if (UndoManager::undoEnabled())
- trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill));
+ UndoTransaction trans;
+ if (UndoManager::undoEnabled())
+ trans = undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill);
setGradientCol1(col1);
if (GrColorP1 != CommonStrings::None)
{
@@ -3161,11 +3149,7 @@
setGradientColor4(defect.convertDefect(GrColorP4QColor, m_Doc->previewVisual));
}
if (trans)
- {
- trans->commit();
- delete trans;
- trans = NULL;
- }
+ trans.commit();
}
void PageItem::get4ColorGeometry(FPoint &c1, FPoint &c2, FPoint &c3, FPoint &c4)
@@ -3253,10 +3237,10 @@
break;
}
- UndoTransaction *trans = NULL;
+ UndoTransaction trans;
if (UndoManager::undoEnabled())
{
- trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill));
+ trans = undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill);
ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradVal);
ss->set("GRAD_MESH_COLOR","grad_mesh_color");
ss->set("X",x);
@@ -3379,11 +3363,7 @@
}
}
if (trans)
- {
- trans->commit();
- delete trans;
- trans = NULL;
- }
+ trans.commit();
}
else
{
@@ -3538,10 +3518,10 @@
meshGradientArray[m-1][0].gridPoint.x(), meshGradientArray[m-1][0].gridPoint.y());
}
- UndoTransaction *trans = NULL;
- if (UndoManager::undoEnabled())
- {
- trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::ChangeMeshGradient,"",Um::IFill));
+ UndoTransaction trans;
+ if (UndoManager::undoEnabled())
+ {
+ trans = undoManager->beginTransaction(Um::Selection,Um::IFill,Um::ChangeMeshGradient,"",Um::IFill);
ScItemState<QPair<QList<QList<meshPoint> >,FPointArray> > *ism = new ScItemState<QPair<QList<QList<meshPoint> >,FPointArray> >(Um::ChangeMeshGradient, "",Um::IFill);
ism->set("MOVE_MESH_GRAD", "move_mesh_grad");
ism->setItem(qMakePair(meshGradientArray,PoLine));
@@ -3577,11 +3557,7 @@
}
ContourLine = PoLine.copy();
if (trans)
- {
- trans->commit();
- delete trans;
- trans = NULL;
- }
+ trans.commit();
}
void PageItem::createConicalMesh()
@@ -10613,10 +10589,10 @@
void PageItem::unWeld()
{
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
if (undoManager->undoEnabled())
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::WeldItems + "/" + Um::Selection, Um::IGroup,
- Um::WeldItems, "", Um::IDelete));
+ activeTransaction = undoManager->beginTransaction(Um::WeldItems + "/" + Um::Selection, Um::IGroup,
+ Um::WeldItems, "", Um::IDelete);
for (int a = 0 ; a < weldList.count(); a++)
{
weldingInfo wInf = weldList.at(a);
@@ -10651,11 +10627,7 @@
}
}
if (activeTransaction)
- {
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
- }
+ activeTransaction.commit();
weldList.clear();
}
Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19421&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Thu Aug 14 03:13:08 2014
@@ -4195,9 +4195,9 @@
unicodeInputString = "";
if (ok)
{
- UndoTransaction *trans = NULL;
+ UndoTransaction trans;
if(UndoManager::undoEnabled())
- trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::ITextFrame,Um::InsertText,"",Um::IDelete));
+ trans = undoManager->beginTransaction(Um::Selection,Um::ITextFrame,Um::InsertText,"",Um::IDelete);
if (itemText.lengthOfSelection() > 0)
deleteSelectedTextFromFrame();
if (conv < 31)
@@ -4217,12 +4217,8 @@
}
}
itemText.insertChars(QString(QChar(conv)), true);
- if(trans)
- {
- trans->commit();
- delete trans;
- trans = NULL;
- }
+ if (trans)
+ trans.commit();
// Tinput = true;
m_Doc->scMW()->setTBvals(this);
if (isAutoNoteFrame() && m_Doc->notesChanged())
@@ -4637,7 +4633,7 @@
if (isNoteFrame() && itemText.cursorPosition() == 0)
break; //avoid inserting chars before first note mark
bool doUpdate = false;
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
if (itemText.lengthOfSelection() > 0) //(kk < 0x1000)
{
bool x11Hack=false;
@@ -4654,7 +4650,7 @@
if (!controlCharHack && !x11Hack && !k->text().isEmpty())
{
if (UndoManager::undoEnabled())
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Selection, Um::IGroup, Um::ReplaceText, "", Um::IDelete));
+ activeTransaction = undoManager->beginTransaction(Um::Selection, Um::IGroup, Um::ReplaceText, "", Um::IDelete);
deleteSelectedTextFromFrame();
doUpdate = true;
@@ -4750,9 +4746,7 @@
{
if (activeTransaction)
{
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
+ activeTransaction.commit();
}
// update layout immediately, we need MaxChars to be correct to detect
// if we need to move to next frame or not
@@ -4810,7 +4804,7 @@
is = dynamic_cast<ScItemState<CharStyle>*>(ts->at(ts->sizet()-1));
state = ts->at(0);
}
- UndoTransaction* trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IDelete,Um::Delete,"",Um::IDelete));
+ UndoTransaction trans = undoManager->beginTransaction(Um::Selection,Um::IDelete,Um::Delete,"",Um::IDelete);
//find and delete notes and marks in selected text
QList<QPair<TextNote*, int> > notes2DEL;
@@ -4928,9 +4922,7 @@
}
if (trans)
{
- trans->commit();
- delete trans;
- trans = NULL;
+ trans.commit();
}
}
else //remove marks without undo
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19421&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Thu Aug 14 03:13:08 2014
@@ -1456,10 +1456,10 @@
{
if (unicodevalue!=-1)
{
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
if (currItem->HasSel){
if (UndoManager::undoEnabled())
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Selection, Um::IGroup, Um::ReplaceText, "", Um::IDelete));
+ activeTransaction = undoManager->beginTransaction(Um::Selection, Um::IGroup, Um::ReplaceText, "", Um::IDelete);
currItem->deleteSelectedTextFromFrame();
}
if (UndoManager::undoEnabled())
@@ -1484,11 +1484,7 @@
}
currItem->itemText.insertChars(QString(QChar(unicodevalue)), true);
if (activeTransaction)
- {
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
- }
+ activeTransaction.commit();
}
else if (unicodevalue==SpecialChars::SHYPHEN.unicode()) //ignore the char as we use an attribute if the text item, for now.
{
@@ -3506,9 +3502,9 @@
}
else
{
- UndoTransaction *pasteAction = NULL;
+ UndoTransaction pasteAction;
if(UndoManager::undoEnabled())
- pasteAction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create,"",Um::ICreate));
+ pasteAction = undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create,"",Um::ICreate);
view->Deselect(true);
uint ac = doc->Items->count();
bool savedAlignGrid = doc->SnapGrid;
@@ -3535,12 +3531,8 @@
AddBookMark(currItem);
}
doc->m_Selection->copy(tmpSelection, false);
- if(pasteAction)
- {
- pasteAction->commit();
- delete pasteAction;
- pasteAction = NULL;
- }
+ if (pasteAction)
+ pasteAction.commit();
}
slotDocCh(false);
doc->regionsChanged()->update(QRectF());
@@ -3711,9 +3703,9 @@
Q_ASSERT(!doc->masterPageMode());
bool ret = false;
MergeDoc *dia = new MergeDoc(this, false, doc->DocPages.count(), doc->currentPage()->pageNr() + 1);
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
if(UndoManager::undoEnabled())
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::ImportPage, Um::IGroup, Um::ImportPage, 0, Um::ILock));
+ activeTransaction = undoManager->beginTransaction(Um::ImportPage, Um::IGroup, Um::ImportPage, 0, Um::ILock);
if (dia->exec())
{
@@ -3800,11 +3792,7 @@
ret = doIt;
}
if (activeTransaction)
- {
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
- }
+ activeTransaction.commit();
delete dia;
return ret;
}
@@ -4953,7 +4941,7 @@
uint docSelectionCount=doc->m_Selection->count();
if ((HaveDoc) && (docSelectionCount != 0))
{
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
PageItem *currItem;
for (uint i = 0; i < docSelectionCount; ++i)
{
@@ -4967,11 +4955,11 @@
if (UndoManager::undoEnabled())
{
if (docSelectionCount > 1)
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Cut,"",Um::ICut));
+ activeTransaction = undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Cut,"",Um::ICut);
else
{
PageItem* item=doc->m_Selection->itemAt(0);
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(item->getUName(), item->getUPixmap(), Um::Cut, "", Um::ICut));
+ activeTransaction = undoManager->beginTransaction(item->getUName(), item->getUPixmap(), Um::Cut, "", Um::ICut);
}
}
currItem = doc->m_Selection->itemAt(0);
@@ -5034,9 +5022,7 @@
scrMenuMgr->setMenuEnabled("EditPasteRecent", scrapbookPalette->tempBView->objectMap.count() != 0);
if (activeTransaction)
{
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
+ activeTransaction.commit();
}
}
}
@@ -5123,11 +5109,11 @@
view->requestMode(submodeEndNodeEdit);
if (HaveDoc)
{
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
if (!ScMimeData::clipboardHasScribusData() && (!internalCopy))
return;
if (UndoManager::undoEnabled())
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(doc->currentPage()->getUName(), 0, Um::Paste, "", Um::IPaste));
+ activeTransaction = undoManager->beginTransaction(doc->currentPage()->getUName(), 0, Um::Paste, "", Um::IPaste);
PageItem* selItem = doc->m_Selection->itemAt(0);
if (((doc->appMode == modeEdit) || (doc->appMode == modeEditTable)) && (selItem->isTextFrame() || selItem->isTable()))
{
@@ -5333,11 +5319,7 @@
view->DrawNew();
}
if (activeTransaction)
- {
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
- }
+ activeTransaction.commit();
if (doc->notesChanged())
doc->notesFramesUpdate();
slotDocCh(false);
@@ -5665,10 +5647,10 @@
void ScribusMainWindow::addNewPages(int wo, int where, int numPages, double height, double width, int orient, QString siz, bool mov, QStringList* basedOn, bool overrideMasterPageSizing)
{
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
if (UndoManager::undoEnabled())
{
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(doc->getUName(), Um::IDocument, (numPages == 1) ? Um::AddPage : Um::AddPages, "", Um::ICreate));
+ activeTransaction = undoManager->beginTransaction(doc->getUName(), Um::IDocument, (numPages == 1) ? Um::AddPage : Um::AddPages, "", Um::ICreate);
SimpleState *ss = new SimpleState(Um::AddPage, "", Um::ICreate);
ss->set("ADD_PAGE", "add_page");
ss->set("PAGE", wo);
@@ -5774,9 +5756,7 @@
if (activeTransaction)
{
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
+ activeTransaction.commit();
}
}
@@ -6819,16 +6799,16 @@
void ScribusMainWindow::deletePage(int from, int to)
{
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
assert( from > 0 );
assert( from <= to );
assert( to <= static_cast<int>(doc->Pages->count()) );
int oldPg = doc->currentPageNumber();
guidePalette->setDoc(NULL);
if (UndoManager::undoEnabled())
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(doc->DocName, Um::IDocument,
- (from - to == 0) ? Um::DeletePage : Um::DeletePages, "",
- Um::IDelete));
+ activeTransaction = undoManager->beginTransaction(doc->DocName, Um::IDocument,
+ (from - to == 0) ? Um::DeletePage : Um::DeletePages, "",
+ Um::IDelete);
PageItem* ite;
doc->m_Selection->clear();
Selection tmpSelection(this, false);
@@ -6901,9 +6881,7 @@
pagePalette->rebuildMasters();
if (activeTransaction)
{
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
+ activeTransaction.commit();
}
}
@@ -7125,21 +7103,17 @@
doc->SnapElement = false;
slotEditCopy();
view->Deselect(true);
- UndoTransaction *trans = NULL;
- if(UndoManager::undoEnabled())
- trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IPolygon,Um::Duplicate,"",Um::IMultipleDuplicate));
+ UndoTransaction trans;
+ if (UndoManager::undoEnabled())
+ trans = undoManager->beginTransaction(Um::Selection,Um::IPolygon,Um::Duplicate,"",Um::IMultipleDuplicate);
slotEditPaste();
for (int b=0; b<doc->m_Selection->count(); ++b)
{
doc->m_Selection->itemAt(b)->setLocked(false);
doc->MoveItem(doc->opToolPrefs().dispX, doc->opToolPrefs().dispY, doc->m_Selection->itemAt(b));
}
- if(trans)
- {
- trans->commit();
- delete trans;
- trans = NULL;
- }
+ if (trans)
+ trans.commit();
doc->SnapGrid = savedAlignGrid;
doc->SnapGuides = savedAlignGuides;
doc->SnapElement = savedAlignElement;
@@ -9570,9 +9544,9 @@
TransformDialog td(this, doc);
if (td.exec() == 0)
return;
- UndoTransaction *trans = NULL;
- if(UndoManager::undoEnabled())
- trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IPolygon,Um::Transform,"",Um::IMove));
+ UndoTransaction trans;
+ if (UndoManager::undoEnabled())
+ trans = undoManager->beginTransaction(Um::Selection,Um::IPolygon,Um::Transform,"",Um::IMove);
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
int count=td.getCount();
QTransform matrix(td.getTransformMatrix());
@@ -9581,9 +9555,7 @@
qApp->restoreOverrideCursor();
if (trans)
{
- trans->commit();
- delete trans;
- trans = NULL;
+ trans.commit();
}
}
@@ -10167,14 +10139,14 @@
if (doc->appMode != modeEdit)
return;
- UndoTransaction* trans = NULL;
+ UndoTransaction trans;
PageItem* currItem = doc->m_Selection->itemAt(0);
if (!currItem->isTextFrame())
return;
if (currItem->HasSel)
{
if (UndoManager::instance()->undoEnabled())
- trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IDelete,Um::Delete,"",Um::IDelete));
+ trans = undoManager->beginTransaction(Um::Selection,Um::IDelete,Um::Delete,"",Um::IDelete);
//inserting mark replace some selected text
currItem->asTextFrame()->deleteSelectedTextFromFrame();
}
@@ -10201,9 +10173,7 @@
}
if (trans)
{
- trans->commit();
- delete trans;
- trans = NULL;
+ trans.commit();
}
}
@@ -10259,11 +10229,11 @@
{ //fast insert note with the only default notes style avaiable
PageItem* currItem = doc->m_Selection->itemAt(0);
Q_ASSERT(currItem->isTextFrame() && !currItem->isNoteFrame());
- UndoTransaction* trans = NULL;
+ UndoTransaction trans;
if (currItem->HasSel)
{
if (UndoManager::instance()->undoEnabled())
- trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IDelete,Um::Delete,"",Um::IDelete));
+ trans = undoManager->beginTransaction(Um::Selection,Um::IDelete,Um::Delete,"",Um::IDelete);
//inserting mark replace some selected text
currItem->asTextFrame()->deleteSelectedTextFromFrame();
}
@@ -10310,11 +10280,7 @@
undoManager->action(doc, is);
}
if (trans)
- {
- trans->commit();
- delete trans;
- trans = NULL;
- }
+ trans.commit();
}
else
insertMark(MARKNoteMasterType);
Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19421&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Thu Aug 14 03:13:08 2014
@@ -652,7 +652,7 @@
QString text;
QUrl url;
PageItem *currItem;
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
bool img = false;
m_canvas->resetRenderMode();
redrawMode = 0;
@@ -918,7 +918,7 @@
uint oldDocItemCount = Doc->Items->count();
if (((!img) || (vectorFile)) && (Doc->DraggedElem == 0))
{
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create,"",Um::ICreate));
+ activeTransaction = undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create, "", Um::ICreate);
if (fi.exists())
{
QString data;
@@ -988,9 +988,8 @@
emit AddBM(currItem);
}
Doc->m_Selection->copy(tmpSelection, false);
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
+ activeTransaction.commit();
+ activeTransaction.reset();
}
else
{
@@ -1099,7 +1098,7 @@
nx = npx.x();
ny = npx.y();
}
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Move,"",Um::IMove));
+ activeTransaction = undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Move, "", Um::IMove);
Doc->moveGroup(nx-gx, ny-gy);
Doc->m_Selection->setGroupRect();
Doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
@@ -1119,9 +1118,8 @@
currItem->gWidth = gw;
currItem->gHeight = gh;
}
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
+ activeTransaction.commit();
+ activeTransaction.reset();
emit ItemGeom();
}
else if (Doc->m_Selection->count() == 1)
@@ -1730,10 +1728,10 @@
//CB Remove emit/start pasting objects
void ScribusView::PasteToPage()
{
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
int ac = Doc->Items->count();
if (UndoManager::undoEnabled())
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Doc->currentPage()->getUName(), 0, Um::Paste, "", Um::IPaste));
+ activeTransaction = undoManager->beginTransaction(Doc->currentPage()->getUName(), 0, Um::Paste, "", Um::IPaste);
/* if (ScMimeData::clipboardHasScribusFragment())
{
bool savedAlignGrid = Doc->SnapGrid;
@@ -1814,18 +1812,16 @@
{
if (activeTransaction)
{
- activeTransaction->cancel();
- delete activeTransaction;
- activeTransaction = NULL;
+ activeTransaction.cancel();
+ activeTransaction.reset();
}
return;
}
newObjects.clear();
if (activeTransaction)
{
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
+ activeTransaction.commit();
+ activeTransaction.reset();
}
emit DocChanged();
}
@@ -1927,7 +1923,7 @@
*/
void ScribusView::endGroupTransaction()
{
- if(m_groupTransactions > 0)
+ if (m_groupTransactions > 0)
{
--m_groupTransactions;
}
@@ -1944,7 +1940,7 @@
*/
void ScribusView::cancelGroupTransaction()
{
- if(m_groupTransaction && m_groupTransactions == 1)
+ if (m_groupTransaction && m_groupTransactions == 1)
{
m_groupTransaction->cancel();
delete m_groupTransaction;
Modified: trunk/Scribus/scribus/ui/cpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19421&path=/trunk/Scribus/scribus/ui/cpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/cpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/cpalette.cpp Thu Aug 14 03:13:08 2014
@@ -746,18 +746,14 @@
double t2 = color2Alpha->value() / 100.0;
double t3 = color3Alpha->value() / 100.0;
double t4 = color4Alpha->value() / 100.0;
- UndoTransaction *trans = NULL;
- if(UndoManager::undoEnabled())
- trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill));
+ UndoTransaction trans;
+ if (UndoManager::undoEnabled())
+ trans = undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill);
currentItem->set4ColorShade(static_cast<int>(color1Shade->value()), static_cast<int>(color2Shade->value()), static_cast<int>(color3Shade->value()), static_cast<int>(color4Shade->value()));
currentItem->set4ColorTransparency(t1, t2, t3, t4);
currentItem->set4ColorColors(color1, color2, color3, color4);
- if(trans)
- {
- trans->commit();
- delete trans;
- trans = NULL;
- }
+ if (trans)
+ trans.commit();
currentItem->update();
}
Modified: trunk/Scribus/scribus/ui/guidemanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19421&path=/trunk/Scribus/scribus/ui/guidemanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/guidemanager.cpp (original)
+++ trunk/Scribus/scribus/ui/guidemanager.cpp Thu Aug 14 03:13:08 2014
@@ -519,12 +519,12 @@
void GuideManager::deletePageButton_clicked()
{
- UndoTransaction *trans = NULL;
+ UndoTransaction trans;
if(UndoManager::undoEnabled())
- trans = new UndoTransaction(UndoManager::instance()->beginTransaction(currentPage->getUName(),
- currentPage->getUPixmap(),
- Um::RemoveAllPageGuides, "",
- Um::IGuides));
+ trans = UndoManager::instance()->beginTransaction(currentPage->getUName(),
+ currentPage->getUPixmap(),
+ Um::RemoveAllPageGuides, "",
+ Um::IGuides);
currentPage->guides.clearHorizontals(GuideManagerCore::Standard);
currentPage->guides.clearVerticals(GuideManagerCore::Standard);
currentPage->guides.clearHorizontals(GuideManagerCore::Auto);
@@ -540,12 +540,9 @@
currentPage->guides.setVerticalAutoRefer(0);
horizontalAutoCountSpin->setValue(0);
verticalAutoCountSpin->setValue(0);
- if(trans)
- {
- trans->commit();
- delete trans;
- trans = NULL;
- }
+
+ if (trans)
+ trans.commit();
drawGuides();
m_Doc->changed();
@@ -553,23 +550,19 @@
void GuideManager::deleteAllGuides_clicked()
{
- UndoTransaction *trans = NULL;
- if(UndoManager::undoEnabled())
- trans = new UndoTransaction(UndoManager::instance()->beginTransaction(m_Doc->getUName(),
- m_Doc->getUPixmap(),
- Um::RemoveAllGuides, "",
- Um::IGuides));
+ UndoTransaction trans;
+ if (UndoManager::undoEnabled())
+ trans = UndoManager::instance()->beginTransaction(m_Doc->getUName(),
+ m_Doc->getUPixmap(),
+ Um::RemoveAllGuides, "",
+ Um::IGuides);
m_drawGuides = false;
deletePageButton_clicked();
copyGuidesToAllPages(GuideManagerCore::Standard);
copyGuidesToAllPages(GuideManagerCore::Auto);
m_drawGuides = true;
- if(trans)
- {
- trans->commit();
- delete trans;
- trans = NULL;
- }
+ if (trans)
+ trans.commit();
drawGuides();
m_Doc->changed();
}
Modified: trunk/Scribus/scribus/ui/layers.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19421&path=/trunk/Scribus/scribus/ui/layers.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/layers.cpp (original)
+++ trunk/Scribus/scribus/ui/layers.cpp Thu Aug 14 03:13:08 2014
@@ -280,9 +280,9 @@
{
if (!m_Doc)
return;
- UndoTransaction *copyTransaction = NULL;
- if(UndoManager::undoEnabled())
- copyTransaction = new UndoTransaction(UndoManager::instance()->beginTransaction("", Um::ILayerAction, Um::DuplicateLayer.arg(m_Doc->activeLayerName()) , "", Um::ICreate) );
+ UndoTransaction copyTransaction;
+ if (UndoManager::undoEnabled())
+ copyTransaction = UndoManager::instance()->beginTransaction("", Um::ILayerAction, Um::DuplicateLayer.arg(m_Doc->activeLayerName()) , "", Um::ICreate);
int current = m_Doc->activeLayer();
@@ -293,9 +293,7 @@
m_Doc->scMW()->changeLayer(m_Doc->activeLayer());
if (copyTransaction)
{
- copyTransaction->commit();
- delete copyTransaction;
- copyTransaction = NULL;
+ copyTransaction.commit();
}
}
Modified: trunk/Scribus/scribus/ui/loremipsum.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19421&path=/trunk/Scribus/scribus/ui/loremipsum.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/loremipsum.cpp (original)
+++ trunk/Scribus/scribus/ui/loremipsum.cpp Thu Aug 14 03:13:08 2014
@@ -302,11 +302,11 @@
i2 = currItem->asTable()->activeCell().textFrame();
if (!i2->asTextFrame())
continue;
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
if (!appendCheckBox->isChecked() && i2->itemText.length() != 0)
{
if (UndoManager::undoEnabled())
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Selection, Um::IGroup, Um::AddLoremIpsum, "", Um::ICreate));
+ activeTransaction = undoManager->beginTransaction(Um::Selection, Um::IGroup, Um::AddLoremIpsum, "", Um::ICreate);
i2->itemText.selectAll();
i2->asTextFrame()->deleteSelectedTextFromFrame();
//We don't need to open a dialog box as the user can undo this action.
@@ -337,12 +337,9 @@
undoManager->action(i2, ss);
}
if (activeTransaction)
- {
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
- }
- int l=i2->itemText.length();
+ activeTransaction.commit();
+
+ int l = i2->itemText.length();
i2->itemText.insertChars(l, sampleText);
delete lp;
if (m_Doc->docHyphenator->AutoCheck)
Modified: trunk/Scribus/scribus/ui/masterpagepalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19421&path=/trunk/Scribus/scribus/ui/masterpagepalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/masterpagepalette.cpp (original)
+++ trunk/Scribus/scribus/ui/masterpagepalette.cpp Thu Aug 14 03:13:08 2014
@@ -117,9 +117,9 @@
void MasterPagesPalette::deleteMasterPage()
{
bool forceDelete = false;
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
if (UndoManager::undoEnabled())
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Group, Um::IGroup, Um::DelMasterPage, "", Um::IDelete));
+ activeTransaction = undoManager->beginTransaction(Um::Group, Um::IGroup, Um::DelMasterPage, "", Um::IDelete);
// allow to delete multiple pages in one step
foreach (QListWidgetItem * delItem, masterPageListBox->selectedItems())
{
@@ -170,18 +170,16 @@
updateMasterPageList(m_masterPage);
if (activeTransaction)
{
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
+ activeTransaction.commit();
}
}
void MasterPagesPalette::duplicateMasterPage()
{
int copyC = 1;
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
if (UndoManager::undoEnabled())
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Group, Um::IGroup, Um::DuplicateMasterPage, "", Um::IGroup));
+ activeTransaction = undoManager->beginTransaction(Um::Group, Um::IGroup, Um::DuplicateMasterPage, "", Um::IGroup);
QString potentialMasterPageName(m_masterPage);
while (m_doc->MasterNames.contains(potentialMasterPageName))
potentialMasterPageName = tr("Copy #%1 of %2").arg(copyC++).arg(m_masterPage);
@@ -306,9 +304,7 @@
}
if (activeTransaction)
{
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
+ activeTransaction.commit();
}
delete dia;
}
@@ -316,9 +312,9 @@
void MasterPagesPalette::newMasterPage()
{
QString MasterPageName;
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
if (UndoManager::undoEnabled())
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Group, Um::IGroup, Um::NewMasterPage, "", Um::IGroup));
+ activeTransaction = undoManager->beginTransaction(Um::Group, Um::IGroup, Um::NewMasterPage, "", Um::IGroup);
int nr = m_doc->Pages->count();
NewTm *dia = new NewTm(this, tr("Name:"), tr("New MasterPage"), m_doc, tr("New Master Page %1").arg(nr));
if (dia->exec())
@@ -369,18 +365,16 @@
}
if (activeTransaction)
{
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
+ activeTransaction.commit();
}
delete dia;
}
void MasterPagesPalette::importPage()
{
- UndoTransaction* activeTransaction = NULL;
+ UndoTransaction activeTransaction;
if (UndoManager::undoEnabled())
- activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Group, Um::IGroup, Um::ImportMasterPage, "", Um::IGroup));
+ activeTransaction = undoManager->beginTransaction(Um::Group, Um::IGroup, Um::ImportMasterPage, "", Um::IGroup);
//bool atf;
MergeDoc *dia = new MergeDoc(this, true);
if (dia->exec())
@@ -428,9 +422,7 @@
}
if (activeTransaction)
{
- activeTransaction->commit();
- delete activeTransaction;
- activeTransaction = NULL;
+ activeTransaction.commit();
}
delete dia;
}
Modified: trunk/Scribus/scribus/ui/propertiespalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19421&path=/trunk/Scribus/scribus/ui/propertiespalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette.cpp Thu Aug 14 03:13:08 2014
@@ -669,9 +669,9 @@
if ((m_haveDoc) && (m_haveItem))
{
QRectF upRect;
- UndoTransaction *trans = NULL;
- if(UndoManager::undoEnabled())
- trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::ILine,Um::GradPos + "p","",Um::ILine));
+ UndoTransaction trans;
+ if (UndoManager::undoEnabled())
+ trans = undoManager->beginTransaction(Um::Selection, Um::ILine, Um::GradPos + "p", "", Um::ILine);
if (m_ScMW->view->editStrokeGradient == 1)
{
m_item->setGradientStrokeStartX(x1 / m_unitRatio);
@@ -766,12 +766,8 @@
upRect |= QRectF(shP, QPointF(0, 0)).normalized();
upRect |= QRectF(shP, QPointF(m_item->width(), m_item->height())).normalized();
}
- if(trans)
- {
- trans->commit();
- delete trans;
- trans = NULL;
- }
+ if (trans)
+ trans.commit();
upRect.translate(m_item->xPos(), m_item->yPos());
m_doc->regionsChanged()->update(upRect.adjusted(-10.0, -10.0, 10.0, 10.0));
m_doc->changed();
@@ -817,9 +813,9 @@
if ((m_haveDoc) && (m_haveItem))
{
QRectF upRect;
- UndoTransaction *trans = NULL;
- if(UndoManager::undoEnabled())
- trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::ILine,Um::GradPos + "o","",Um::ILine));
+ UndoTransaction trans;
+ if (UndoManager::undoEnabled())
+ trans = undoManager->beginTransaction(Um::Selection, Um::ILine, Um::GradPos + "o", "", Um::ILine);
m_item->setGradientMaskStartX(x1 / m_unitRatio);
m_item->setGradientMaskStartY(y1 / m_unitRatio);
m_item->setGradientMaskEndX(x2 / m_unitRatio);
@@ -834,11 +830,9 @@
m_item->setGradientMaskFocalY(m_item->GrMaskStartY);
}
m_item->update();
- if(trans)
- {
- trans->commit();
- delete trans;
- trans = NULL;
+ if (trans)
+ {
+ trans.commit();
}
upRect = QRectF(QPointF(m_item->GrMaskStartX, m_item->GrMaskStartY), QPointF(m_item->GrMaskEndX, m_item->GrMaskEndY));
double radEnd = distance(m_item->GrMaskEndX - m_item->GrMaskStartX, m_item->GrMaskEndY - m_item->GrMaskStartY);
More information about the scribus-commit
mailing list