Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 11575 → Rev 11576

/trunk/Scribus/scribus/canvasmode_drawbezier.h
24,8 → 24,8
class PageItem;
class ScribusMainWindow;
class ScribusView;
class UndoTransaction;
 
 
/**
Handles the creation of new pageitems
*/
49,6 → 49,7
inline bool GetItem(PageItem** pi);
void selectPage(QMouseEvent *m);
 
UndoTransaction* m_createTransaction;
int Cp, oldCp;
bool inItemCreation, shiftSelItems, FirstPoly;
bool m_MouseButtonPressed;
/trunk/Scribus/scribus/canvasmode_legacy.cpp
2309,6 → 2309,7
{
if ((m_doc->m_Selection->count() == 0) && (m_view->HaveSelRect) && (!m_view->MidButt))
{
UndoTransaction* activeTransaction = NULL;
QRect AreaR = QRect(static_cast<int>(Mxp), static_cast<int>(Myp), static_cast<int>(SeRx-Mxp), static_cast<int>(SeRy-Myp)).normalized();
m_view->HaveSelRect = false;
double Tx, Ty, Tw, Th;
2355,10 → 2356,10
offY = 0.0;
m_doc->m_Selection->clear();
if (UndoManager::undoEnabled())
m_view->undoManager->beginTransaction(m_doc->currentPage()->getUName(),
Um::ITable, Um::CreateTable,
QString(Um::RowsCols).arg(Rows).arg(Cols),
Um::ICreate);
activeTransaction = new UndoTransaction(m_view->undoManager->beginTransaction(m_doc->currentPage()->getUName(),
Um::ITable, Um::CreateTable,
QString(Um::RowsCols).arg(Rows).arg(Cols),
Um::ICreate));
for (int rc = 0; rc < Rows; ++rc)
{
for (int cc = 0; cc < Cols; ++cc)
2400,8 → 2401,12
}
}
m_ScMW->GroupObj();
if (UndoManager::undoEnabled())
m_view->undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
m_doc->changed();
}
if (!PrefsManager::instance()->appPrefs.stickyTools)
2964,10 → 2969,11
m_doc->SizeItem(npx.x(), npx.y(), currItem->ItemNr);
bool sav = m_doc->SnapGuides;
m_doc->SnapGuides = false;
UndoTransaction* activeTransaction = NULL;
if (UndoManager::undoEnabled())
{
m_view->undoManager->beginTransaction(currItem->getUName(), currItem->getUPixmap(),
Um::Resize, QString(Um::ResizeFromTo).arg(currItem->width()).arg(currItem->height()).arg(currItem->width() - npx.x()).arg(currItem->height() - npx.y()), Um::IResize);
activeTransaction = new UndoTransaction(m_view->undoManager->beginTransaction(currItem->getUName(), currItem->getUPixmap(),
Um::Resize, QString(Um::ResizeFromTo).arg(currItem->width()).arg(currItem->height()).arg(currItem->width() - npx.x()).arg(currItem->height() - npx.y()), Um::IResize));
}
m_canvas->m_viewMode.operItemResizing = false;
switch (frameResizeHandle)
3604,8 → 3610,12
m_view->updateContents();
// emit DocChanged();
currItem->checkChanges();
if (UndoManager::undoEnabled())
m_view->undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
}
m_doc->setRedrawBounding(currItem);
currItem->OwnPage = m_doc->OnPage(currItem);
/trunk/Scribus/scribus/scribusview.h
76,10 → 76,10
class ScribusWin;
class ScribusMainWindow;
class UndoManager;
class UndoTransaction;
 
 
 
 
/**
* This class provides an incomplete base for your application view.
*/
211,7 → 211,6
void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false, bool noResize = true);
// void QueryFarben();
void rememberOldZoomLocation(int mx=0, int my=0);
bool mousePressed();
bool groupTransactionStarted() { return m_groupTransactions > 0; }
// void setGroupTransactionStarted(bool isOn);
void startGroupTransaction(const QString &actionName = "",
317,6 → 316,7
int oldX;
int oldY;
int m_groupTransactions;
UndoTransaction* m_groupTransaction;
bool _isGlobalMode;
// bool forceRedraw;
 
344,6 → 344,8
void keyReleaseEvent(QKeyEvent *k);
 
inline void registerMousePress(QPoint p);
bool mousePressed();
void resetMousePressed();
inline QPoint mousePressLocation();
inline bool moveTimerElapsed();
inline void resetMoveTimer();
/trunk/Scribus/scribus/guidemanager.cpp
436,10 → 436,10
 
void GuideManager::deletePageButton_clicked()
{
UndoManager::instance()->beginTransaction(currentPage->getUName(),
currentPage->getUPixmap(),
Um::RemoveAllPageGuides, "",
Um::IGuides);
UndoTransaction 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);
455,7 → 455,7
currentPage->guides.setVerticalAutoRefer(0);
horizontalAutoCountSpin->setValue(0);
verticalAutoCountSpin->setValue(0);
UndoManager::instance()->commit();
trans.commit();
 
drawGuides();
}
462,16 → 462,16
 
void GuideManager::deleteAllGuides_clicked()
{
UndoManager::instance()->beginTransaction(m_Doc->getUName(),
m_Doc->getUPixmap(),
Um::RemoveAllGuides, "",
Um::IGuides);
UndoTransaction 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;
UndoManager::instance()->commit();
trans.commit();
drawGuides();
}
 
/trunk/Scribus/scribus/pageitem.cpp
2721,8 → 2721,6
 
void PageItem::moveUndoAction()
{
if (!shouldCheck())
return;
if (oldXpos == Xpos && oldYpos == Ypos)
return;
if (UndoManager::undoEnabled())
2753,8 → 2751,6
 
void PageItem::resizeUndoAction()
{
if (!shouldCheck())
return;
if (oldHeight == Height && oldWidth == Width)
return;
if (UndoManager::undoEnabled())
2784,8 → 2780,6
 
void PageItem::rotateUndoAction()
{
if (!shouldCheck())
return;
if (oldRot == Rot)
return;
if (UndoManager::undoEnabled())
2815,8 → 2809,6
 
void PageItem::changeImageOffsetUndoAction()
{
if (!shouldCheck())
return;
if (oldLocalX == LocalX && oldLocalY == LocalY)
return;
if (UndoManager::undoEnabled())
2835,8 → 2827,6
 
void PageItem::changeImageScaleUndoAction()
{
if (!shouldCheck())
return;
if (oldLocalScX == LocalScX && oldLocalScY == LocalScY)
return;
if (UndoManager::undoEnabled())
3221,7 → 3211,7
}
 
 
// This must go into class ScribusDoc!
// FIXME: This must go into class ScribusDoc!
// For now we'll just make it independent of 'this' -- AV
void PageItem::restoreType(SimpleState *state, bool isUndo)
{
/trunk/Scribus/scribus/scribusview.cpp
166,6 → 166,7
Ready(false),
oldX(0), oldY(0),
m_groupTransactions(0),
m_groupTransaction(NULL),
_isGlobalMode(true),
// evSpon(false),
// forceRedraw(false),
776,6 → 777,7
QString text;
QUrl url;
PageItem *currItem;
UndoTransaction* activeTransaction = NULL;
bool img = false;
m_canvas->resetRenderMode();
redrawMode = 0;
937,7 → 939,7
uint oldDocItemCount = Doc->Items->count();
if ((!img) && (Doc->DraggedElem == 0))
{
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create,"",Um::ICreate);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create,"",Um::ICreate));
if ((fi.exists()) && (!img))
{
QString data;
1004,7 → 1006,9
emit AddBM(currItem);
}
Doc->m_Selection->copy(tmpSelection, false, false);
undoManager->commit();
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
else
{
1121,7 → 1125,7
nx = npx.x();
ny = npx.y();
}
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Move,"",Um::IMove);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Move,"",Um::IMove));
Doc->moveGroup(nx-gx, ny-gy, false);
Doc->m_Selection->setGroupRect();
Doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
1139,7 → 1143,9
currItem->gWidth = gw;
currItem->gHeight = gh;
}
undoManager->commit();
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
emit ItemPos(gx, gy);
emit ItemGeom(gw, gh);
}
2085,9 → 2091,10
//CB Remove emit/start pasting objects
void ScribusView::PasteToPage()
{
UndoTransaction* activeTransaction = NULL;
int ac = Doc->Items->count();
if (UndoManager::undoEnabled())
undoManager->beginTransaction(Doc->currentPage()->getUName(), 0, Um::Paste, "", Um::IPaste);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Doc->currentPage()->getUName(), 0, Um::Paste, "", Um::IPaste));
if (m_ScMW->Buffer2.contains("<SCRIBUSFRAGMENT"))
{
bool savedAlignGrid = Doc->useRaster;
2161,8 → 2168,12
currItem->emitAllToGUI();
}
newObjects.clear();
if (UndoManager::undoEnabled())
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
}
 
 
2199,6 → 2210,12
return m_canvas->m_viewMode.m_MouseButtonPressed;
}
 
