r21515 by jghali - improve text typing speed when editing long text chains

scribus-commit scribus-commit at lists.scribus.net
Tue Nov 15 21:51:15 UTC 2016


Author: jghali
Date: Tue Nov 15 21:51:15 2016
New Revision: 21515

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21515
Log:
improve text typing speed when editing long text chains

Modified:
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/pageitem_textframe.h
    trunk/Scribus/scribus/text/storytext.cpp
    trunk/Scribus/scribus/text/storytext.h

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21515&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp	Tue Nov 15 21:51:15 2016
@@ -80,7 +80,7 @@
 	unicodeInputString = "";
 	m_origAnnotPos = QRectF(xPos(), yPos(), width(), height());
 	verticalAlign = 0;
-	connect(&itemText,SIGNAL(changed()), this, SLOT(slotInvalidateLayout()));
+	connect(&itemText,SIGNAL(changed(int, int)), this, SLOT(slotInvalidateLayout(int, int)));
 }
 
 PageItem_TextFrame::PageItem_TextFrame(const PageItem & p) : PageItem(p)
@@ -93,7 +93,7 @@
 	m_notesFramesMap.clear();
 	m_origAnnotPos = QRectF(xPos(), yPos(), width(), height());
 	verticalAlign = 0;
-	connect(&itemText,SIGNAL(changed()), this, SLOT(slotInvalidateLayout()));
+	connect(&itemText,SIGNAL(changed(int, int)), this, SLOT(slotInvalidateLayout(int, int)));
 }
 
 static QRegion itemShape(PageItem* docItem, double xOffset, double yOffset)
@@ -3058,9 +3058,27 @@
 	}
 }
 
-void PageItem_TextFrame::slotInvalidateLayout()
+void PageItem_TextFrame::slotInvalidateLayout(int firstItem, int endItem)
 {
-	invalidateLayout(true);
+	PageItem* firstFrame = firstInChain();
+	firstItem = itemText.prevParagraph(firstItem);
+
+	PageItem_TextFrame* firstInvalid = dynamic_cast<PageItem_TextFrame*>(firstFrame);
+	while (firstInvalid)
+	{
+		if (firstInvalid->invalid)
+			break;
+		if (firstInvalid->firstChar <= firstItem && firstItem <= firstInvalid->MaxChars)
+			break;
+		firstInvalid = dynamic_cast<PageItem_TextFrame*>(firstInvalid->NextBox);
+	}
+
+	PageItem_TextFrame* invalidFrame = firstInvalid;
+	while (invalidFrame)
+	{
+		invalidFrame->invalid = true;
+		invalidFrame = dynamic_cast<PageItem_TextFrame*>(invalidFrame->NextBox);
+	}
 }
 
 bool PageItem_TextFrame::isValidChainFromBegin()

Modified: trunk/Scribus/scribus/pageitem_textframe.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21515&path=/trunk/Scribus/scribus/pageitem_textframe.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.h	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.h	Tue Nov 15 21:51:15 2016
@@ -122,7 +122,7 @@
 	QRectF m_origAnnotPos;
 	
 private slots:
-	void slotInvalidateLayout();
+	void slotInvalidateLayout(int firstItem, int endItem);
 
 public:
 	//for footnotes/endnotes

Modified: trunk/Scribus/scribus/text/storytext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21515&path=/trunk/Scribus/scribus/text/storytext.cpp
==============================================================================
--- trunk/Scribus/scribus/text/storytext.cpp	(original)
+++ trunk/Scribus/scribus/text/storytext.cpp	Tue Nov 15 21:51:15 2016
@@ -1700,8 +1700,7 @@
 			par->charStyleContext()->invalidate();
 	}
 	if (!signalsBlocked())
-		emit changed();
-	emit changed();
+		emit changed(firstItem, endItem);
 }
 
 

Modified: trunk/Scribus/scribus/text/storytext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21515&path=/trunk/Scribus/scribus/text/storytext.h
==============================================================================
--- trunk/Scribus/scribus/text/storytext.h	(original)
+++ trunk/Scribus/scribus/text/storytext.h	Tue Nov 15 21:51:15 2016
@@ -248,7 +248,7 @@
  	void invalidateAll();
 
 signals:
-		void changed();
+	void changed(int firstItem, int endItem);
 
 private:
  	ScText * item(uint index);




More information about the scribus-commit mailing list