undo4welding.diff (5,263 bytes)
diff --git a/Scribus/scribus/pageitem.cpp b/Scribus/scribus/pageitem.cpp
index cd7f342..4126f3e 100644
--- a/Scribus/scribus/pageitem.cpp
+++ b/Scribus/scribus/pageitem.cpp
@@ -4949,6 +4949,10 @@ void PageItem::restore(UndoState *state, bool isUndo)
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);
@@ -4979,6 +4983,51 @@ void PageItem::restoreConnectPath(SimpleState *state, bool isUndo)
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)
{
if (ss->contains("SNAP_TO_PATCH"))
@@ -10062,6 +10111,13 @@ void PageItem::weldTo(PageItem* pIt)
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();
}
@@ -10145,6 +10201,10 @@ QList<PageItem*> PageItem::itemsWeldedTo(PageItem* except)
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);
@@ -10156,10 +10216,29 @@ void PageItem::unWeld()
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();
}
diff --git a/Scribus/scribus/pageitem.h b/Scribus/scribus/pageitem.h
index 49f9c00..bb476a5 100644
--- a/Scribus/scribus/pageitem.h
+++ b/Scribus/scribus/pageitem.h
@@ -1436,6 +1436,10 @@ protected:
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);
+
/*@}*/
/**
diff --git a/Scribus/scribus/undomanager.cpp b/Scribus/scribus/undomanager.cpp
index 355f876..6c7adf2 100644
--- a/Scribus/scribus/undomanager.cpp
+++ b/Scribus/scribus/undomanager.cpp
@@ -1042,6 +1042,7 @@ void UndoManager::languageChange()
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::ClearImage = "";
QString UndoManager::PathOperation = "";
QString UndoManager::ChangePageAttrs = "";
QString UndoManager::Transform = "";
+QString UndoManager::WeldItems = "";
/*** Icons for UndoObjects *******************************************/
QPixmap *UndoManager::IImageFrame = 0;
diff --git a/Scribus/scribus/undomanager.h b/Scribus/scribus/undomanager.h
index 24e92df..278dd28 100644
--- a/Scribus/scribus/undomanager.h
+++ b/Scribus/scribus/undomanager.h
@@ -652,6 +652,7 @@ public:
static QString UnlinkTextFrame;
static QString ClearImage;
static QString PathOperation;
+ static QString WeldItems;
/*@}*/
/**