void ScribusView::resetMousePressed()
{
m_canvas->m_viewMode.m_MouseButtonPressed = false;
}
 
 
void ScribusView::startGroupTransaction(const QString& action, const QString& description, QPixmap* actionIcon, Selection* customSelection)
{
Selection* itemSelection = (customSelection!=0) ? customSelection : Doc->m_Selection;
2205,39 → 2222,63
assert(itemSelection!=0);
uint selectedItemCount=itemSelection->count();
Q_ASSERT(selectedItemCount > 0);
QString tooltip = description;
QString target = Um::SelectionGroup;
QPixmap* targetIcon = Um::IGroup;
if (tooltip.isEmpty() && selectedItemCount > 1)
if (!m_groupTransaction)
{
tooltip = Um::ItemsInvolved + "\n";
for (uint i = 0; i < selectedItemCount; ++i)
tooltip += "\t" + itemSelection->itemAt(i)->getUName() + "\n";
QString tooltip = description;
QString target = Um::SelectionGroup;
QPixmap* targetIcon = Um::IGroup;
if (tooltip.isEmpty() && selectedItemCount > 1)
{
tooltip = Um::ItemsInvolved + "\n";
for (uint i = 0; i < selectedItemCount; ++i)
tooltip += "\t" + itemSelection->itemAt(i)->getUName() + "\n";
}
if (selectedItemCount == 1)
{
target = itemSelection->itemAt(0)->getUName();
targetIcon = itemSelection->itemAt(0)->getUPixmap();
}
m_groupTransaction = new UndoTransaction(undoManager->beginTransaction(target, targetIcon,
action, tooltip, actionIcon));
}
if (selectedItemCount == 1)
{
target = itemSelection->itemAt(0)->getUName();
targetIcon = itemSelection->itemAt(0)->getUPixmap();
}
undoManager->beginTransaction(target, targetIcon,
action, tooltip, actionIcon);
++m_groupTransactions;
}
 
 
/**
*/
void ScribusView::endGroupTransaction()
{
assert(m_groupTransactions > 0);
undoManager->commit();
--m_groupTransactions;
if(m_groupTransactions > 0)
{
--m_groupTransactions;
}
if (m_groupTransaction && m_groupTransactions == 0)
{
m_groupTransaction->commit();
delete m_groupTransaction;
m_groupTransaction = NULL;
}
}
 
 
/**
Always cancels the toplevel transaction and all enclosed ones
*/
void ScribusView::cancelGroupTransaction()
{
assert(m_groupTransactions > 0);
undoManager->cancelTransaction();
--m_groupTransactions;
if(m_groupTransaction && m_groupTransactions == 1)
{
m_groupTransaction->cancel();
delete m_groupTransaction;
m_groupTransaction = NULL;
}
else if (m_groupTransaction)
{
m_groupTransaction->markFailed();
}
if (m_groupTransactions > 0)
--m_groupTransactions;
}
 
 
3208,11 → 3249,11
{
// OBSOLETE CR 2005-02-06
case PageItem::ItemType1:
z = Doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, x, y, w, h, pw, Buffer->Pcolor, Buffer->Pcolor2, !m_canvas->m_viewMode.m_MouseButtonPressed);
z = Doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, x, y, w, h, pw, Buffer->Pcolor, Buffer->Pcolor2, true);
break;
//
case PageItem::ImageFrame:
z = Doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, x, y, w, h, 1, Doc->toolSettings.dBrushPict, CommonStrings::None, !m_canvas->m_viewMode.m_MouseButtonPressed);
z = Doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, x, y, w, h, 1, Doc->toolSettings.dBrushPict, CommonStrings::None, true);
Doc->Items->at(z)->setImageXYScale(Buffer->LocalScX, Buffer->LocalScY);
Doc->Items->at(z)->setImageXYOffset(Buffer->LocalX, Buffer->LocalY);
Doc->Items->at(z)->Pfile = Buffer->Pfile;
3232,7 → 3273,7
break;
// OBSOLETE CR 2005-02-06
case PageItem::ItemType3:
z = Doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, x, y, w, h, pw, Buffer->Pcolor, Buffer->Pcolor2, !m_canvas->m_viewMode.m_MouseButtonPressed);
z = Doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, x, y, w, h, pw, Buffer->Pcolor, Buffer->Pcolor2, true);
break;
//
case PageItem::PathText:
3239,9 → 3280,9
case PageItem::TextFrame:
#ifndef NLS_PROTO
if (Buffer->PType == PageItem::PathText)
z = Doc->itemAdd(PageItem::PathText, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Buffer->Pcolor, !m_canvas->m_viewMode.m_MouseButtonPressed);
z = Doc->itemAdd(PageItem::PathText, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Buffer->Pcolor, true);
else
z = Doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Buffer->Pcolor, !m_canvas->m_viewMode.m_MouseButtonPressed);
z = Doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Buffer->Pcolor, true);
if ((Buffer->m_isAnnotation) && (Buffer->m_annotation.UseIcons()))
{
Doc->Items->at(z)->setImageXYScale(Buffer->LocalScX, Buffer->LocalScY);
3357,19 → 3398,19
#endif
break;
case PageItem::Line:
z = Doc->itemAdd(PageItem::Line, PageItem::Unspecified, x, y, w ,0, pw, CommonStrings::None, Buffer->Pcolor2, !m_canvas->m_viewMode.m_MouseButtonPressed);
z = Doc->itemAdd(PageItem::Line, PageItem::Unspecified, x, y, w ,0, pw, CommonStrings::None, Buffer->Pcolor2, true);
break;
case PageItem::Polygon:
z = Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, x, y, w, h, pw, Buffer->Pcolor, Buffer->Pcolor2, !m_canvas->m_viewMode.m_MouseButtonPressed);
z = Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, x, y, w, h, pw, Buffer->Pcolor, Buffer->Pcolor2, true);
break;
case PageItem::PolyLine:
z = Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, x, y, w, h, pw, Buffer->Pcolor, Buffer->Pcolor2, !m_canvas->m_viewMode.m_MouseButtonPressed);
z = Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, x, y, w, h, pw, Buffer->Pcolor, Buffer->Pcolor2, true);
break;
case PageItem::Multiple:
Q_ASSERT(false);
break;
case PageItem::LatexFrame:
z = Doc->itemAdd(PageItem::LatexFrame, PageItem::Unspecified, x, y, w, h, 1, Doc->toolSettings.dBrushPict, CommonStrings::None, !m_canvas->m_viewMode.m_MouseButtonPressed);
z = Doc->itemAdd(PageItem::LatexFrame, PageItem::Unspecified, x, y, w, h, 1, Doc->toolSettings.dBrushPict, CommonStrings::None, true);
Doc->Items->at(z)->setImageXYScale(Buffer->LocalScX, Buffer->LocalScY);
Doc->Items->at(z)->setImageXYOffset(Buffer->LocalX, Buffer->LocalY);
Doc->Items->at(z)->Pfile = Buffer->Pfile;
3770,7 → 3811,7
uint selectedItemCount = tmpSelection.count();
if (selectedItemCount != 0)
{
undoManager->beginTransaction(currItem->getUName(), currItem->getUPixmap(), Um::ToOutlines, "", 0);
UndoTransaction trans(undoManager->beginTransaction(currItem->getUName(), currItem->getUPixmap(), Um::ToOutlines, "", 0));
uint offset=0;
for(uint i=0; i<selectedItemCount; ++i)
{
3866,7 → 3907,7
sca.translate(currItem->xPos(), currItem->yPos());
pts.map(sca);
}
uint z = Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, currItem->xPos(), currItem->yPos(), currItem->width(), currItem->height(), currItem->lineWidth(), currItem->lineColor(), currItem->fillColor(), !m_canvas->m_viewMode.m_MouseButtonPressed);
uint z = Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, currItem->xPos(), currItem->yPos(), currItem->width(), currItem->height(), currItem->lineWidth(), currItem->lineColor(), currItem->fillColor(), true);
bb = Doc->Items->at(z);
//bb->setTextFlowsAroundFrame(currItem->textFlowsAroundFrame());
//bb->setTextFlowUsesBoundingBox(currItem->textFlowUsesBoundingBox());
3972,7 → 4013,7
}
if (charStyle.baselineOffset() != 0)
st += (charStyle.fontSize() / 10.0) * hl->glyph.scaleV * (charStyle.baselineOffset() / 1000.0);
uint z = Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, currItem->xPos(), currItem->yPos(), currItem->width(), currItem->height(), currItem->lineWidth(), currItem->lineColor(), currItem->fillColor(), !m_canvas->m_viewMode.m_MouseButtonPressed);
uint z = Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, currItem->xPos(), currItem->yPos(), currItem->width(), currItem->height(), currItem->lineWidth(), currItem->lineColor(), currItem->fillColor(), true);
bb = Doc->Items->at(z);
bb->setTextFlowMode(currItem->textFlowMode());
bb->setSizeLocked(currItem->sizeLocked());
4021,7 → 4062,7
if (currItem->imageFlippedV())
chma.scale(1, -1);
pts.map(chma);
uint z = Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, currItem->xPos(), currItem->yPos(), currItem->width(), currItem->height(), currItem->lineWidth(), currItem->lineColor(), currItem->fillColor(), !m_canvas->m_viewMode.m_MouseButtonPressed);
uint z = Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, currItem->xPos(), currItem->yPos(), currItem->width(), currItem->height(), currItem->lineWidth(), currItem->lineColor(), currItem->fillColor(), true);
bb = Doc->Items->at(z);
//bb->setTextFlowsAroundFrame(currItem->textFlowsAroundFrame());
//bb->setTextFlowUsesBoundingBox(currItem->textFlowUsesBoundingBox());
4095,7 → 4136,7
}
if (charStyle.baselineOffset() != 0)
st += (charStyle.fontSize() / 10.0) * hl->glyph.scaleV * (charStyle.baselineOffset() / 1000.0);
uint z = Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, currItem->xPos(), currItem->yPos(), currItem->width(), currItem->height(), currItem->lineWidth(), currItem->lineColor(), currItem->fillColor(), !m_canvas->m_viewMode.m_MouseButtonPressed);
uint z = Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, currItem->xPos(), currItem->yPos(), currItem->width(), currItem->height(), currItem->lineWidth(), currItem->lineColor(), currItem->fillColor(), true);
bb = Doc->Items->at(z);
bb->setTextFlowMode(currItem->textFlowMode());
bb->setSizeLocked(currItem->sizeLocked());
4139,7 → 4180,7
}
if ((currItem->asPathText()) && (currItem->PoShow))
{
uint z = Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, currItem->xPos(), currItem->yPos(), currItem->width(), currItem->height(), currItem->lineWidth(), CommonStrings::None, currItem->lineColor(), !m_canvas->m_viewMode.m_MouseButtonPressed);
uint z = Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, currItem->xPos(), currItem->yPos(), currItem->width(), currItem->height(), currItem->lineWidth(), CommonStrings::None, currItem->lineColor(), true);
PageItem *bb = Doc->Items->at(z);
bb->PoLine = currItem->PoLine.copy();
bb->ClipEdited = true;
4176,7 → 4217,7
Doc->itemSelection_DeleteItem(&tmpSelection);
}
Doc->m_Selection->copy(tmpSelection, false, true);
undoManager->commit();
trans.commit();
}
#endif
}
/trunk/Scribus/scribus/scribus.cpp
1283,8 → 1283,10
}
else
view->Deselect(false);
view->cancelGroupTransaction();
break;
case modeEdit:
view->cancelGroupTransaction();
break;
case modeLinkFrames:
case modeUnlinkFrames:
1905,7 → 1907,7
for (int i = 0; i < docSelectionCount; ++i)
doc->m_Selection->itemAt(i)->checkChanges(true);
if (docSelectionCount > 1 && view->groupTransactionStarted())
undoManager->commit();
view->endGroupTransaction();
}
break;
}
3475,7 → 3477,7
{
if (HaveDoc)
{
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create,"",Um::ICreate);
UndoTransaction pasteAction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create,"",Um::ICreate));
QFileInfo fi(data);
if (fi.suffix().toLower() == "sml")
{
3516,7 → 3518,7
AddBookMark(currItem);
}
doc->m_Selection->copy(tmpSelection, false, false);
undoManager->commit();
pasteAction.commit();
slotDocCh(false);
doc->regionsChanged()->update(QRectF());
}
4734,6 → 4736,7
uint docSelectionCount=doc->m_Selection->count();
if ((HaveDoc) && (docSelectionCount != 0))
{
UndoTransaction* activeTransaction = NULL;
PageItem *currItem;
for (uint i = 0; i < docSelectionCount; ++i)
{
4747,11 → 4750,11
if (UndoManager::undoEnabled())
{
if (docSelectionCount > 1)
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Cut,"",Um::ICut);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Cut,"",Um::ICut));
else
{
PageItem* item=doc->m_Selection->itemAt(0);
undoManager->beginTransaction(item->getUName(), item->getUPixmap(), Um::Cut, "", Um::ICut);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(item->getUName(), item->getUPixmap(), Um::Cut, "", Um::ICut));
}
}
Buffer2 = "<SCRIBUSTEXT>";
4869,8 → 4872,12
ClipB->setText(BufferI);
scrActions["editPaste"]->setEnabled(true);
scrMenuMgr->setMenuEnabled("EditPasteRecent", scrapbookPalette->tempBView->objectMap.count() != 0);
if (UndoManager::undoEnabled())
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
}
}
 
5005,10 → 5012,11
view->requestMode(submodeEndNodeEdit);
if (HaveDoc)
{
UndoTransaction* activeTransaction = NULL;
if (Buffer2.isNull())
return;
if (UndoManager::undoEnabled())
undoManager->beginTransaction(doc->currentPage()->getUName(), 0, Um::Paste, "", Um::IPaste);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(doc->currentPage()->getUName(), 0, Um::Paste, "", Um::IPaste));
if (doc->appMode == modeEdit && doc->m_Selection->itemAt(0))
{
PageItem_TextFrame *currItem = dynamic_cast<PageItem_TextFrame*>(doc->m_Selection->itemAt(0));
5134,7 → 5142,6
doc->SnapGuides = false;
// HACK #6541 : undo does not handle text modification => do not record embedded item creation
// if embedded item is deleted, undo system will not be aware of its deletion => crash - JG
bool undoEnabled = undoManager->undoEnabled();
undoManager->setUndoEnabled(false);
 
if (hasXMLRootElem(Buffer2, "<SCRIBUSELEM"))
5194,7 → 5201,7
outlinePalette->BuildTree();
currItem->itemText.insertObject(currItem->CPos, currItem3);
currItem->CPos += 1;
undoManager->setUndoEnabled(undoEnabled);
undoManager->setUndoEnabled(true);
}
else
{
5267,8 → 5274,12
}
view->DrawNew();
}
if (UndoManager::undoEnabled())
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
slotDocCh(false);
}
}
5488,9 → 5499,10
 
void ScribusMainWindow::addNewPages(int wo, int where, int numPages, double height, double width, int orient, QString siz, bool mov, QStringList* basedOn)
{
UndoTransaction* activeTransaction = NULL;
if (UndoManager::undoEnabled())
{
undoManager->beginTransaction(doc->getUName(), Um::IDocument, (numPages == 1) ? Um::AddPage : Um::AddPages, "", Um::ICreate);
activeTransaction = new UndoTransaction(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);
5575,8 → 5587,12
 
undoManager->setUndoEnabled(true);
 
if (UndoManager::undoEnabled())
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
}
 
void ScribusMainWindow::slotNewMasterPage(int w, const QString& name)
6683,6 → 6699,7
 
void ScribusMainWindow::DeletePage(int from, int to)
{
UndoTransaction* activeTransaction = NULL;
assert( from > 0 );
assert( from <= to );
assert( to <= static_cast<int>(doc->Pages->count()) );
6689,9 → 6706,9
int oldPg = doc->currentPageNumber();
guidePalette->setDoc(NULL);
if (UndoManager::undoEnabled())
undoManager->beginTransaction(doc->DocName, Um::IDocument,
(from - to == 0) ? Um::DeletePage : Um::DeletePages, "",
Um::IDelete);
activeTransaction = new UndoTransaction(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);
6757,8 → 6774,12
doc->rebuildMasterNames();
pagePalette->rebuildPages();
pagePalette->rebuildMasters();
if (UndoManager::undoEnabled())
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
}
 
void ScribusMainWindow::MovePage()
9565,7 → 9586,7
doc->setPatterns(dia->dialogPatterns);
propertiesPalette->updateColorList();
view->DrawNew();
undoManager->setUndoEnabled(true);
// undoManager->setUndoEnabled(true);
}
delete dia;
undoManager->setUndoEnabled(true);
/trunk/Scribus/scribus/canvasgesture_resize.h
36,6 → 36,7
class QPainter;
class QRubberBand;
class PageItem;
class UndoTransaction;
 
