r16489 by craig - #9875: Add in undo/redo for text frame linking and unlinking
scribus-commit
scribus-commit at lists.scribus.net
Thu Mar 24 12:39:09 CET 2011
Author: craig
Date: Thu Mar 24 11:39:09 2011
New Revision: 16489
URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16489
Log:
#9875: Add in undo/redo for text frame linking and unlinking
Modified:
branches/Version135/Scribus/scribus/pageitem.cpp
branches/Version135/Scribus/scribus/pageitem.h
branches/Version135/Scribus/scribus/undomanager.cpp
branches/Version135/Scribus/scribus/undomanager.h
Modified: branches/Version135/Scribus/scribus/pageitem.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16489&path=/branches/Version135/Scribus/scribus/pageitem.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/pageitem.cpp (original)
+++ branches/Version135/Scribus/scribus/pageitem.cpp Thu Mar 24 11:39:09 2011
@@ -783,12 +783,20 @@
nxt->firstChar = 0;
nxt = nxt->NextBox;
}
+ if (UndoManager::undoEnabled())
+ {
+ ItemState<std::pair<PageItem*, PageItem*> > *is = new ItemState<std::pair<PageItem*, PageItem*> >(UndoManager::LinkTextFrame);
+ is->set("LINK_TEXT_FRAME", "linkTextFrame");
+ is->setItem(std::pair<PageItem*, PageItem*>(this, NextBox));
+ undoManager->action(this, is);
+ }
}
void PageItem::unlink()
{
if( NextBox )
{
+ PageItem *undoNextBox=NextBox;
// make sure lastInFrame is valid
layout();
/*
@@ -826,6 +834,13 @@
}
// NextBox == NULL now
NextBox = NULL;
+ if (UndoManager::undoEnabled())
+ {
+ ItemState<std::pair<PageItem*, PageItem*> > *is = new ItemState<std::pair<PageItem*, PageItem*> >(UndoManager::UnlinkTextFrame);
+ is->set("UNLINK_TEXT_FRAME", "unlinkTextFrame");
+ is->setItem(std::pair<PageItem*, PageItem*>(this, undoNextBox));
+ undoManager->action(this, is);
+ }
}
}
@@ -3236,6 +3251,10 @@
restoreEditText(ss, isUndo);
else if (ss->contains("CLEAR_IMAGE"))
restoreClearImage(ss,isUndo);
+ else if (ss->contains("LINK_TEXT_FRAME"))
+ restoreLinkTextFrame(ss,isUndo);
+ else if (ss->contains("UNLINK_TEXT_FRAME"))
+ restoreUnlinkTextFrame(ss,isUndo);
}
if (!OnMasterPage.isEmpty())
m_Doc->setCurrentPage(oldCurrentPage);
@@ -3621,6 +3640,35 @@
asImageFrame()->clearContents();
}
+void PageItem::restoreLinkTextFrame(UndoState *state, bool isUndo)
+{
+ if (!isTextFrame())
+ return;
+ if (isUndo)
+ {
+ unlink();
+ }
+ else
+ {
+ ItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ItemState<std::pair<PageItem*, PageItem*> >*>(state);
+ asTextFrame()->link(is->getItem().second->asTextFrame());
+ }
+}
+
+void PageItem::restoreUnlinkTextFrame(UndoState *state, bool isUndo)
+{
+ if (!isTextFrame())
+ return;
+ if (isUndo)
+ {
+ ItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ItemState<std::pair<PageItem*, PageItem*> >*>(state);
+ asTextFrame()->link(is->getItem().second->asTextFrame());
+ }
+ else
+ {
+ unlink();
+ }
+}
void PageItem::restorePoly(SimpleState *state, bool isUndo, bool isContour)
Modified: branches/Version135/Scribus/scribus/pageitem.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16489&path=/branches/Version135/Scribus/scribus/pageitem.h
==============================================================================
--- branches/Version135/Scribus/scribus/pageitem.h (original)
+++ branches/Version135/Scribus/scribus/pageitem.h Thu Mar 24 11:39:09 2011
@@ -1084,7 +1084,8 @@
void restoreShapeContour(UndoState *state, bool isUndo);
void restoreImageEffects(UndoState *state, bool isUndo);
void restoreEditText(SimpleState *state, bool isUndo);
-
+ void restoreLinkTextFrame(UndoState *state, bool isUndo);
+ void restoreUnlinkTextFrame(UndoState *state, bool isUndo);
/*@}*/
/**
Modified: branches/Version135/Scribus/scribus/undomanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16489&path=/branches/Version135/Scribus/scribus/undomanager.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/undomanager.cpp (original)
+++ branches/Version135/Scribus/scribus/undomanager.cpp Thu Mar 24 11:39:09 2011
@@ -964,9 +964,11 @@
UndoManager::Copy = tr("Copy");
UndoManager::CopyPage = tr("Copy page");
UndoManager::ToOutlines = tr("Convert to outlines");
- UndoManager::EditText = tr("Edit text");
- UndoManager::ClearImage = tr("Clear image frame content");
- UndoManager::ClearContent = tr("Clear frame content");
+ UndoManager::EditText = tr("Edit text");
+ UndoManager::ClearImage = tr("Clear image frame content");
+ UndoManager::ClearContent = tr("Clear frame content");
+ UndoManager::LinkTextFrame = tr("Link text frame");
+ UndoManager::UnlinkTextFrame = tr("Unlink text frame");
}
void UndoManager::initIcons()
@@ -1167,9 +1169,11 @@
QString UndoManager::Copy = "";
QString UndoManager::CopyPage = "";
QString UndoManager::ToOutlines = "";
-QString UndoManager::EditText = "";
-QString UndoManager::ClearImage = "";
-QString UndoManager::ClearContent = "";
+QString UndoManager::EditText = "";
+QString UndoManager::ClearImage = "";
+QString UndoManager::ClearContent = "";
+QString UndoManager::LinkTextFrame = "";
+QString UndoManager::UnlinkTextFrame = "";
/*** Icons for UndoObjects *******************************************/
QPixmap *UndoManager::IImageFrame = 0;
Modified: branches/Version135/Scribus/scribus/undomanager.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16489&path=/branches/Version135/Scribus/scribus/undomanager.h
==============================================================================
--- branches/Version135/Scribus/scribus/undomanager.h (original)
+++ branches/Version135/Scribus/scribus/undomanager.h Thu Mar 24 11:39:09 2011
@@ -591,6 +591,8 @@
static QString EditText;
static QString ClearImage;
static QString ClearContent;
+ static QString LinkTextFrame;
+ static QString UnlinkTextFrame;
/*@}*/
/**
More information about the scribus-commit
mailing list