r17791 by jghali - #11011 : undo does not restore items welding
scribus-commit
scribus-commit at lists.scribus.net
Mon Oct 8 21:06:51 UTC 2012
Author: jghali
Date: Mon Oct 8 21:06:51 2012
New Revision: 17791
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17791
Log:
#11011 : undo does not restore items welding
Modified:
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/pageitem.h
trunk/Scribus/scribus/undomanager.cpp
trunk/Scribus/scribus/undomanager.h
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17791&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Mon Oct 8 21:06:51 2012
@@ -4950,6 +4950,10 @@
restoreAppMode(ss, isUndo);
else if (ss->contains("CONNECT_PATH"))
restoreConnectPath(ss, isUndo);
+ else if (ss->contains("WELD_ITEMS"))
+ restoreWeldItems(ss, isUndo);
+ else if (ss->contains("UNWELD_ITEM"))
+ restoreUnWeldItem(ss, isUndo);
}
if (!OnMasterPage.isEmpty())
m_Doc->setCurrentPage(oldCurrentPage);
@@ -4978,6 +4982,51 @@
OldH2 = height();
updateClip();
ContourLine = PoLine.copy();
+}
+
+void PageItem::restoreWeldItems(SimpleState *state, bool isUndo)
+{
+ if (isUndo)
+ {
+ unWeld();
+ }
+ else
+ {
+ ScItemState<PageItem*> *is = dynamic_cast<ScItemState<PageItem*>*>(state);
+ PageItem* wIt = is->getItem();
+ weldTo(wIt);
+ }
+ m_Doc->changed();
+ m_Doc->regionsChanged()->update(QRectF());
+}
+
+void PageItem::restoreUnWeldItem(SimpleState *state, bool isUndo)
+{
+ if (isUndo)
+ {
+ ScItemState<PageItem*> *is = dynamic_cast<ScItemState<PageItem*>*>(state);
+ PageItem* wIt = is->getItem();
+ {
+ weldingInfo wInf;
+ wInf.weldItem = wIt;
+ wInf.weldID = is->getInt("thisID");
+ wInf.weldPoint = FPoint(is->getDouble("thisPoint_x"), is->getDouble("thisPoint_y"));
+ weldList.append(wInf);
+ }
+ {
+ weldingInfo wInf;
+ wInf.weldItem = this;
+ wInf.weldID = is->getInt("ID");
+ wInf.weldPoint = FPoint(is->getDouble("Point_x"), is->getDouble("Point_y"));
+ wIt->weldList.append(wInf);
+ }
+ }
+ else
+ {
+ unWeld();
+ }
+ m_Doc->changed();
+ m_Doc->regionsChanged()->update(QRectF());
}
bool PageItem::checkGradientUndoRedo(SimpleState *ss, bool isUndo)
@@ -10063,6 +10112,13 @@
return;
addWelded(pIt);
pIt->addWelded(this);
+ if(undoManager->undoEnabled())
+ {
+ ScItemState<PageItem*> *is = new ScItemState<PageItem*>(Um::WeldItems,"",Um::IGroup);
+ is->set("WELD_ITEMS", "weld_items");
+ is->setItem(pIt);
+ undoManager->action(this, is, getUPixmap());
+ }
update();
pIt->update();
}
@@ -10146,6 +10202,10 @@
void PageItem::unWeld()
{
+ UndoTransaction* activeTransaction = NULL;
+ if (undoManager->undoEnabled())
+ activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::WeldItems + "/" + Um::Selection, Um::IGroup,
+ Um::WeldItems, "", Um::IDelete));
for (int a = 0 ; a < weldList.count(); a++)
{
weldingInfo wInf = weldList.at(a);
@@ -10157,10 +10217,29 @@
if (pIt2 == this)
{
pIt->weldList.removeAt(b);
+ if(undoManager->undoEnabled())
+ {
+ ScItemState<PageItem*> *is = new ScItemState<PageItem*>(Um::WeldItems,"",Um::IGroup);
+ is->set("UNWELD_ITEM", "unweld_item");
+ is->setItem(pIt);
+ is->set("thisPoint_x", wInf.weldPoint.x());
+ is->set("thisPoint_y", wInf.weldPoint.y());
+ is->set("thisID", wInf.weldID);
+ is->set("Point_x", wInf2.weldPoint.x());
+ is->set("Point_y", wInf2.weldPoint.y());
+ is->set("ID", wInf2.weldID);
+ undoManager->action(this, is, getUPixmap());
+ }
break;
}
}
}
+ if (activeTransaction)
+ {
+ activeTransaction->commit();
+ delete activeTransaction;
+ activeTransaction = NULL;
+ }
weldList.clear();
}
Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17791&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Mon Oct 8 21:06:51 2012
@@ -1436,6 +1436,10 @@
void restoreUnlinkTextFrame(UndoState *state, bool isUndo);
void restoreReverseText(UndoState *state, bool isUndo);
void restorePathOperation(UndoState *state, bool isUndo);
+
+ void restoreWeldItems(SimpleState *state, bool isUndo);
+ void restoreUnWeldItem(SimpleState *state, bool isUndo);
+
/*@}*/
/**
Modified: trunk/Scribus/scribus/undomanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17791&path=/trunk/Scribus/scribus/undomanager.cpp
==============================================================================
--- trunk/Scribus/scribus/undomanager.cpp (original)
+++ trunk/Scribus/scribus/undomanager.cpp Mon Oct 8 21:06:51 2012
@@ -1042,6 +1042,7 @@
UndoManager::PathOperation = tr("Path Operation");
UndoManager::ChangePageAttrs = tr("Change Page Attributes");
UndoManager::Transform = tr("Transform");
+ UndoManager::WeldItems = tr("Weld Items");
}
void UndoManager::initIcons()
@@ -1305,6 +1306,7 @@
QString UndoManager::PathOperation = "";
QString UndoManager::ChangePageAttrs = "";
QString UndoManager::Transform = "";
+QString UndoManager::WeldItems = "";
/*** Icons for UndoObjects *******************************************/
QPixmap *UndoManager::IImageFrame = 0;
Modified: trunk/Scribus/scribus/undomanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17791&path=/trunk/Scribus/scribus/undomanager.h
==============================================================================
--- trunk/Scribus/scribus/undomanager.h (original)
+++ trunk/Scribus/scribus/undomanager.h Mon Oct 8 21:06:51 2012
@@ -652,6 +652,7 @@
static QString UnlinkTextFrame;
static QString ClearImage;
static QString PathOperation;
+ static QString WeldItems;
/*@}*/
/**
More information about the scribus-commit
mailing list