r16507 by craig - #2338: Allow undo/redo of Manage Page Properties

scribus-commit scribus-commit at lists.scribus.net
Fri Mar 25 22:57:59 CET 2011


Author: craig
Date: Fri Mar 25 21:57:58 2011
New Revision: 16507

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16507
Log:
#2338: Allow undo/redo of Manage Page Properties

Modified:
    branches/Version135/Scribus/scribus/scribus.cpp
    branches/Version135/Scribus/scribus/scribusdoc.cpp
    branches/Version135/Scribus/scribus/scribusdoc.h
    branches/Version135/Scribus/scribus/undomanager.cpp
    branches/Version135/Scribus/scribus/undomanager.h

Modified: branches/Version135/Scribus/scribus/scribus.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16507&path=/branches/Version135/Scribus/scribus/scribus.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/scribus.cpp (original)
+++ branches/Version135/Scribus/scribus/scribus.cpp Fri Mar 25 21:57:58 2011
@@ -6961,20 +6961,21 @@
 			doc->changePageMargins(dia->top(), dia->bottom(),
 								   dia->left(), dia->right(),
 								   ph, pw, ph, pw, orientation,
-								   sizeName, doc->currentPage()->pageNr(), lp);
+								   sizeName, dia->getMarginPreset(), dia->getMoveObjects(), doc->currentPage()->pageNr(), lp);
 		}
 		else
 		{
 			doc->changePageMargins(dia->top(), dia->bottom(),
 								   dia->left(), dia->right(),
 								   ph, pw, ph, pw, orientation,
-								   sizeName, doc->currentPage()->pageNr());
+								   sizeName, dia->getMarginPreset(), dia->getMoveObjects(), doc->currentPage()->pageNr());
 			if (dia->masterPage() != Nam)
 				Apply_MasterPage(dia->masterPage(), doc->currentPage()->pageNr());
 		}
-		doc->currentPage()->marginPreset = dia->getMarginPreset();
-		view->reformPages(dia->getMoveObjects());
-		view->DrawNew();
+		//CB: Moved to changePageMargins for #2338
+		//doc->currentPage()->marginPreset = dia->getMarginPreset();
+		//view->reformPages(dia->getMoveObjects());
+		//view->DrawNew();
 	}
 	delete dia;
 }

Modified: branches/Version135/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16507&path=/branches/Version135/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/scribusdoc.cpp (original)
+++ branches/Version135/Scribus/scribus/scribusdoc.cpp Fri Mar 25 21:57:58 2011
@@ -1363,7 +1363,26 @@
 			restoreMasterPageApplying(ss, isUndo);
 		else if (ss->contains("COPY_PAGE"))
 			restorePageCopy(ss, isUndo);
-
+		else if (ss->contains("PAGE_CHANGEPROPS"))
+		{
+			if (isUndo)
+			{
+				changePageMargins(ss->getDouble("OLD_PAGE_INITIALTOP"), ss->getDouble("OLD_PAGE_INITIALBOTTOM"), 
+						ss->getDouble("OLD_PAGE_INITIALLEFT"), ss->getDouble("OLD_PAGE_INITIALRIGHT"), 
+						ss->getDouble("OLD_PAGE_INITIALHEIGHT"), ss->getDouble("OLD_PAGE_INITIALWIDTH"), 
+						ss->getDouble("OLD_PAGE_HEIGHT"), ss->getDouble("OLD_PAGE_WIDTH"), ss->getInt("OLD_PAGE_ORIENTATION"),
+						ss->get("OLD_PAGE_SIZE"), ss->getInt("OLD_PAGE_MARGINPRESET"), ss->getBool("OLD_PAGE_MOVEOBJECTS"), ss->getInt("PAGE_NUM"), ss->getInt("OLD_PAGE_TYPE"));
+			}
+			else
+			{
+				changePageMargins(ss->getDouble("NEW_PAGE_INITIALTOP"), ss->getDouble("NEW_PAGE_INITIALBOTTOM"), 
+						ss->getDouble("NEW_PAGE_INITIALLEFT"), ss->getDouble("NEW_PAGE_INITIALRIGHT"), 
+						ss->getDouble("NEW_PAGE_INITIALHEIGHT"), ss->getDouble("NEW_PAGE_INITIALWIDTH"), 
+						ss->getDouble("NEW_PAGE_HEIGHT"), ss->getDouble("NEW_PAGE_WIDTH"), ss->getInt("NEW_PAGE_ORIENTATION"),
+						ss->get("NEW_PAGE_SIZE"), ss->getInt("NEW_PAGE_MARGINPRESET"), ss->getBool("OLD_PAGE_MOVEOBJECTS"), ss->getInt("PAGE_NUM"), ss->getInt("NEW_PAGE_TYPE"));
+			}
+		}
+				
 		if (layersUndo)
 		{
 			if (ScCore->usingGUI())
@@ -3390,7 +3409,7 @@
 }
 
 
