r13852 by jghali - #8335, page import blocks scribus : improve page import speed when undo is enabled, not a complete fix, page import is still dead slow in that case

scribus-commit scribus-commit at lists.scribus.net
Wed Aug 26 05:36:35 CEST 2009


Revision: 13852
Author: jghali
Date: 2009-08-13T06:59:43.146123Z
Commit message: #8335, page import blocks scribus : improve page import speed when undo is enabled, not a complete fix, page import is still dead slow in that case

Changeset: 
M  /branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
M  /branches/Version135/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp

Diffs:
Index: scribus/plugins/fileloader/scribus13format/scribus13format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus13format/scribus13format.cpp	(revision 13851)
+++ scribus/plugins/fileloader/scribus13format/scribus13format.cpp	(revision 13852)
@@ -16,6 +16,7 @@
 #include "scribusview.h"
 #include "sctextstream.h"
 #include "sccolorengine.h"
+#include "undomanager.h"
 
 #include "units.h"
 #include "util.h"
@@ -2034,6 +2035,7 @@
 		currItem = doc->Items->at(z);
 		if (pagenr > -2) 
 			currItem->OwnPage = pagenr;
+		UndoManager::instance()->setUndoEnabled(false);
 		currItem->setImageXYScale(scx, scy);
 		currItem->setImageXYOffset(offsX, offsY);
 		currItem->Pfile     = Relative2Path(obj->attribute("PFILE"), baseDir);
@@ -2102,6 +2104,7 @@
 				doc->loadPict(currItem->Pfile, currItem, true);
 			}
 		}
+		UndoManager::instance()->setUndoEnabled(true);
 		break;
 	// OBSOLETE CR 2005-02-06
 	case PageItem::ItemType3:
@@ -2116,6 +2119,7 @@
 		currItem = doc->Items->at(z);
 		if (pagenr > -2) 
 			currItem->OwnPage = pagenr;
+		UndoManager::instance()->setUndoEnabled(false);
 		if ((obj->attribute("ANNOTATION", "0").toInt()) && (static_cast<bool>(obj->attribute("ANICON", "0").toInt())))
 		{
 			currItem->setImageXYScale(scx, scy);
@@ -2136,12 +2140,14 @@
 			currItem->AspectRatio = obj->attribute("RATIO", "0").toInt();
 		}
 		//currItem->convertTo(pt);
+		UndoManager::instance()->setUndoEnabled(true);
 		break;
 	case PageItem::TextFrame:
 		z = doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor, true);
 		currItem = doc->Items->at(z);
 		if (pagenr > -2) 
 			currItem->OwnPage = pagenr;
+		UndoManager::instance()->setUndoEnabled(false);
 		if ((obj->attribute("ANNOTATION", "0").toInt()) && (static_cast<bool>(obj->attribute("ANICON", "0").toInt())))
 		{
 			currItem->setImageXYScale(scx, scy);
@@ -2161,7 +2167,8 @@
 			currItem->ScaleType = obj->attribute("SCALETYPE", "1").toInt();
 			currItem->AspectRatio = obj->attribute("RATIO", "0").toInt();
 		}
-			//currItem->convertTo(pt);
+		//currItem->convertTo(pt);
+		UndoManager::instance()->setUndoEnabled(true);
 		break;
 	case PageItem::Line:
 		z = doc->itemAdd(PageItem::Line, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor2, true);
@@ -2186,6 +2193,8 @@
 		assert(false);
 		break;
 	}
+
+	UndoManager::instance()->setUndoEnabled(false);
 	currItem->FrameType = obj->attribute("FRTYPE", "0").toInt();
 	int startArrowIndex = obj->attribute("startArrowIndex", "0").toInt();
 	if ((startArrowIndex < 0) || (startArrowIndex > static_cast<int>(doc->arrowStyles.size())))
@@ -2534,6 +2543,7 @@
 	}
 	//currItem->setRedrawBounding();
 	//currItem->OwnPage = view->OnPage(currItem);
+	UndoManager::instance()->setUndoEnabled(true);
 	return currItem;
 }
 