/**
This class realizes resizing of selected items on behalf of its parent mode.
76,7 → 77,7
double m_origRatio;
QRectF m_bounds;
QRectF m_origBounds;
bool m_transactionStarted;
UndoTransaction* m_transactionStarted;
};
 
 
/trunk/Scribus/scribus/undomanager.cpp
25,21 → 25,42
***************************************************************************/
 
#include "undomanager.h"
#include "undogui.h"
#include "scconfig.h"
#include "prefsmanager.h"
 
#include <QDebug>
#include <QList>
#include <QPixmap>
 
#include "prefscontext.h"
#include "prefsfile.h"
#include "prefsmanager.h"
#include "scconfig.h"
#include "scpaths.h"
#include "scraction.h"
#include "scribuscore.h"
#include "undogui.h"
#include "undostack.h"
#include <QList>
//Added by qt3to4:
#include <QPixmap>
 
#include "scpaths.h"
#include "util_icon.h"
 
 
/**************************************************************************************/
 
/**
This struct is use instead of std::pair<TransactionObject*, TransactionState*> now.
Just data, no methods.
*/
struct TransactionData : public Transaction::TransactionStateBase
{
int stackLevel;
UndoManager* UM;
UndoObject* transactionObject; // will be DummyUndoObject
TransactionState* transactionState;
};
 
 
/**************************************************************************************/
 
 
 
UndoManager* UndoManager::instance_ = 0;
bool UndoManager::undoEnabled_ = true;
int UndoManager::undoEnabledCounter_ = 0;
80,109 → 101,177
if (!UndoManager::IGuides)
initIcons();
prefs_ = PrefsManager::instance()->prefsFile->getContext("undo");
transaction_= 0;
transactionTarget_ = 0;
languageChange();
setUndoEnabled(prefs_->getBool("enabled", true));
}
 
void UndoManager::beginTransaction(const QString &targetName,
QPixmap *targetPixmap,
const QString &name,
const QString &description,
QPixmap *actionPixmap)
 
 
UndoTransaction UndoManager::beginTransaction(const QString &targetName,
QPixmap *targetPixmap,
const QString &name,
const QString &description,
QPixmap *actionPixmap)
{
if (!undoEnabled_)
return;
if (transaction_) // begin a transaction_inside transaction
transactions_.push_back(
std::pair<TransactionObject*, TransactionState*>(transactionTarget_, transaction_));
transaction_= new TransactionState();
transactionTarget_ = new TransactionObject();
return UndoTransaction(NULL);
/** @brief Dummy object for storing transaction target's name */
UndoObject* transactionTarget_ = new DummyUndoObject();
TransactionState* transactionState_ = new TransactionState();
transactionTarget_->setUName(targetName); // Name which will be in action history
if (targetPixmap)
transactionTarget_->setUPixmap(targetPixmap);
if (name.length() > 0) // if left to 0 length action will be fetched from the
transaction_->setName(name); // last added UndoState in this transaction
transactionState_->setName(name); // last added UndoState in this transaction
if (description.length() > 0)
transaction_->setDescription(description); // tool tip for action history
transactionState_->setDescription(description); // tool tip for action history
if (actionPixmap)
transaction_->setPixmap(actionPixmap); // for action history
transactionState_->setPixmap(actionPixmap); // for action history
 
// Holds the state and data of this transaction:
TransactionData *transaction = new TransactionData();
transaction->transactionObject = transactionTarget_;
transaction->transactionState = transactionState_;
transaction->stackLevel = transactions_.size();
transaction->UM = this;
transactions_.push_back(transaction);
// qDebug() << "UndoManager::beginTransaction" << targetName << name << transaction;
return UndoTransaction(transaction);
}
 
void UndoManager::cancelTransaction()
UndoTransaction::UndoTransaction(TransactionData* data) : Transaction(data)
{};
 
UndoTransaction::~UndoTransaction()
{
delete transaction_;
transaction_= 0;
delete transactionTarget_;
transactionTarget_ = 0;
if (!transactions_.empty())
if (m_data)
{
// fetch the next transaction_from the vector
transactionTarget_ = transactions_[transactions_.size() - 1].first;
transaction_= transactions_[transactions_.size() - 1].second;
// delete transactions_[transactions_.size() - 1];
transactions_.erase(transactions_.end() - 1);
UndoTransaction::cancel(); // no virtual calls in destructor
delete m_data;
m_data = 0;
}
}
 
void UndoManager::commit(const QString &targetName,
QPixmap *targetPixmap,
const QString &name,
const QString &description,
QPixmap *actionPixmap)
bool UndoTransaction::cancel()
{
if (!transaction_ || !transactionTarget_ || !undoEnabled_)
if (!m_data)
return false;
TransactionData* data = static_cast<TransactionData*>(m_data);
UndoManager* UM = data->UM;
int stackLevel = data->stackLevel;
 
switch (m_data->m_status)
{
cancelTransaction();
return;
case Transaction::STATE_OPEN:
case Transaction::STATE_WILLFAIL:
// qDebug() << "UndoManager::cancelTransaction" << data << data->transactionObject->getUName() << data->transactionState->getName() << stackLevel;
data->m_status = Transaction::STATE_FAILED;
delete data->transactionObject;
data->transactionObject = 0;
delete data->transactionState;
data->transactionState = 0;
//brutal for now:
assert (stackLevel + 1 == signed(UM->transactions_.size()));
if (stackLevel < signed(UM->transactions_.size()))
{
UM->transactions_.erase(UM->transactions_.begin() + stackLevel);
}
return true;
default:
// do nothing;
// qDebug() << "UndoManager::cancelTransaction ** already closed **";
return false;
}
if (targetName.length() > 0)
transactionTarget_->setUName(targetName);
if (targetPixmap)
transactionTarget_->setUPixmap(targetPixmap);
if (name.length() > 0)
transaction_->setName(name);
if (description.length() > 0)
transaction_->setDescription(description);
if (actionPixmap)
transaction_->setPixmap(actionPixmap);
}
 
UndoObject *tmpu = transactionTarget_;
TransactionState *tmps = transaction_;
bool UndoTransaction::commit(const QString &targetName,
QPixmap *targetPixmap,
const QString &name,
const QString &description,
QPixmap *actionPixmap)
{
if (m_data && m_data->m_status == Transaction::STATE_OPEN)
{
TransactionData* data = static_cast<TransactionData*>(m_data);
if (targetName.length() > 0)
data->transactionObject->setUName(targetName);
if (targetPixmap)
data->transactionObject->setUPixmap(targetPixmap);
if (name.length() > 0)
data->transactionState->setName(name);
if (description.length() > 0)
data->transactionState->setDescription(description);
if (actionPixmap)
data->transactionState->setPixmap(actionPixmap);
}
return commit();
}
bool UndoTransaction::commit()
{
if (!m_data)
return false;
TransactionData* data = static_cast<TransactionData*>(m_data);
UndoManager* UM = data->UM;
int stackLevel = data->stackLevel;
 
if (!transactions_.empty())
if (!UM->undoEnabled_)
{
// fetch the next transaction_to be an active transaction
transactionTarget_ = transactions_[transactions_.size() - 1].first;
transaction_= transactions_[transactions_.size() - 1].second;
// delete transactions_[transactions_.size() - 1]
transactions_.erase(transactions_.end() - 1);
cancel();
return false;
}
else
UndoObject *tmpu = UM->transactions_.at(stackLevel)->transactionObject;
TransactionState *tmps = UM->transactions_.at(stackLevel)->transactionState;
switch (m_data->m_status)
{
transaction_ = 0;
transactionTarget_ = 0;
}
case Transaction::STATE_OPEN:
// qDebug() << "UndoManager::commitTransaction" << data << data->transactionObject->getUName() << data->transactionState->getName() << stackLevel;
m_data->m_status = Transaction::STATE_COMMITTED;
 
if (tmps->sizet() > 0) // are there any actions inside the commited transaction
{
if (tmps->getName().isEmpty())
tmps->useActionName();
action(tmpu, tmps);
} // if not just delete objects
else
{
delete tmpu;
tmpu = 0;
delete tmps;
tmps = 0;
// brutal for now:
assert (stackLevel + 1 == signed(UM->transactions_.size()));
if (stackLevel < signed(UM->transactions_.size()))
{
UM->transactions_.erase(UM->transactions_.begin() + stackLevel);
}
if (tmps->sizet() > 0) // are there any actions inside the commited transaction
{
if (tmps->getName().isEmpty())
tmps->useActionName();
UM->action(tmpu, tmps);
} // if not just delete objects
else
{
delete tmpu;
tmpu = 0;
delete tmps;
tmps = 0;
}
return true;
break;
case STATE_WILLFAIL:
return cancel();
break;
default:
// qDebug() << "UndoManager::commitTransaction ** already closed **";
// nothing
break;
}
return false;
}
 
bool UndoManager::isTransactionMode()
{
return transaction_ ? true : false;
return transactions_.size() > 0;
}
 
void UndoManager::registerGui(UndoGui* gui)
394,16 → 483,24
return;
}
 
if ((!transaction_) &&
if (!isTransactionMode() &&
(currentUndoObjectId_ == -1 || currentUndoObjectId_ == static_cast<long>(target->getUId())))
{
// qDebug() << "UndoManager: new Action" << state->getName() << "for" << currentUndoObjectId_;
emit newAction(target, state); // send action to the guis
}
else
{
emit clearRedo();
 
if (transaction_)
transaction_->pushBack(target, state);
}
if (isTransactionMode())
{
// qDebug() << "UndoManager: Action stored for transaction:" << transactions_.back() << target->getUName() << state->getName();
transactions_.back()->transactionState->pushBack(target, state);
}
else
{
// qDebug() << "UndoManager: Action executed:" << target->getUName() << state->getName();
state->setUndoObject(target);
stacks_[currentDoc_].action(state);
}
481,6 → 578,9
UndoObject* UndoManager::replaceObject(ulong uid, UndoObject *newUndoObject)
{
UndoObject *tmp = 0;
TransactionState* transaction_ = NULL;
if (transactions_.size() > 0)
transaction_ = transactions_.at(transactions_.size()-1)->transactionState;
for (uint i = 0; i < stacks_[currentDoc_].undoActions_.size(); ++i)
{
UndoState *tmpState = stacks_[currentDoc_].undoActions_[i];
/trunk/Scribus/scribus/canvasmode_create.h
26,8 → 26,8
class ResizeGesture;
class ScribusMainWindow;
class ScribusView;
class UndoTransaction;
 
 
/**
Handles the creation of new pageitems
*/
67,6 → 67,7
double SeRx, SeRy;
bool MoveGX, MoveGY;
FPointArray RecordP;
UndoTransaction* m_createTransaction;
ResizeGesture* resizeGesture;
LineMove* lineMoveGesture;
};
/trunk/Scribus/scribus/canvasmode_drawfreehand.cpp
322,6 → 322,7
{
if (RecordP.size() > 1)
{
UndoTransaction createTransaction(UndoManager::instance()->beginTransaction());
uint z = m_doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, Mxp, Myp, 1, 1, m_doc->toolSettings.dWidth, CommonStrings::None, m_doc->toolSettings.dPenLine, true);
currItem = m_doc->Items->at(z);
currItem->PoLine.resize(0);
361,7 → 362,14
currItem->ClipEdited = true;
currItem->FrameType = 3;
currItem->OwnPage = m_doc->OnPage(currItem);
//FIXME
m_view->resetMousePressed();
currItem->checkChanges();
QString targetName = Um::ScratchSpace;
if (currItem->OwnPage > -1)
targetName = m_doc->Pages->at(currItem->OwnPage)->getUName();
createTransaction.commit(targetName, currItem->getUPixmap(),
Um::Create + " " + currItem->getUName(), "", Um::ICreate);
//FIXME
m_canvas->m_viewMode.operItemResizing = false;
inItemCreation = false;
m_doc->changed();
379,6 → 387,7
}
assert(false);
if (m_doc->appMode != modeDrawBezierLine) //FIXME: that should be dead - av
{
if (inItemCreation)
546,7 → 555,6
qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
}
}
if (m_view->moveTimerElapsed() && (GetItem(&currItem)))
{
m_canvas->setRenderModeUseBuffer(false);
577,10 → 585,11
m_doc->SizeItem(npx.x(), npx.y(), currItem->ItemNr);
bool sav = m_doc->SnapGuides;
m_doc->SnapGuides = false;
UndoTransaction* activeTransaction = NULL;
if (UndoManager::undoEnabled())
{
m_view->undoManager->beginTransaction(currItem->getUName(), currItem->getUPixmap(),
Um::Resize, QString(Um::ResizeFromTo).arg(currItem->width()).arg(currItem->height()).arg(currItem->width() - npx.x()).arg(currItem->height() - npx.y()), Um::IResize);
activeTransaction = new UndoTransaction(m_view->undoManager->beginTransaction(currItem->getUName(), currItem->getUPixmap(),
Um::Resize, QString(Um::ResizeFromTo).arg(currItem->width()).arg(currItem->height()).arg(currItem->width() - npx.x()).arg(currItem->height() - npx.y()), Um::IResize));
}
// m_canvas->m_viewMode.operItemResizing = false;
switch (frameResizeHandle)
826,8 → 835,12
m_view->updateCanvas();
// emit DocChanged();
currItem->checkChanges();
if (UndoManager::undoEnabled())
m_view->undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
}
m_doc->setRedrawBounding(currItem);
currItem->OwnPage = m_doc->OnPage(currItem);
/trunk/Scribus/scribus/canvasmode_create.cpp
70,6 → 70,7
frameResizeHandle = -1;
RotMode = 0;
inItemCreation = false;
m_createTransaction = NULL;
shiftSelItems = false;
FirstPoly = true;
resizeGesture = NULL;
114,7 → 115,7
{
PageItem* currItem;
qDebug() << "CreateMode::activate" << fromGesture;
if (fromGesture && GetItem(&currItem))
if (fromGesture && GetItem(&currItem) && m_createTransaction)
{
double itemX = fabs(currItem->width());
double itemY = fabs(currItem->height());
186,9 → 187,22
currItem->OldB2 = currItem->width();
currItem->OldH2 = currItem->height();
currItem->Sizing = false;
m_view->resetMousePressed();
currItem->checkChanges();
QString targetName = Um::ScratchSpace;
if (currItem->OwnPage > -1)
targetName = m_doc->Pages->at(currItem->OwnPage)->getUName();
m_createTransaction->commit(targetName, currItem->getUPixmap(),
Um::Create + " " + currItem->getUName(), "", Um::ICreate);
m_doc->SnapGuides = oldSnap;
currItem->update();
}
else
{
m_createTransaction->cancel();
}
delete m_createTransaction;
m_createTransaction = NULL;
inItemCreation = false;
}
else
197,8 → 211,8
m_doc->AdjustItemSize(currItem);
else
{
currItem->OldB2 = currItem->width();
currItem->OldH2 = currItem->height();
// currItem->OldB2 = currItem->width();
// currItem->OldH2 = currItem->height();
currItem->updateClip();
}
currItem->ContourLine = currItem->PoLine.copy();
205,6 → 219,15
m_doc->setRedrawBounding(currItem);
currItem->OwnPage = m_doc->OnPage(currItem);
currItem->Sizing = false;
m_view->resetMousePressed();
currItem->checkChanges();
QString targetName = Um::ScratchSpace;
if (currItem->OwnPage > -1)
targetName = m_doc->Pages->at(currItem->OwnPage)->getUName();
m_createTransaction->commit(targetName, currItem->getUPixmap(),
Um::Create + " " + currItem->getUName(), "", Um::ICreate);
delete m_createTransaction;
m_createTransaction = NULL;
currItem->update();
inItemCreation = false;
}
218,6 → 241,13
}
else
{
if (m_createTransaction)
{
qDebug() << "canceling left over create Transaction";
m_createTransaction->cancel();
delete m_createTransaction;
m_createTransaction = NULL;
}
GxM = GyM = -1;
Mxp = Myp = -1;
Dxp = Dyp = -1;
232,10 → 262,20
setModeCursor();
}
 