-bool ScribusDoc::changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double height, const double width, const int orientation, const QString& pageSize, const int pageNumber, const int pageType)
+bool ScribusDoc::changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double height, const double width, const int orientation, const QString& pageSize, const int marginPreset, const bool moveObjects, const int pageNumber, const int pageType)
 {
 	bool retVal=true;
 	if (pageNumber==-1)
@@ -3404,6 +3423,39 @@
 			retVal=false;
 		else
 		{
+			QRectF pagebox(currentPage()->xOffset(), currentPage()->yOffset(), qMax( currentPage()->width(), width), qMax(currentPage()->height(), height));
+			if (UndoManager::undoEnabled())
+			{
+				SimpleState *ss = new SimpleState(Um::ChangePageProps);//, QString("%1").arg(pageNumber), Um::IPage);
+				ss->set("PAGE_CHANGEPROPS", "page_changeprops");
+				ss->set("PAGE_NUM", pageNumber);
+				ss->set("OLD_PAGE_INITIALTOP", currentPage()->initialMargins.Top);
+				ss->set("OLD_PAGE_INITIALBOTTOM", currentPage()->initialMargins.Bottom);
+				ss->set("OLD_PAGE_INITIALLEFT", currentPage()->initialMargins.Left);
+				ss->set("OLD_PAGE_INITIALRIGHT", currentPage()->initialMargins.Right);
+				ss->set("OLD_PAGE_INITIALHEIGHT", currentPage()->initialHeight());
+				ss->set("OLD_PAGE_INITIALWIDTH", currentPage()->initialWidth());
+				ss->set("OLD_PAGE_HEIGHT", currentPage()->height());
+				ss->set("OLD_PAGE_WIDTH", currentPage()->width());
+				ss->set("OLD_PAGE_ORIENTATION", currentPage()->PageOri);
+				ss->set("OLD_PAGE_SIZE", currentPage()->m_pageSize);
+				ss->set("OLD_PAGE_TYPE", currentPage()->LeftPg);
+				ss->set("OLD_PAGE_MARGINPRESET", currentPage()->marginPreset);
+				ss->set("OLD_PAGE_MOVEOBJECTS", moveObjects);
+				ss->set("NEW_PAGE_INITIALTOP", initialTop);
+				ss->set("NEW_PAGE_INITIALBOTTOM", initialBottom);
+				ss->set("NEW_PAGE_INITIALLEFT", initialLeft);
+				ss->set("NEW_PAGE_INITIALRIGHT", initialRight);
+				ss->set("NEW_PAGE_INITIALHEIGHT", initialHeight);
+				ss->set("NEW_PAGE_INITIALWIDTH", initialWidth);
+				ss->set("NEW_PAGE_HEIGHT", height);
+				ss->set("NEW_PAGE_WIDTH", width);
+				ss->set("NEW_PAGE_ORIENTATION", orientation);
+				ss->set("NEW_PAGE_SIZE", pageSize);
+				ss->set("NEW_PAGE_TYPE", pageType);
+				ss->set("NEW_PAGE_MARGINPRESET", marginPreset);
+				undoManager->action(this, ss);
+			}
 			//set the current page's values
 			currentPage()->initialMargins.Top = initialTop;
 			currentPage()->initialMargins.Bottom = initialBottom;
@@ -3416,6 +3468,10 @@
 			currentPage()->PageOri = orientation;
 			currentPage()->m_pageSize = pageSize;
 			currentPage()->LeftPg = pageType;
+			currentPage()->marginPreset = marginPreset;
+			reformPages(moveObjects);
+			invalidateRegion(pagebox);
+			regionsChanged()->update(pagebox);
 			changed();
 		}
 	}

