r16509 by craig - #2338: Allow undo/redo of Manage Page Properties, remove some old commented out code from scribusview

scribus-commit scribus-commit at lists.scribus.net
Fri Mar 25 23:28:00 CET 2011


Author: craig
Date: Fri Mar 25 22:28:00 2011
New Revision: 16509

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16509
Log:
#2338: Allow undo/redo of Manage Page Properties, remove some old commented out code from scribusview

Modified:
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h
    trunk/Scribus/scribus/scribusview.cpp
    trunk/Scribus/scribus/undomanager.cpp
    trunk/Scribus/scribus/undomanager.h

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16509&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Fri Mar 25 22:28:00 2011
@@ -6855,20 +6855,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: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16509&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Fri Mar 25 22:28:00 2011
@@ -1534,7 +1534,25 @@
 			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())
@@ -3858,7 +3876,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)
@@ -3872,6 +3890,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()->orientation());
+				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;
@@ -3884,6 +3935,10 @@
 			currentPage()->setOrientation(orientation);
 			currentPage()->m_pageSize = pageSize;
 			currentPage()->LeftPg = pageType;
+			currentPage()->marginPreset = marginPreset;
+			reformPages(moveObjects);
+			invalidateRegion(pagebox);
+			regionsChanged()->update(pagebox);
 			changed();
 		}
 	}

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16509&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Fri Mar 25 22:28:00 2011
@@ -659,7 +659,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: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16509&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Fri Mar 25 22:28:00 2011
@@ -1560,84 +1560,6 @@
 	emit DocChanged();
 }
 
-/*
-void ScribusView::Reset1Control()
-{
-	Doc->nodeEdit.reset1Control(Doc->m_Selection->itemAt(0));
-}
-
-void ScribusView::ResetControl()
-{
-	PageItem *currItem = Doc->m_Selection->itemAt(0);
-	Doc->nodeEdit.resetControl(currItem);
-}
-*/
-
-/*
-//CB-->Doc
-void ScribusView::moveGroup(double x, double y, bool fromMP, Selection* customSelection)
-{
-	Selection* itemSelection = (customSelection!=0) ? customSelection : Doc->m_Selection;
-	Q_ASSERT(itemSelection!=0);
-	uint selectedItemCount=itemSelection->count();
-	if (selectedItemCount == 0)
-		return;
-
-	if (!_groupTransactionStarted && selectedItemCount > 1)
-	{
-		QString tooltip = Um::ItemsInvolved + "\n";
-		for (uint i = 0; i < selectedItemCount; ++i)
-			tooltip += "\t" + itemSelection->itemAt(i)->getUName() + "\n";
-		undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup,
-									  Um::Move, tooltip, Um::IMove);
-		_groupTransactionStarted = true;
-	}
-
-	Doc->moveGroup(x, y, fromMP, itemSelection);
-}
-
-//CB-->Doc
-void ScribusView::RotateGroup(double win)
-{
-	if (!_groupTransactionStarted && Doc->m_Selection->count() > 1)
-	{
-		QString tooltip = Um::ItemsInvolved + "\n";
-		for (int i = 0; i < Doc->m_Selection->count(); ++i)
-			tooltip += "\t" + Doc->m_Selection->itemAt(i)->getUName() + "\n";
-		undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup,
-									  Um::Rotate, tooltip, Um::IRotate);
-		_groupTransactionStarted = true;
-	}
-
-	Doc->rotateGroup(win, RCenter);
-}
-
-
-
-void ScribusView::scaleGroup(double scx, double scy, bool scaleText, Selection* customSelection)
-{
-	Selection* itemSelection = (customSelection!=0) ? customSelection : Doc->m_Selection;
-	Q_ASSERT(itemSelection!=0);
-	uint selectedItemCount=itemSelection->count();
-	if (selectedItemCount == 0)
-		return;
-
-	if (!_groupTransactionStarted && selectedItemCount > 1)
-	{
-		QString tooltip = Um::ItemsInvolved + "\n";
-		for (uint i = 0; i < selectedItemCount; ++i)
-			tooltip += "\t" + itemSelection->itemAt(i)->getUName() + "\n";
-		undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup,
-									  Um::Resize, tooltip, Um::IResize);
-		_groupTransactionStarted = true;
-	}
-
-	Doc->scaleGroup(scx, scy, scaleText, itemSelection);
-	emit DocChanged();
-}
-*/
-
-
 bool ScribusView::slotSetCurs(int x, int y)
 {
 	PageItem *currItemGeneric;
@@ -1645,9 +1567,6 @@
 	{
 		if (!((currItemGeneric->asTextFrame()) || (currItemGeneric->asImageFrame())))
 			return false;
-		// unsed by gcc warning - PV
-		//int xP = qRound(x/m_canvas->scale() + Doc->minCanvasCoordinate.x());
-		//int yP = qRound(y/m_canvas->scale() + Doc->minCanvasCoordinate.y());
 		if (currItemGeneric->asImageFrame())
 			return true;
 		PageItem_TextFrame *currItem=currItemGeneric->asTextFrame();

Modified: trunk/Scribus/scribus/undomanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16509&path=/trunk/Scribus/scribus/undomanager.cpp
==============================================================================
--- trunk/Scribus/scribus/undomanager.cpp (original)
+++ trunk/Scribus/scribus/undomanager.cpp Fri Mar 25 22:28:00 2011
@@ -931,6 +931,7 @@
 	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::DeleteLayer        = tr("Delete layer");
@@ -1140,6 +1141,7 @@
 QString UndoManager::AddPages           = "";
 QString UndoManager::DeletePage         = "";
 QString UndoManager::DeletePages        = "";
+QString UndoManager::ChangePageProps    = "";
 QString UndoManager::AddLayer           = "";
 QString UndoManager::DuplicateLayer     = "";
 QString UndoManager::DeleteLayer        = "";

Modified: trunk/Scribus/scribus/undomanager.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16509&path=/trunk/Scribus/scribus/undomanager.h
==============================================================================
--- trunk/Scribus/scribus/undomanager.h (original)
+++ trunk/Scribus/scribus/undomanager.h Fri Mar 25 22:28:00 2011
@@ -559,6 +559,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