void CreateMode::deactivate(bool flag)
void CreateMode::deactivate(bool forGesture)
{
qDebug() << "CreateMode::deactivate" << flag;
qDebug() << "CreateMode::deactivate" << forGesture;
m_view->redrawMarker->hide();
if (!forGesture)
{
if (m_createTransaction)
{
qDebug() << "CreateMode::deactivate: canceling left over create Transaction";
m_createTransaction->cancel();
delete m_createTransaction;
m_createTransaction = NULL;
}
}
}
 
void CreateMode::mouseDoubleClickEvent(QMouseEvent *m)
392,6 → 432,7
m_view->DrawNew();
return;
}
m_createTransaction = new UndoTransaction(Um::instance()->beginTransaction("creating"));
switch (m_doc->appMode)
{
case modeDrawShapes:
403,7 → 444,7
case 0:
if (m->modifiers() == Qt::ShiftModifier)
{
z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Rectangle, Rxp, Ryp, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, !m_MouseButtonPressed);
z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Rectangle, Rxp, Ryp, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
m_doc->Items->at(z)->FrameType = 0;
SetupDrawNoResize(z);
}
410,7 → 451,7
else
{
m_doc->ApplyGuides(&Rxp, &Ryp);
z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, !m_MouseButtonPressed);
z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
m_doc->Items->at(z)->FrameType = 0;
SetupDraw(z);
}
418,7 → 459,7
case 1:
if (m->modifiers() == Qt::ShiftModifier)
{
z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Ellipse, Rxp, Ryp, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, !m_MouseButtonPressed);
z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Ellipse, Rxp, Ryp, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
m_doc->Items->at(z)->FrameType = 1;
SetupDrawNoResize(z);
}
425,7 → 466,7
else
{
m_doc->ApplyGuides(&Rxp, &Ryp);
z = m_doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, !m_MouseButtonPressed);
z = m_doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
m_doc->Items->at(z)->FrameType = 1;
SetupDraw(z);
}
433,7 → 474,7
default:
if (m->modifiers() == Qt::ShiftModifier)
{
z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, !m_MouseButtonPressed);
z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
m_doc->Items->at(z)->SetFrameShape(m_doc->ValCount, m_doc->ShapeValues);
m_doc->setRedrawBounding(m_doc->Items->at(z));
m_doc->Items->at(z)->FrameType = m_doc->SubMode+2;
442,7 → 483,7
else
{
m_doc->ApplyGuides(&Rxp, &Ryp);
z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, !m_MouseButtonPressed);
z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
m_doc->Items->at(z)->SetFrameShape(m_doc->ValCount, m_doc->ShapeValues);
m_doc->setRedrawBounding(m_doc->Items->at(z));
m_doc->Items->at(z)->FrameType = m_doc->SubMode+2;
456,7 → 497,7
break;
selectPage(m);
m_doc->ApplyGuides(&Rxp, &Ryp);
z = m_doc->itemAdd(PageItem::Line, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1, m_doc->toolSettings.dWidthLine, CommonStrings::None, m_doc->toolSettings.dPenLine, !m_MouseButtonPressed);
z = m_doc->itemAdd(PageItem::Line, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1, m_doc->toolSettings.dWidthLine, CommonStrings::None, m_doc->toolSettings.dPenLine, true);
SetupDraw(z);
break;
case modeDrawLatex:
465,13 → 506,13
selectPage(m);
if (m->modifiers() == Qt::ShiftModifier)
{
z = m_doc->itemAddArea(PageItem::LatexFrame, PageItem::Unspecified, Rxp, Ryp, 1, m_doc->toolSettings.dBrushPict, CommonStrings::None, !m_MouseButtonPressed);
z = m_doc->itemAddArea(PageItem::LatexFrame, PageItem::Unspecified, Rxp, Ryp, 1, m_doc->toolSettings.dBrushPict, CommonStrings::None, true);
SetupDrawNoResize(z);
}
else
{
m_doc->ApplyGuides(&Rxp, &Ryp);
z = m_doc->itemAdd(PageItem::LatexFrame, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, 1, m_doc->toolSettings.dBrushPict, CommonStrings::None, !m_MouseButtonPressed);
z = m_doc->itemAdd(PageItem::LatexFrame, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, 1, m_doc->toolSettings.dBrushPict, CommonStrings::None, true);
SetupDraw(z);
}
break;
481,13 → 522,13
selectPage(m);
if (m->modifiers() == Qt::ShiftModifier)
{
z = m_doc->itemAddArea(PageItem::ImageFrame, PageItem::Unspecified, Rxp, Ryp, 1, m_doc->toolSettings.dBrushPict, CommonStrings::None, !m_MouseButtonPressed);
z = m_doc->itemAddArea(PageItem::ImageFrame, PageItem::Unspecified, Rxp, Ryp, 1, m_doc->toolSettings.dBrushPict, CommonStrings::None, true);
SetupDrawNoResize(z);
}
else
{
m_doc->ApplyGuides(&Rxp, &Ryp);
z = m_doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, 1, m_doc->toolSettings.dBrushPict, CommonStrings::None, !m_MouseButtonPressed);
z = m_doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, 1, m_doc->toolSettings.dBrushPict, CommonStrings::None, true);
SetupDraw(z);
}
break;
497,13 → 538,13
selectPage(m);
if (m->modifiers() == Qt::ShiftModifier)
{
z = m_doc->itemAddArea(PageItem::TextFrame, PageItem::Unspecified, Rxp, Ryp, m_doc->toolSettings.dWidth, CommonStrings::None, m_doc->toolSettings.dPenText, !m_MouseButtonPressed);
z = m_doc->itemAddArea(PageItem::TextFrame, PageItem::Unspecified, Rxp, Ryp, m_doc->toolSettings.dWidth, CommonStrings::None, m_doc->toolSettings.dPenText, true);
SetupDrawNoResize(z);
}
else
{
m_doc->ApplyGuides(&Rxp, &Ryp);
z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, CommonStrings::None, m_doc->toolSettings.dPenText, !m_MouseButtonPressed);
z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, CommonStrings::None, m_doc->toolSettings.dPenText, true);
SetupDraw(z);
}
break;
513,11 → 554,11
break;
selectPage(m);
if (m->modifiers() == Qt::ShiftModifier)
z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, !m_MouseButtonPressed);
z = m_doc->itemAddArea(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
else
{
m_doc->ApplyGuides(&Rxp, &Ryp);
z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, !m_MouseButtonPressed);
z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, m_doc->toolSettings.dBrush, m_doc->toolSettings.dPen, true);
}
currItem = m_doc->Items->at(z);
FPointArray cli = RegularPolygonF(currItem->width(), currItem->height(), m_doc->toolSettings.polyC, m_doc->toolSettings.polyS, m_doc->toolSettings.polyF, m_doc->toolSettings.polyR);
573,7 → 614,7
break;
selectPage(m);
m_doc->ApplyGuides(&Rxp, &Ryp);
z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, CommonStrings::None, m_doc->toolSettings.dPenText, !m_MouseButtonPressed);
z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, CommonStrings::None, m_doc->toolSettings.dPenText, true);
currItem = m_doc->Items->at(z);
currItem->setIsAnnotation(true);
currItem->AutoName = false;
795,6 → 836,7
{
if ((m_doc->m_Selection->count() == 0) && (m_view->HaveSelRect) && (!m_view->MidButt))
{
UndoTransaction * activeTransaction = NULL;
m_view->HaveSelRect = false;
double Tx, Ty, Tw, Th;
FPoint np2 = m_doc->ApplyGridF(FPoint(Mxp, Myp));
838,15 → 880,15
offY = 0.0;
m_doc->m_Selection->clear();
if (UndoManager::undoEnabled())
m_view->undoManager->beginTransaction(m_doc->currentPage()->getUName(),
Um::ITable, Um::CreateTable,
QString(Um::RowsCols).arg(Rows).arg(Cols),
Um::ICreate);
activeTransaction = new UndoTransaction(m_view->undoManager->beginTransaction(m_doc->currentPage()->getUName(),
Um::ITable, Um::CreateTable,
QString(Um::RowsCols).arg(Rows).arg(Cols),
Um::ICreate));
for (int rc = 0; rc < Rows; ++rc)
{
for (int cc = 0; cc < Cols; ++cc)
{
z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, Tx + offX, Ty + offY, deltaX, deltaY, m_doc->toolSettings.dWidth, CommonStrings::None, m_doc->toolSettings.dPenText, !m_MouseButtonPressed);
z = m_doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, Tx + offX, Ty + offY, deltaX, deltaY, m_doc->toolSettings.dWidth, CommonStrings::None, m_doc->toolSettings.dPenText, true);
currItem = m_doc->Items->at(z);
currItem->isTableItem = true;
currItem->setTextFlowMode(PageItem::TextFlowUsesBoundingBox);
880,11 → 922,38
}
}
m_doc->itemSelection_GroupObjects(false, false);
if (UndoManager::undoEnabled())
m_view->undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
}
} // if (modeDrawTable)
}
if (m_createTransaction)
{
// from former ScribusDoc::itemAddCommit():
PageItem *createdItem=m_doc->m_Selection->itemAt(0);
if (createdItem != NULL)
{
m_view->resetMousePressed();
createdItem->checkChanges(true);
QString targetName = Um::ScratchSpace;
if (createdItem->OwnPage > -1)
targetName = m_doc->Pages->at(createdItem->OwnPage)->getUName();
m_createTransaction->commit(targetName, createdItem->getUPixmap(),
Um::Create + " " + createdItem->getUName(), "", Um::ICreate);
}
else
{
qDebug() << "create mode::release: lost created item/selection";
m_createTransaction->cancel();
}
delete m_createTransaction;
m_createTransaction = NULL;
}
if (!PrefsManager::instance()->appPrefs.stickyTools)
{
m_view->requestMode(modeNormal);
/trunk/Scribus/scribus/undomanager.h
30,10 → 30,10
#include <vector>
#include <utility>
#include <QObject>
//Added by qt3to4:
#include <QPixmap>
 
#include "scribusapi.h"
#include "transaction.h"
#include "undostate.h"
#include "undoobject.h"
#include "undostack.h"
41,6 → 41,7
class QString;
class QPixmap;
class UndoGui;
class TransactionData;
class PrefsContext;
 
/** @brief Key is the doc name, value is it's undo stack */
59,6 → 60,7
TransactionState();
/** @brief Destroys the TransactionState instance */
~TransactionState();
/**
* @brief Add a new <code>UndoState</code> object to the transaction.
* @param state state to be added to the transaction
116,7 → 118,27
std::vector<UndoState*> states_;
};
 
 
 
/**
Class which handles Undo transactions. No data, just methods.
*/
class UndoTransaction : public Transaction
{
public:
UndoTransaction(TransactionData* data);
virtual ~UndoTransaction();
virtual bool commit();
virtual bool cancel();
bool commit(const QString &targetName,
QPixmap *targetPixmap,
const QString &name = "",
const QString &description = "",
QPixmap *actionPixmap = 0);
};
 
 
/**
* @brief UndoManager handles the undo stack.
*
* UndoManager is the engine of the undo/redo handling. When ever an undoable
137,6 → 159,8
{
Q_OBJECT
public:
friend class UndoTransaction;
/** @brief Marks for a global undo mode where ever UndoOjbect id is requested. */
static const int GLOBAL_UNDO_MODE = -1;
188,21 → 212,25
* window and icon for the action will be drawn over this one.
* @param name name for the transaction (f.e. "Move" would make with the above
* "Move Selection")
* The result can only be used for initializing a Transaction object, eg. on the stack:
* Transaction groupTransaction(undoManger->beginTransaction(...));
* or the heap:
* Transaction* groupTransactionPtr = new Transaction(undoManger->beginTransaction(...));
* @param description description for the transaction
* @param actionPixmap icon for the action performed by the transaction
* @sa commit()
*/
void beginTransaction(const QString &targetName = "",
QPixmap *targetPixmap = 0,
const QString &actionName = "",
const QString &description = "",
QPixmap *actionPixmap = 0);
UndoTransaction beginTransaction(const QString &targetName = "",
QPixmap *targetPixmap = 0,
const QString &actionName = "",
const QString &description = "",
QPixmap *actionPixmap = 0);
/**
* @brief Cancels the current transaction and deletes groupped <code>UndoState</code>s.
* @brief Nothing from canceled transaction will be sent to the undo gui widgets.
*/
void cancelTransaction();
//void cancelTransaction();
/**
* @brief Commit the current transaction.
220,11 → 248,11
* @param actionPixmap icon for the action performed by the transaction
* @sa beginTransaction()
*/
void commit(const QString &targetName = "",
QPixmap *targetPixmap = 0,
const QString &name = "",
const QString &description = "",
QPixmap *actionPixmap = 0);
// void commit(const QString &targetName = "",
// QPixmap *targetPixmap = 0,
// const QString &name = "",
// const QString &description = "",
// QPixmap *actionPixmap = 0);
/**
* @brief Returns true if in transaction mode if not will return false.
311,26 → 339,7
bool isGlobalMode();
 
private:
 
/*** UndoManager::TransactionObject ***************************************************/
 
/**
* @brief Dummy subclass of <code>UndoObject</code> which is used for holding the name
* @brief for the transaction's target object(group) (f.e "Selection", "Group", "Script"...).
* @author Riku Leino tsoots@gmail.com
* @date January 2005
*/
class TransactionObject : public UndoObject
{
public:
TransactionObject() {};
virtual ~TransactionObject() {};
void restore(UndoState*, bool) {};
};
 
/**************************************************************************************/
 
/**
* @brief The only instance of UndoManager available.
*
* UndoManager is singleton and the instance can be queried with the method
367,21 → 376,9
* @brief Stores the transactions which are currently started but not
* @brief canceled or commited.
*/
std::vector<std::pair<TransactionObject*, TransactionState*> > transactions_;
std::vector<TransactionData*> transactions_;
 
/**
* @brief If in transaction mode this is the container for incoming <code>UndoState</code>
* @brief objects.
*
* It is also used to detect if we are in the transaction mode. When it is <code>NULL</code>
* normal mode is on.
*/
TransactionState *transaction_;
 
/** @brief Dummy object for storing transaction target's name */
TransactionObject *transactionTarget_;
 
/**
* @brief UndoGuis attached to this UndoManager
* @sa UndoGui
* @sa UndoWidget
/trunk/Scribus/scribus/scribusdoc.cpp
207,7 → 207,7
// sections
symReturn(), symNewLine(), symTab(), symNonBreak(), symNewCol(), symNewFrame(),
docHyphenator(0),
_itemCreationTransactionStarted(false),
m_itemCreationTransaction(NULL),
m_updateManager()
{
init();
314,7 → 314,7
// sections
symReturn(), symNewLine(), symTab(), symNonBreak(), symNewCol(), symNewFrame(),
docHyphenator(0),
_itemCreationTransactionStarted(false),
m_itemCreationTransaction(NULL),
m_updateManager()
{
pageSets[pagesSetup.pageArrangement].FirstPage = pagesSetup.firstPageLocation;
1872,9 → 1872,9
return false;
int layerLevel = lToRemove->Level;
QString name = lToRemove->Name;
 
UndoTransaction* activeTransaction = NULL;
if (UndoManager::undoEnabled())
undoManager->beginTransaction("Layer", Um::IDocument, Um::DeleteLayer, "", Um::IDelete);
activeTransaction = new UndoTransaction(undoManager->beginTransaction("Layer", Um::IDocument, Um::DeleteLayer, "", Um::IDelete));
 
rebuildItemLists();
if (ScCore->usingGUI())
1925,7 → 1925,7
//Now delete the layer
Layers.removeLayerByNumber(layerNumber);
 
if (UndoManager::undoEnabled())
if (activeTransaction)
{
SimpleState *ss = new SimpleState(Um::DeleteLayer, "", Um::IDelete);
ss->set("REMOVE_LAYER", "remove_layer");
1935,7 → 1935,9
ss->set("LAYER_NR", layerNumber);
ss->set("DELETE", deleteItems);
undoManager->action(this, ss, DocName, Um::ILayer);
undoManager->commit();
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
setActiveLayer(layerNumberFromLevel(0));
return true;
3390,10 → 3392,11
 
int ScribusDoc::itemAdd(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double b, const double h, const double w, const QString& fill, const QString& outline, const bool itemFinalised)
{
if (UndoManager::undoEnabled() && !_itemCreationTransactionStarted)
assert(itemFinalised); // av: caller must wrap transaction around this if wanted
UndoTransaction* activeTransaction = NULL;
if (UndoManager::undoEnabled()) // && !m_itemCreationTransaction)
{
_itemCreationTransactionStarted = true;
undoManager->beginTransaction();
activeTransaction = new UndoTransaction(undoManager->beginTransaction());
}
PageItem* newItem=NULL;
switch( itemType )
3455,12 → 3458,13
target = Pages->at(newItem->OwnPage);
undoManager->action(target, is);
//If the item is created "complete" (ie, not being created by drag/resize, commit to undomanager)
if (itemFinalised)
if (activeTransaction)
{
//dont think we need this now ... newItem->checkChanges(true);
undoManager->commit(Pages->at(newItem->OwnPage)->getUName(), newItem->getUPixmap(),
Um::Create + " " + newItem->getUName(), "", Um::ICreate);
_itemCreationTransactionStarted = false;
activeTransaction->commit(Pages->at(newItem->OwnPage)->getUName(), newItem->getUPixmap(),
Um::Create + " " + newItem->getUName(), "", Um::ICreate);
delete activeTransaction;
activeTransaction = NULL;
}
}
return newItem->ItemNr;
3493,10 → 3497,9
Page* oldCurrentPage = currentPage();
int z=-2;
PageItem *prevItem=0; //Previous item for text frame linking
undoManager->beginTransaction(
iafData.frameType==PageItem::TextFrame ? Um::TextFrame : Um::ImageFrame,
iafData.frameType==PageItem::TextFrame ? Um::ITextFrame : Um::IImageFrame,
Um::InsertFrame, "", Um::ICreate);
UndoTransaction transaction(undoManager->beginTransaction(iafData.frameType==PageItem::TextFrame ? Um::TextFrame : Um::ImageFrame,
iafData.frameType==PageItem::TextFrame ? Um::ITextFrame : Um::IImageFrame,
Um::InsertFrame, "", Um::ICreate));
for (uint i=0;i<pageNs.size();++i)
{
Page* targetPage=Pages->at(pageNs[i]-1);
3601,7 → 3604,7
}
}
 
undoManager->commit();
transaction.commit();
setCurrentPage(oldCurrentPage);
changed();
regionsChanged()->update(QRectF());
3683,7 → 3686,7
bool ScribusDoc::itemAddCommit(const int /*itemNumber*/)
{
//TODO use the parameter
if (_itemCreationTransactionStarted && appMode != modeDrawBezierLine)
if (m_itemCreationTransaction && appMode != modeDrawBezierLine)
{
PageItem *createdItem=m_Selection->itemAt(0);
if (createdItem!=NULL)
3692,9 → 3695,10
QString targetName = Um::ScratchSpace;
if (createdItem->OwnPage > -1)
targetName = Pages->at(createdItem->OwnPage)->getUName();
undoManager->commit(targetName, createdItem->getUPixmap(),
m_itemCreationTransaction->commit(targetName, createdItem->getUPixmap(),
Um::Create + " " + createdItem->getUName(), "", Um::ICreate);
_itemCreationTransactionStarted = false;
delete m_itemCreationTransaction;
m_itemCreationTransaction = NULL;
if (!isLoading())
return true;
}
4266,7 → 4270,7
//Remove old item from the doc's selection if it was in it
bool removedFromSelection=m_Selection->removeItem(oldItem);
//Create a new item from the old one
bool transactionConversion=false;
UndoTransaction* transactionConversion = NULL;
PageItem *newItem;
switch (newType)
{
4277,8 → 4281,7
newItem = new PageItem_TextFrame(*oldItem);
if (UndoManager::undoEnabled() && oldItem->itemType()==PageItem::PathText)
{
undoManager->beginTransaction(currentPage()->getUName(), 0, Um::TextFrame, "", Um::ITextFrame);
transactionConversion=true;
transactionConversion = new UndoTransaction(undoManager->beginTransaction(currentPage()->getUName(), 0, Um::TextFrame, "", Um::ITextFrame));
}
break;
//We dont allow this
4296,8 → 4299,7
return NULL;
if (UndoManager::undoEnabled())
{
undoManager->beginTransaction(currentPage()->getUName(), 0, Um::PathText, "", Um::ITextFrame);
transactionConversion=true;
transactionConversion = new UndoTransaction(undoManager->beginTransaction(currentPage()->getUName(), 0, Um::PathText, "", Um::ITextFrame));
}
newItem = new PageItem_PathText(*oldItem);
break;
4311,7 → 4313,10
if (newItem==NULL)
{
if (transactionConversion)
undoManager->cancelTransaction();
{
transactionConversion->cancel();
delete transactionConversion;
}
return NULL;
}
//Do new item type specific adjustments to the new item. Some of this may move when new
4455,8 → 4460,9
//Close any undo transaction
if (transactionConversion)
{
if (UndoManager::undoEnabled())
undoManager->commit();
transactionConversion->commit();
delete transactionConversion;
transactionConversion = NULL;
}
return newItem;
}
4702,7 → 4708,7
 
void ScribusDoc::copyPage(int pageNumberToCopy, int existingPage, int whereToInsert, int copyCount)
{
undoManager->beginTransaction(getUName(), Um::IDocument, Um::CopyPage, "", Um::ICreate);
UndoTransaction copyTransaction(undoManager->beginTransaction(getUName(), Um::IDocument, Um::CopyPage, "", Um::ICreate));
SimpleState *ss = new SimpleState(Um::Copy, "", Um::ICreate);
ss->set("COPY_PAGE", "copy_page");
ss->set("PAGE_NUM", pageNumberToCopy);
4804,7 → 4810,7
else
setCurrentPage(from);
changed();
undoManager->commit();
copyTransaction.commit();
}
 
 
5059,10 → 5065,11
uint selectedItemCount=m_Selection->count();
if (selectedItemCount != 0)
{
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::LineWidth, "", Um::ILineStyle);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::LineWidth, "", Um::ILineStyle));
for (uint a = 0; a < selectedItemCount; ++a)
{
PageItem *currItem = m_Selection->itemAt(a);
5080,8 → 5087,12
}
currItem->update();
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
}
changed();
5094,17 → 5105,22
uint selectedItemCount=m_Selection->count();
if (selectedItemCount != 0)
{
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::LineStyle, "", Um::ILineStyle);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::LineStyle, "", Um::ILineStyle));
for (uint a = 0; a < selectedItemCount; ++a)
{
m_Selection->itemAt(a)->setLineStyle(w);
m_Selection->itemAt(a)->update();
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
}
changed();
5117,17 → 5133,22
uint selectedItemCount=m_Selection->count();
if (selectedItemCount != 0)
{
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::LineJoin, "", Um::ILineStyle);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::LineJoin, "", Um::ILineStyle));
for (uint a = 0; a < selectedItemCount; ++a)
{
m_Selection->itemAt(a)->setLineJoin(w);
m_Selection->itemAt(a)->update();
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
}
changed();
5140,17 → 5161,22
uint selectedItemCount=m_Selection->count();
if (selectedItemCount != 0)
{
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::LineEnd, "", Um::ILineStyle);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::LineEnd, "", Um::ILineStyle));
for (uint a = 0; a < selectedItemCount; ++a)
{
m_Selection->itemAt(a)->setLineEnd(w);
m_Selection->itemAt(a)->update();
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
}
changed();
5197,9 → 5223,10
uint docSelectionCount = itemSelection->count();
if (docSelectionCount != 0)
{
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (docSelectionCount > 1)
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::LineStyle, name, Um::ILineStyle);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::LineStyle, name, Um::ILineStyle));
for (uint aa = 0; aa < docSelectionCount; ++aa)
{
PageItem *currItem = itemSelection->itemAt(aa);
5206,8 → 5233,12
currItem->setCustomLineStyle(name);
currItem->update();
}
if (docSelectionCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
changed();
}
5219,12 → 5250,13
uint selectedItemCount=m_Selection->count();
if (selectedItemCount != 0)
{
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (farbe == CommonStrings::tr_NoneColor)
farbe = CommonStrings::None;
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::SetLineColor, farbe, Um::IFill);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::SetLineColor, farbe, Um::IFill));
PageItem *i;
for (uint a = 0; a < selectedItemCount; ++a)
{
5235,8 → 5267,12
i->setLineColor(farbe);
i->update();
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
}
changed();
5356,10 → 5392,11
uint selectedItemCount=m_Selection->count();
if (selectedItemCount != 0)
{
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::SetFill, farbe, Um::IFill);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::SetFill, farbe, Um::IFill));
PageItem *currItem;
for (uint a = 0; a < selectedItemCount; ++a)
{
5367,8 → 5404,12
currItem->setFillColor(farbe);
currItem->update();
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
changed();
}
5381,11 → 5422,12
uint selectedItemCount=m_Selection->count();
if (selectedItemCount != 0)
{
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::SetShade, QString("%1").arg(sha),
Um::IShade);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::SetShade, QString("%1").arg(sha),
Um::IShade));
PageItem *currItem;
for (uint a = 0; a < selectedItemCount; ++a)
{
5393,8 → 5435,12
currItem->setFillShade(sha);
currItem->update();
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
changed();
}
5405,10 → 5451,11
uint selectedItemCount=m_Selection->count();
if (selectedItemCount != 0)
{
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::SetLineShade, QString("%1").arg(sha), Um::IShade);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
Um::IGroup, Um::SetLineShade, QString("%1").arg(sha), Um::IShade));
PageItem *currItem;
for (uint a = 0; a < selectedItemCount; ++a)
{
5416,8 → 5463,12
currItem->setLineShade(sha);
currItem->update();
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
changed();
}
5564,9 → 5615,10
uint selectedItemCount=m_Selection->count();
if (selectedItemCount != 0 && s != ScStyle_None)
{
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::SetFontEffect, "", Um::IFont);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::SetFontEffect, "", Um::IFont));
for (uint aa = 0; aa < selectedItemCount; ++aa)
{
PageItem *currItem = m_Selection->itemAt(aa);
5602,8 → 5654,12
currItem->update();
}
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
changed();
}
5673,8 → 5729,9
uint selectedItemCount=itemSelection->count();
if (selectedItemCount == 0)
return;
UndoTransaction* activeTransaction = NULL;
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, newStyle.displayName(), Um::IFont);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, newStyle.displayName(), Um::IFont));
for (uint aa = 0; aa < selectedItemCount; ++aa)
{
PageItem *currItem = itemSelection->itemAt(aa);
5709,8 → 5766,12
if (currItem->asPathText())
currItem->updatePolyClip();
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
changed();
regionsChanged()->update(QRectF());
}
5724,8 → 5785,9
uint selectedItemCount=itemSelection->count();
if (selectedItemCount == 0)
return;
UndoTransaction* activeTransaction = NULL;
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, tr( "remove direct paragraph formatting" ), Um::IFont);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, tr( "remove direct paragraph formatting" ), Um::IFont));
for (uint aa = 0; aa < selectedItemCount; ++aa)
{
PageItem *currItem = itemSelection->itemAt(aa);
5766,8 → 5828,12
if (currItem->asPathText())
currItem->updatePolyClip();
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
changed();
regionsChanged()->update(QRectF());
}
5781,8 → 5847,9
uint selectedItemCount=itemSelection->count();
if (selectedItemCount == 0)
return;
UndoTransaction* activeTransaction = NULL;
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, newStyle.displayName(), Um::IFont);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, newStyle.displayName(), Um::IFont));
for (uint aa = 0; aa < selectedItemCount; ++aa)
{
PageItem *currItem = itemSelection->itemAt(aa);
5831,8 → 5898,12
currItem->updatePolyClip();
currItem->invalidateLayout();
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
changed();
regionsChanged()->update(QRectF());
}
5846,8 → 5917,9
uint selectedItemCount=itemSelection->count();
if (selectedItemCount == 0)
return;
UndoTransaction* activeTransaction = NULL;
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, newStyle.asString(), Um::IFont);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, newStyle.asString(), Um::IFont));
for (uint aa = 0; aa < selectedItemCount; ++aa)
{
PageItem *currItem = itemSelection->itemAt(aa);
5886,8 → 5958,12
currItem->updatePolyClip();
currItem->invalidateLayout();
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
changed();
regionsChanged()->update(QRectF());
}
5901,8 → 5977,9
uint selectedItemCount=itemSelection->count();
if (selectedItemCount == 0)
return;
UndoTransaction* activeTransaction = NULL;
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, newStyle.asString(), Um::IFont);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, newStyle.asString(), Um::IFont));
for (uint aa = 0; aa < selectedItemCount; ++aa)
{
PageItem *currItem = itemSelection->itemAt(aa);
5941,8 → 6018,12
currItem->updatePolyClip();
currItem->invalidateLayout();
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
changed();
regionsChanged()->update(QRectF());
}
5956,8 → 6037,9
uint selectedItemCount=itemSelection->count();
if (selectedItemCount == 0)
return;
UndoTransaction* activeTransaction = NULL;
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, tr( "remove direct char formatting" ), Um::IFont);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, tr( "remove direct char formatting" ), Um::IFont));
for (uint aa = 0; aa < selectedItemCount; ++aa)
{
PageItem *currItem = itemSelection->itemAt(aa);
6018,8 → 6100,12
currItem->updatePolyClip();
currItem->invalidateLayout();
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
changed();
regionsChanged()->update(QRectF());
}
6596,13 → 6682,14
uint docSelectionCount=m_Selection->count();
if (docSelectionCount != 0)
{
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (docSelectionCount > 1)
{
if (m_Selection->itemAt(0)->locked())
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::UnLock, 0, Um::IUnLock);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::UnLock, 0, Um::IUnLock));
else
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Lock, 0, Um::ILock);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Lock, 0, Um::ILock));
}
for ( uint a = 0; a < docSelectionCount; ++a)
{
6609,8 → 6696,12
m_Selection->itemAt(a)->toggleLock();
m_Selection->itemAt(a)->update();
}
if (docSelectionCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
changed();
emit firstSelectedItemType(m_Selection->itemAt(0)->itemType());
6623,13 → 6714,14
uint selectedItemCount=m_Selection->count();
if (selectedItemCount != 0)
{
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (selectedItemCount > 1)
{
if (m_Selection->itemAt(0)->sizeLocked())
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::SizeUnLock, 0, Um::IUnLock);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::SizeUnLock, 0, Um::IUnLock));
else
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::SizeLock, 0, Um::ILock);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::SizeLock, 0, Um::ILock));
}
for ( uint a = 0; a < selectedItemCount; ++a)
{
6636,8 → 6728,12
m_Selection->itemAt(a)->toggleSizeLock();
m_Selection->itemAt(a)->update();
}
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
changed();
emit firstSelectedItemType(m_Selection->itemAt(0)->itemType());
6673,13 → 6769,14
uint docSelectionCount=m_Selection->count();
if (docSelectionCount != 0)
{
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (docSelectionCount > 1)
{
if (m_Selection->itemAt(0)->printEnabled())
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::DisablePrint, 0, Um::IDisablePrint);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::DisablePrint, 0, Um::IDisablePrint));
else
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::EnablePrint, 0, Um::IEnablePrint);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::EnablePrint, 0, Um::IEnablePrint));
}
for ( uint a = 0; a < docSelectionCount; ++a)
{
6686,8 → 6783,12
m_Selection->itemAt(a)->togglePrintEnabled();
m_Selection->itemAt(a)->update();
}
if (docSelectionCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
changed();
emit firstSelectedItemType(m_Selection->itemAt(0)->itemType());
6702,7 → 6803,7
{
if (docSelectionCount > 1)
{
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::FlipH, 0, Um::IFlipH);
UndoTransaction trans(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::FlipH, 0, Um::IFlipH));
double gx, gy, gh, gw, ix, iy, iw, ih;
m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
for (uint a = 0; a < docSelectionCount; ++a)
6727,8 → 6828,8
currItem->setRedrawBounding();
currItem->GrStartX = currItem->width() - currItem->GrStartX;
currItem->GrEndX = currItem->width() - currItem->GrEndX;
undoManager->commit();
}
trans.commit();
}
else
{
6767,7 → 6868,7
{
if (docSelectionCount > 1)
{
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::FlipV, 0, Um::IFlipV);
UndoTransaction trans(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::FlipV, 0, Um::IFlipV));
double gx, gy, gh, gw, ix, iy, iw, ih;
m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
for (uint a = 0; a < docSelectionCount; ++a)
6794,7 → 6895,7
currItem->GrEndY = currItem->height() - currItem->GrEndY;
}
regionsChanged()->update(QRectF());
undoManager->commit();
trans.commit();
}
else
{
6936,9 → 7037,10
return;
selectedItemCount = delItems.count();
 
UndoTransaction* activeTransaction = NULL;
if (selectedItemCount > 1)
undoManager->beginTransaction(Um::Group + "/" + Um::Selection, Um::IGroup,
Um::Delete, tooltip, Um::IDelete);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Group + "/" + Um::Selection, Um::IGroup,
Um::Delete, tooltip, Um::IDelete));
 