Index: scribus/plugins/fileloader/scribus134format/scribus134format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus134format/scribus134format.cpp	(revision 13851)
+++ scribus/plugins/fileloader/scribus134format/scribus134format.cpp	(revision 13852)
@@ -9,7 +9,9 @@
 
 #include "../../formatidlist.h"
 #include "commonstrings.h"
+#include "hyphenator.h"
 #include "missing.h"
+#include "pageitem_latexframe.h"
 #include "prefsmanager.h"
 #include "scclocale.h"
 #include "scconfig.h"
@@ -19,8 +21,7 @@
 #include "sctextstream.h"
 #include "sccolorengine.h"
 #include "scribuscore.h"
-#include "hyphenator.h"
-#include "pageitem_latexframe.h"
+#include "undomanager.h"
 
 #include "units.h"
 #include "util.h"
@@ -2043,6 +2044,7 @@
 	case PageItem::LatexFrame: /*Everything that is valid for image frames is also valid for latex frames*/
 		z = doc->itemAdd(pt, PageItem::Unspecified, x, y, w, h, 1, doc->toolSettings.dBrushPict, CommonStrings::None, true);
 		currItem = doc->Items->at(z);
+		UndoManager::instance()->setUndoEnabled(false);
 		if (pagenr > -2) 
 			currItem->OwnPage = pagenr;
 		currItem->setImageXYScale(scx, scy);
@@ -2178,6 +2180,7 @@
 				doc->loadPict(currItem->Pfile, currItem, true);
 			}
 		}
+		UndoManager::instance()->setUndoEnabled(true);
 		break;
 	// OBSOLETE CR 2005-02-06
 	case PageItem::ItemType3:
@@ -2192,6 +2195,7 @@
 		currItem = doc->Items->at(z);
 		if (pagenr > -2) 
 			currItem->OwnPage = pagenr;
+		UndoManager::instance()->setUndoEnabled(false);
 		if ((obj->attribute("ANNOTATION", "0").toInt()) && (static_cast<bool>(obj->attribute("ANICON", "0").toInt())))
 		{
 			currItem->setImageXYScale(scx, scy);
@@ -2211,6 +2215,7 @@
 			currItem->ScaleType = obj->attribute("SCALETYPE", "1").toInt();
 			currItem->AspectRatio = obj->attribute("RATIO", "0").toInt();
 		}
+		UndoManager::instance()->setUndoEnabled(true);
 		//currItem->convertTo(pt);
 		break;
 	case PageItem::TextFrame:
@@ -2218,6 +2223,7 @@
 		currItem = doc->Items->at(z);
 		if (pagenr > -2) 
 			currItem->OwnPage = pagenr;
+		UndoManager::instance()->setUndoEnabled(false);
 		if ((obj->attribute("ANNOTATION", "0").toInt()) && (static_cast<bool>(obj->attribute("ANICON", "0").toInt())))
 		{
 			currItem->setImageXYScale(scx, scy);
@@ -2237,7 +2243,8 @@
 			currItem->ScaleType = obj->attribute("SCALETYPE", "1").toInt();
 			currItem->AspectRatio = obj->attribute("RATIO", "0").toInt();
 		}
-			//currItem->convertTo(pt);
+		UndoManager::instance()->setUndoEnabled(true);
+		//currItem->convertTo(pt);
 		break;
 	case PageItem::Line:
 		z = doc->itemAdd(PageItem::Line, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor2, true);
@@ -2261,6 +2268,8 @@
 		Q_ASSERT(false);
 		break;
 	}
+
+	UndoManager::instance()->setUndoEnabled(false);
 	currItem->FrameType = obj->attribute("FRTYPE", "0").toInt();
 	int startArrowIndex = obj->attribute("startArrowIndex", "0").toInt();
 	if ((startArrowIndex < 0) || (startArrowIndex > static_cast<int>(doc->arrowStyles.size())))
@@ -2659,6 +2668,7 @@
 		}
 //		currItem->updateGradientVectors();
 	}
+	UndoManager::instance()->setUndoEnabled(true);
 	//currItem->setRedrawBounding();
 	//currItem->OwnPage = view->OnPage(currItem);
 	return currItem;




More information about the scribus-commit mailing list