Modified: branches/Version135/Scribus/scribus/scribusdoc.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16507&path=/branches/Version135/Scribus/scribus/scribusdoc.h
==============================================================================
--- branches/Version135/Scribus/scribus/scribusdoc.h (original)
+++ branches/Version135/Scribus/scribus/scribusdoc.h Fri Mar 25 21:57:58 2011
@@ -564,7 +564,7 @@
 	/**
 	 * @brief Set the page margins. Current code uses current page only, also provide a (currently, TODO) option for this.
 	 */
-	bool changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double Height, const double width, const int orientation, const QString& pageSize, const int pageNumber=-1, const int pageType = 0);
+	bool changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double Height, const double width, const int orientation, const QString& pageSize, const int marginPreset, const bool moveObjects, const int pageNumber=-1, const int pageType = 0);
 	/**
 	 * @brief Recalculate the colors after CMS settings change. Update the items in the doc accordingly.
 	 */

Modified: branches/Version135/Scribus/scribus/undomanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16507&path=/branches/Version135/Scribus/scribus/undomanager.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/undomanager.cpp (original)
+++ branches/Version135/Scribus/scribus/undomanager.cpp Fri Mar 25 21:57:58 2011
@@ -916,7 +916,7 @@
 	UndoManager::ObjectFrame        = tr("Text flows around the frame");
 	UndoManager::BoundingBox        = tr("Text flows around bounding box");
 	UndoManager::ContourLine        = tr("Text flows around contour line");
-	UndoManager::ImageClip        = tr("Text flows around image clipping path");
+	UndoManager::ImageClip          = tr("Text flows around image clipping path");
 	UndoManager::NoTextFlow         = tr("No text flow");
 	UndoManager::NoObjectFrame      = tr("No object frame");
 	UndoManager::NoBoundingBox      = tr("No bounding box");
@@ -935,8 +935,9 @@
 	UndoManager::AddPages           = tr("Add pages");
 	UndoManager::DeletePage         = tr("Delete page");
 	UndoManager::DeletePages        = tr("Delete pages");
+	UndoManager::ChangePageProps    = tr("Change page properties");
 	UndoManager::AddLayer           = tr("Add layer");
-	UndoManager::DuplicateLayer	= tr("Duplicate layer %1");
+	UndoManager::DuplicateLayer	    = tr("Duplicate layer %1");
 	UndoManager::DeleteLayer        = tr("Delete layer");
 	UndoManager::RenameLayer        = tr("Rename layer");
 	UndoManager::RaiseLayer         = tr("Raise layer");
@@ -1146,6 +1147,7 @@
 QString UndoManager::AddPages           = "";
 QString UndoManager::DeletePage         = "";
 QString UndoManager::DeletePages        = "";
+QString UndoManager::ChangePageProps    = "";
 QString UndoManager::AddLayer           = "";
 QString UndoManager::DuplicateLayer     = "";
 QString UndoManager::DeleteLayer        = "";

Modified: branches/Version135/Scribus/scribus/undomanager.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16507&path=/branches/Version135/Scribus/scribus/undomanager.h
==============================================================================
--- branches/Version135/Scribus/scribus/undomanager.h (original)
+++ branches/Version135/Scribus/scribus/undomanager.h Fri Mar 25 21:57:58 2011
@@ -561,6 +561,7 @@
 	static QString AddPages;
 	static QString DeletePage;
 	static QString DeletePages;
+	static QString ChangePageProps;
 	static QString AddLayer;
 	static QString DuplicateLayer;
 	static QString DeleteLayer;




More information about the scribus-commit mailing list