for (uint de = 0; de < selectedItemCount; ++de)
{
6985,8 → 7087,12
}
updateFrameItems();
renumberItemsInListOrder();
if (selectedItemCount > 1)
undoManager->commit();
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
// JG resetting ElemToLink fixes #5629
ElemToLink = NULL;
regionsChanged()->update(QRectF());
7167,8 → 7273,9
uint selectedItemCount=m_Selection->count();
if (selectedItemCount != 0)
{
UndoTransaction* activeTransaction = NULL;
if (UndoManager::undoEnabled() && selectedItemCount > 1)
undoManager->beginTransaction();
activeTransaction = new UndoTransaction(undoManager->beginTransaction());
QString tooltip = Um::ItemsInvolved + "\n";
for (uint a = 0; a < selectedItemCount; ++a)
{
7176,12 → 7283,16
currItem->setLayer(layerNumber);
tooltip += "\t" + currItem->getUName() + "\n";
}
if (UndoManager::undoEnabled() && selectedItemCount > 1)
undoManager->commit(Um::Selection,
Um::IGroup,
Um::SendToLayer,
tooltip,
Um::ILayerAction);
if (activeTransaction)
{
activeTransaction->commit(Um::Selection,
Um::IGroup,
Um::SendToLayer,
tooltip,
Um::ILayerAction);
delete activeTransaction;
activeTransaction = NULL;
}
}
 
//CB why not just the following as we are calling for updatecontents anyway and we arent reflowing text
7208,9 → 7319,10
uint selectedItemCount=itemSelection->count();
if (selectedItemCount != 0)
{
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (UndoManager::undoEnabled() && selectedItemCount > 1)
undoManager->beginTransaction();
activeTransaction = new UndoTransaction(undoManager->beginTransaction());
QString tooltip = Um::ItemsInvolved + "\n";
for (uint a = 0; a < selectedItemCount; ++a)
{
7227,12 → 7339,16
tooltip += "\t" + currItem->getUName() + "\n";
currItem->update();
}
if (UndoManager::undoEnabled() && selectedItemCount > 1)
undoManager->commit(Um::Selection,
Um::IGroup,
Um::ImageOffset,
tooltip,
Um::IImageScaling);
if (activeTransaction)
{
activeTransaction->commit(Um::Selection,
Um::IGroup,
Um::ImageOffset,
tooltip,
Um::IImageScaling);
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
changed();
}
7246,9 → 7362,10
uint selectedItemCount=itemSelection->count();
if (selectedItemCount != 0)
{
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (UndoManager::undoEnabled() && selectedItemCount > 1)
undoManager->beginTransaction();
activeTransaction = new UndoTransaction(undoManager->beginTransaction());
QString tooltip = Um::ItemsInvolved + "\n";
for (uint a = 0; a < selectedItemCount; ++a)
{
7265,12 → 7382,16
tooltip += "\t" + currItem->getUName() + "\n";
currItem->update();
}
if (UndoManager::undoEnabled() && selectedItemCount > 1)
undoManager->commit(Um::Selection,
if (activeTransaction)
{
activeTransaction->commit(Um::Selection,
Um::IGroup,
Um::ImageScale,
tooltip,
Um::IImageScaling);
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
changed();
}
7285,14 → 7406,16
if (selectedItemCount == 0)
return;
m_updateManager.setUpdatesDisabled();
UndoTransaction* outerTransaction = NULL;
if (UndoManager::undoEnabled() && selectedItemCount > 1)
undoManager->beginTransaction();
outerTransaction = new UndoTransaction(undoManager->beginTransaction());
QString tooltip = Um::ItemsInvolved + "\n";
for (uint a = 0; a < selectedItemCount; ++a)
{
UndoTransaction* activeTransaction = NULL;
PageItem *currItem = itemSelection->itemAt(a);
if (UndoManager::undoEnabled())
undoManager->beginTransaction();
activeTransaction = new UndoTransaction(undoManager->beginTransaction());
currItem->setImageXYScale(sx, sy);
currItem->setImageXYOffset(ox/sx, oy/sy);
if (currItem->imageClip.size() != 0)
7304,20 → 7427,28
currItem->imageClip.map(cl);
}
tooltip += "\t" + currItem->getUName() + "\n";
if (UndoManager::undoEnabled())
undoManager->commit(Um::Selection,
Um::IImageFrame,
Um::ImageScale,
tooltip,
Um::IImageScaling);
if (activeTransaction)
{
activeTransaction->commit(Um::Selection,
Um::IImageFrame,
Um::ImageScale,
tooltip,
Um::IImageScaling);
delete activeTransaction;
activeTransaction = NULL;
}
currItem->update();
}
if (UndoManager::undoEnabled() && selectedItemCount > 1)
undoManager->commit(Um::Selection,
Um::IGroup,
Um::ImageScale,
tooltip,
Um::IImageScaling);
if (outerTransaction)
{
outerTransaction->commit(Um::Selection,
Um::IGroup,
Um::ImageScale,
tooltip,
Um::IImageScaling);
delete outerTransaction;
outerTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
changed();
}
7419,7 → 7550,7
for (int i = 0; i < m_Selection->count(); ++i)
targetTooltip += "\t" + m_Selection->itemAt(i)->getUName() + "\n";
// Make the align action a single action in Action History
undoManager->beginTransaction(Um::Selection, 0, Um::AlignDistribute, targetTooltip, Um::IAlignDistribute);
m_alignTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Selection, 0, Um::AlignDistribute, targetTooltip, Um::IAlignDistribute));
if (oneLocked && (t == 0))
{
for (uint i = 0; i < alignObjectsCount; ++i)
7437,7 → 7568,9
m_ScMW->HaveNewSel(m_Selection->itemAt(0)->itemType());
for (int i = 0; i < m_Selection->count(); ++i)
setRedrawBounding(m_Selection->itemAt(i));
undoManager->commit(); // commit and send the action to the UndoManager
m_alignTransaction->commit(); // commit and send the action to the UndoManager
delete m_alignTransaction;
m_alignTransaction = NULL;
regionsChanged()->update(QRectF());
}
 
8441,14 → 8574,16
if ((mdData.type==0 && mdData.copyCount<1) || (mdData.type==1 && (mdData.gridRows==1 && mdData.gridCols==1)))
return;
QString tooltip("");
UndoTransaction* activeTransaction = NULL;
 
if (UndoManager::undoEnabled())
{ // Make multiple duplicate a single action in the action history
if (m_Selection->count() > 1)
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::MultipleDuplicate,"",Um::IMultipleDuplicate);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::MultipleDuplicate,"",Um::IMultipleDuplicate));
else
{
PageItem* item=m_Selection->itemAt(0);
undoManager->beginTransaction(item->getUName(), item->getUPixmap(), Um::MultipleDuplicate, "", Um::IMultipleDuplicate);
activeTransaction = new UndoTransaction(undoManager->beginTransaction(item->getUName(), item->getUPixmap(), Um::MultipleDuplicate, "", Um::IMultipleDuplicate));
}
}
//FIXME: Enable paste without doing this save/restore, and stop using paste with all the refreshes
8533,8 → 8668,12
}
tooltip = tr("Number of copies: %1\nHorizontal gap: %2\nVertical gap: %3").arg(copyCount-1).arg(mdData.gridGapH).arg(mdData.gridGapV);
}
if (UndoManager::undoEnabled())
undoManager->commit("", 0, "", tooltip, 0);
if (activeTransaction)
{
activeTransaction->commit("", 0, "", tooltip, 0);
delete activeTransaction;
activeTransaction = NULL;
}
//FIXME: Enable paste without doing this save/restore
useRaster = savedAlignGrid;
SnapGuides = savedAlignGuides;
8580,9 → 8719,10
if (selectedItemCount == 0)
return;
 
UndoTransaction* activeTransaction = NULL;
m_updateManager.setUpdatesDisabled();
if (UndoManager::undoEnabled() && selectedItemCount > 1)
undoManager->beginTransaction();
activeTransaction = new UndoTransaction(undoManager->beginTransaction());
QString tooltip = Um::ItemsInvolved + "\n";
for (uint a = 0; a < selectedItemCount; ++a)
{
8605,12 → 8745,16
t=Um::StartAndEndArrow;
else
t=(startArrowID!=-1) ? Um::StartArrow : Um::EndArrow;
if (UndoManager::undoEnabled() && selectedItemCount > 1)
undoManager->commit(Um::Selection,
Um::IGroup,
t,
tooltip,
Um::IArrow);
if (activeTransaction)
{
activeTransaction->commit(Um::Selection,
Um::IGroup,
t,
tooltip,
Um::IArrow);
delete activeTransaction;
activeTransaction = NULL;
}
m_updateManager.setUpdatesEnabled();
changed();
}
9752,7 → 9896,7
if (selectedItemCount > 0)
{
bool toUpdate=false;
UndoTransaction* activeTransaction = NULL;
for (uint i = 0; i < selectedItemCount; ++i)
{
PageItem *currItem = itemSelection->itemAt(i);
9760,11 → 9904,12
{
if (currItem->asImageFrame() && currItem->PicAvail && !currItem->isTableItem)
{
undoManager->beginTransaction(selectedItemCount == 1 ?
currItem->getUName() : Um::SelectionGroup,
selectedItemCount == 1 ?
currItem->getUPixmap() : Um::IGroup,
Um::AdjustFrameToImage,"",Um::IResize);
if (!activeTransaction)
activeTransaction = new UndoTransaction(undoManager->beginTransaction(selectedItemCount == 1 ?
currItem->getUName() : Um::SelectionGroup,
selectedItemCount == 1 ?
currItem->getUPixmap() : Um::IGroup,
Um::AdjustFrameToImage,"",Um::IResize));
double w, h, x, y;
w = currItem->OrigW * currItem->imageXScale();
h = currItem->OrigH * currItem->imageYScale();
9778,15 → 9923,16
else
SizeItem(w, h, currItem->ItemNr, true);
currItem->setImageXYOffset(0.0, 0.0);
toUpdate=true;
}
}
}
if (toUpdate)
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
regionsChanged()->update(QRectF());
changed();
undoManager->commit();
itemSelection->itemAt(0)->emitAllToGUI();
}
}
9793,6 → 9939,42
}
 
 
 
NodeEditContext::NodeEditContext()
: submode(MOVE_POINT), isContourLine(false), oldClip(NULL), nodeTransaction(NULL),
ClRe(-1), ClRe2(-1), SegP1(-1), SegP2(-1), EdPoints(true), MoveSym(false), SelNode()
{
}
 
bool NodeEditContext::hasNodeSelected()
{
return ClRe != -1;
}
 
 
void NodeEditContext::deselect()
{
ClRe = -1;
}
 
void NodeEditContext::reset()
{
submode = MOVE_POINT;
isContourLine = false;
ClRe = -1;
ClRe2 = -1;
SegP1 = -1;
SegP2 = -1;
delete oldClip;
oldClip = NULL;
delete nodeTransaction;
nodeTransaction = NULL;
MoveSym = false;
SelNode.clear();
}
 
 
 
FPointArray NodeEditContext::beginTransaction(PageItem* currItem)
{
ScribusDoc* Doc = currItem->doc();
9815,7 → 9997,7
oldClip = new FPointArray(Clip);
oldItemX = currItem->xPos();
oldItemY = currItem->yPos();
undoManager->beginTransaction(currItem->getUName(), currItem->getUPixmap(), uAction);
nodeTransaction = new UndoTransaction(undoManager->beginTransaction(currItem->getUName(), currItem->getUPixmap(), uAction));
Doc->nodeEdit.deselect();
return Clip;
}
9827,7 → 10009,7
ScribusDoc* Doc = currItem->doc();
UndoManager* undoManager = UndoManager::instance();
if (oldClip) // is there the old clip stored for the undo action
if (nodeTransaction) // is there the old clip stored for the undo action
{
FPointArray newClip(Doc->nodeEdit.isContourLine ? currItem->ContourLine : currItem->PoLine);
if (*oldClip != newClip)
9843,11 → 10025,13
state->set("NEW_X", currItem->xPos());
state->set("NEW_Y", currItem->yPos());
undoManager->action(currItem, state);
undoManager->commit();
nodeTransaction->commit();
}
else
undoManager->cancelTransaction();
nodeTransaction->cancel();
delete nodeTransaction;
nodeTransaction = NULL;
delete oldClip;
oldClip = 0;
}
9854,6 → 10038,9
}
 
 
/**
first part: create a new UndoState or cancel the current transaction
*/
ItemState<QPair<FPointArray, FPointArray> >* NodeEditContext::finishTransaction1(PageItem* currItem)
{
ScribusDoc* Doc = currItem->doc();
9860,7 → 10047,7
UndoManager* undoManager = UndoManager::instance();
ItemState<QPair<FPointArray, FPointArray> >* state = NULL;
if (oldClip) // is there the old clip stored for the undo action
if (nodeTransaction) // is there the old clip stored for the undo action
{
FPointArray newClip(Doc->nodeEdit.isContourLine ? currItem->ContourLine : currItem->PoLine);
if (*oldClip != newClip)
9876,13 → 10063,17
{
delete oldClip;
oldClip = 0;
undoManager->cancelTransaction();
nodeTransaction->cancel();
delete nodeTransaction;
nodeTransaction = NULL;
}
}
return state;
}
 
 
/**
second part: take the UndoState returned from finishTransaction1() and commit it
*/
void NodeEditContext::finishTransaction2(PageItem* currItem, ItemState<QPair<FPointArray, FPointArray> >* state)
{
//ScribusDoc* Doc = currItem->doc();
9894,7 → 10085,9
state->set("NEW_Y", currItem->yPos());
undoManager->setUndoEnabled(true);
undoManager->action(currItem, state);
undoManager->commit();
nodeTransaction->commit();
delete nodeTransaction;
nodeTransaction = NULL;
delete oldClip;
oldClip = 0;
}
/trunk/Scribus/scribus/transaction.h
0,0 → 1,101
 
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
/***************************************************************************
* Copyright (C) 2008 by Andreas Vox *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
 
#ifndef TRANSACTION_H
#define TRANSACTION_H
 
#include "scribusapi.h"
 
 
/**
Interface class for objects representing a going transaction.
Will be specialized by classes like Undomanager for use as
a result type in their beginTransaction() method.
*/
class SCRIBUS_API Transaction {
 
public:
enum Status {
STATE_OPEN,
STATE_WILLFAIL,
STATE_FAILED,
STATE_COMMITTED
};
struct TransactionStateBase {
Status m_status;
};
Transaction(TransactionStateBase* data) : m_data(data)
{
m_data->m_status = STATE_OPEN;
}
Transaction(const Transaction& other) : m_data(other.m_data)
{
const_cast<Transaction&>(other).m_data = 0; // mean, but necessary so that not both destructors commit/close
}
/**
Automatically commits if forgotten.
Override as appropiate. Since the superclass destructor is called last, you
can cancel in the subclass destructor; the commit here then will do nothing.
Don't forget to set m_data to NULL if you free the m_data pointer!
*/
virtual ~Transaction();
/**
Commits this transaction if in STATE_OPEN.
If in STATE_WILLFAIL, cancel the transaction instead; otherwise do nothing.
Returns true iff the transaction was committed or canceled.
*/
virtual bool commit() = 0;
/**
Cancels this transaction if in STATE_OPEN or STATE_WILLFAIL; otherwise do nothing
Returns true iff the transaction was canceled.
*/
virtual bool cancel() = 0;
/**
Marks this transaction as failed.
*/
virtual void markFailed();
int getState() const;
protected:
// if you subclass, do *not* add any data members but use this pointer instead,
// otherwise the copy initializer will strip your objects.
TransactionStateBase* m_data;
private:
// blocked
Transaction& operator= (const Transaction&) { return *this; }
};
 
#endif
/trunk/Scribus/scribus/canvasgesture_linemove.cpp
130,6 → 130,8
{
doResize();
m_doc->setRedrawBounding(m_line);
m_view->resetMousePressed();
m_line->checkChanges();
m_line->update();
}
m->accept();
/trunk/Scribus/scribus/canvasmode_drawbezier.cpp
71,6 → 71,7
inItemCreation = false;
shiftSelItems = false;
FirstPoly = true;
m_createTransaction = NULL;
}
 
 
270,6 → 271,7
if (FirstPoly)
{
selectPage(m);
m_createTransaction = new UndoTransaction(UndoManager::instance()->beginTransaction());
z = m_doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, Rxp, Ryp, 1+Rxpd, 1+Rypd, m_doc->toolSettings.dWidth, CommonStrings::None, m_doc->toolSettings.dPenLine, true);
currItem = m_doc->Items->at(z);
m_doc->m_Selection->clear();
385,7 → 387,23
m_doc->AdjustItemSize(currItem);
currItem->ContourLine = currItem->PoLine.copy();
}
m_view->resetMousePressed();
currItem->checkChanges();
if (m_createTransaction)
{
m_view->resetMousePressed();
currItem->checkChanges(true);
QString targetName = Um::ScratchSpace;
if (currItem->OwnPage > -1)
targetName = m_doc->Pages->at(currItem->OwnPage)->getUName();
m_createTransaction->commit(targetName, currItem->getUPixmap(),
Um::Create + " " + currItem->getUName(), "", Um::ICreate);
delete m_createTransaction;
m_createTransaction = NULL;
}
currItem->update();
}
if (!PrefsManager::instance()->appPrefs.stickyTools)
{
// qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
394,7 → 412,6
}
else
m_view->requestMode(m_doc->appMode);
currItem->update();
m_doc->changed();
// emit DocChanged();
FirstPoly = true;
/trunk/Scribus/scribus/scribusdoc.h
68,6 → 68,7
class ResourceCollection;
class PageSize;
class ScPattern;
class UndoTransaction;
 
class QProgressBar;
 
77,6 → 78,7
int submode;
bool isContourLine;
FPointArray *oldClip;
UndoTransaction* nodeTransaction;
double oldItemX;
double oldItemY;
88,25 → 90,12
bool MoveSym;
QList<int> SelNode;
NodeEditContext() : submode(MOVE_POINT), isContourLine(false), oldClip(NULL),
ClRe(-1), ClRe2(-1), SegP1(-1), SegP2(-1), EdPoints(true), MoveSym(false), SelNode() {}
NodeEditContext();
bool hasNodeSelected() { return ClRe != -1; }
void deselect() { ClRe = -1; }
bool hasNodeSelected();
void deselect();
void reset()
{
submode = MOVE_POINT;
isContourLine = false;
ClRe = -1;
ClRe2 = -1;
SegP1 = -1;
SegP2 = -1;
delete oldClip;
oldClip = NULL;
MoveSym = false;
SelNode.clear();
}
void reset();
void reset1Control(PageItem* currItem);
void resetControl(PageItem* currItem);
1083,7 → 1072,9
Hyphenator * docHyphenator;
private:
bool _itemCreationTransactionStarted;
UndoTransaction* m_itemCreationTransaction;
UndoTransaction* m_alignTransaction;
 
Page* _currentPage;
UpdateManager m_updateManager;
MassObservable<PageItem*> m_itemsChanged;
/trunk/Scribus/scribus/transaction.cpp
0,0 → 1,49
 
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
/***************************************************************************
* Copyright (C) 2008 by Andreas Vox *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
 
 
 
#include "transaction.h"
 
Transaction::~Transaction()
{
if (m_data)
{
// we must not call virtual functions from destructor: commit();
delete m_data;
}
}
 
void Transaction::markFailed()
{
if (m_data->m_status == STATE_OPEN)
m_data->m_status = STATE_WILLFAIL;
}
 
int Transaction::getState() const
{
return m_data->m_status;
}
/trunk/Scribus/scribus/plugins/imposition/imposition.cpp
527,7 → 527,7
//get group control
signed int groupid = gs->itemAt(0)->Groups.at(0);
PageItem* groupcontrol;
PageItem* groupcontrol = NULL;
for (int k = 0; k < targetDoc->Items->count(); k++)
{
if (
715,7 → 715,7
//get group control
signed int groupid = gs->itemAt(0)->Groups.at(0);
PageItem* groupcontrol;
PageItem* groupcontrol = NULL;
for (int k = 0; k < targetDoc->Items->count(); k++)
{
if (
878,7 → 878,7
//get group control
signed int groupid = gs->itemAt(0)->Groups.at(0);
PageItem* groupcontrol;
PageItem* groupcontrol = NULL;
for (int k = 0; k < targetDoc->Items->count(); k++)
{
if (
1032,7 → 1032,7
//get group control
signed int groupid = gs->itemAt(0)->Groups.at(0);
PageItem* groupcontrol;
PageItem* groupcontrol = NULL;
for (int k = 0; k < targetDoc->Items->count(); k++)
{
if (
/trunk/Scribus/scribus/plugins/aiimplugin/importai.cpp
385,7 → 385,11
outf.open(QIODevice::WriteOnly);
try
{
#if PODOFO_VERSION == 0 && PODOFO_MINOR == 5 && PODOFO_REVISION == 99
PoDoFo::PdfMemDocument doc( infile.toLocal8Bit().data() );
#else
PoDoFo::PdfDocument doc( infile.toLocal8Bit().data() );
#endif
PoDoFo::PdfPage *curPage = doc.GetPage(0);
if (curPage != NULL)
{
/trunk/Scribus/scribus/plugins/svgimplugin/svgplugin.cpp
161,18 → 161,24
return true;
}
if (UndoManager::undoEnabled() && m_Doc)
UndoTransaction* activeTransaction = NULL;
bool emptyDoc = (m_Doc == NULL);
if (UndoManager::undoEnabled() && !emptyDoc)
{
UndoManager::instance()->beginTransaction(m_Doc->currentPage()->getUName(),Um::IImageFrame,Um::ImportSVG, filename, Um::ISVG);
activeTransaction = new UndoTransaction(UndoManager::instance()->beginTransaction(m_Doc->currentPage()->getUName(),Um::IImageFrame,Um::ImportSVG, filename, Um::ISVG));
}
else if (UndoManager::undoEnabled() && !m_Doc)
else if (UndoManager::undoEnabled() && emptyDoc)
UndoManager::instance()->setUndoEnabled(false);
SVGPlug *dia = new SVGPlug(mw, flags);
dia->import(filename, flags);
Q_CHECK_PTR(dia);
if (UndoManager::undoEnabled())
UndoManager::instance()->commit();
else
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
else if (UndoManager::undoEnabled() && emptyDoc)
UndoManager::instance()->setUndoEnabled(true);
if (dia->importCanceled)
{
/trunk/Scribus/scribus/plugins/fileloader/oodraw/oodrawimp.cpp
178,20 → 178,26
return true;
}
m_Doc=ScCore->primaryMainWindow()->doc;
if (UndoManager::undoEnabled() && m_Doc)
UndoTransaction* activeTransaction = NULL;
bool emptyDoc = (m_Doc == NULL);
if (UndoManager::undoEnabled() && !emptyDoc)
{
UndoManager::instance()->beginTransaction(m_Doc->currentPage()->getUName(),
Um::IImageFrame,
Um::ImportOOoDraw,
fileName, Um::IImportOOoDraw);
activeTransaction = new UndoTransaction(UndoManager::instance()->beginTransaction(m_Doc->currentPage()->getUName(),
Um::IImageFrame,
Um::ImportOOoDraw,
fileName, Um::IImportOOoDraw));
}
else if (UndoManager::undoEnabled() && !m_Doc)
else if (UndoManager::undoEnabled() && emptyDoc)
UndoManager::instance()->setUndoEnabled(false);
OODPlug dia(m_Doc);
bool importDone = dia.import(fileName, flags);
if (UndoManager::undoEnabled())
UndoManager::instance()->commit();
else
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
else if (UndoManager::undoEnabled() && emptyDoc)
UndoManager::instance()->setUndoEnabled(true);
if (dia.importCanceled)
{
/trunk/Scribus/scribus/plugins/psimport/importpsplugin.cpp
146,21 → 146,27
return true;
}
m_Doc=ScCore->primaryMainWindow()->doc;
if (UndoManager::undoEnabled() && m_Doc)
UndoTransaction* activeTransaction = NULL;
bool emptyDoc = (m_Doc == NULL);
if (UndoManager::undoEnabled() && !emptyDoc)
{
UndoManager::instance()->beginTransaction(m_Doc->currentPage()->getUName(),
Um::IImageFrame,
Um::ImportEPS,
fileName, Um::IEPS);
activeTransaction = new UndoTransaction(UndoManager::instance()->beginTransaction(m_Doc->currentPage()->getUName(),
Um::IImageFrame,
Um::ImportEPS,
fileName, Um::IEPS));
}
else if (UndoManager::undoEnabled() && !m_Doc)
else if (UndoManager::undoEnabled() && emptyDoc)
UndoManager::instance()->setUndoEnabled(false);
EPSPlug *dia = new EPSPlug(m_Doc, flags);
Q_CHECK_PTR(dia);
dia->import(fileName, flags);
if (UndoManager::undoEnabled())
UndoManager::instance()->commit();
else
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
else if (UndoManager::undoEnabled() && emptyDoc)
UndoManager::instance()->setUndoEnabled(true);
delete dia;
return true;
/trunk/Scribus/scribus/canvasgesture_resize.cpp
27,7 → 27,7
 
ResizeGesture::ResizeGesture (CanvasMode* parent) : CanvasGesture(parent)
{
m_transactionStarted = false;
m_transactionStarted = NULL;
}
 
void ResizeGesture::prepare(Canvas::FrameHandle framehandle)
65,8 → 65,10
m_handle = Canvas::OUTSIDE;
if (m_transactionStarted)
{
m_view->cancelGroupTransaction();
m_transactionStarted = false;
qDebug() << "ResizeGesture::clear: cancel transaction" << m_transactionStarted;
m_transactionStarted->cancel();
delete m_transactionStarted;
m_transactionStarted = NULL;
}
}
 
133,13 → 135,18
m_doc->setRedrawBounding(currItem);
if (currItem->asImageFrame())
currItem->AdjustPictScale();
m_view->resetMousePressed();
// necessary since mousebutton is still recorded pressed, and otherwise checkchages() will do nothing
currItem->checkChanges();
currItem->invalidateLayout();
currItem->update();
}
// qDebug() << "ResizeGesture::release: transaction" << m_transactionStarted;
if (m_transactionStarted)
{
m_view->endGroupTransaction();
m_transactionStarted = false;
m_transactionStarted->commit();
delete m_transactionStarted;
m_transactionStarted = NULL;
}
m->accept();
m_canvas->update();
149,12 → 156,20
 
void ResizeGesture::doResize(bool scaleContent)
{
PageItem* currItem = m_doc->m_Selection->itemAt(0);
QString targetName = Um::SelectionGroup;
QPixmap* targetIcon = Um::IGroup;
if (!m_doc->m_Selection->isMultipleSelection())
{
targetName = currItem->getUName();
targetIcon = currItem->getUPixmap();
}
if (!m_transactionStarted)
{
m_view->startGroupTransaction(Um::Resize, "", Um::IResize);
m_transactionStarted = true;
m_transactionStarted = new UndoTransaction(Um::instance()->beginTransaction(targetName, targetIcon,
Um::Resize, "", Um::IResize));
// qDebug() << "ResizeGesture::doResize: begin transaction" << m_transactionStarted;
}
PageItem* currItem = m_doc->m_Selection->itemAt(0);
QRectF newBounds = m_bounds.normalized();
if (m_doc->m_Selection->isMultipleSelection())
{
/trunk/Scribus/scribus/CMakeLists.txt
549,6 → 549,7
tabtypography.cpp
tocgenerator.cpp
tocindexprefs.cpp
transaction.cpp
tt/simpletreemodel/treeitem.cpp
tt/simpletreemodel/treemodel.cpp
ui/copypagetomasterpagedialog.cpp