r14405 by jghali - fix sluggish selection when selecting multiple items with document outline palette showed

scribus-commit scribus-commit at lists.scribus.net
Sun Dec 13 02:00:30 CET 2009


Revision: 14405
Author: jghali
Date: 2009-12-12T13:54:41.787579Z
Commit message: fix sluggish selection when selecting multiple items with document outline palette showed

Changeset: 
M  /trunk/Scribus/scribus/canvasmode_normal.cpp
M  /trunk/Scribus/scribus/ui/outlinepalette.cpp
M  /trunk/Scribus/scribus/scribusdoc.cpp
M  /trunk/Scribus/scribus/ui/outlinepalette.h
M  /trunk/Scribus/scribus/scribusdoc.h

Diffs:
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(revision 14404)
+++ scribus/scribusdoc.cpp	(revision 14405)
@@ -9115,6 +9115,18 @@
 	endAlign();
 }
 
+void ScribusDoc::beginUpdate()
+{
+	m_docUpdater->beginUpdate();
+	m_updateManager.setUpdatesEnabled(false);
+}
+
+void ScribusDoc::endUpdate()
+{
+	m_updateManager.setUpdatesEnabled(true);
+	m_docUpdater->endUpdate();
+}
+
 void ScribusDoc::itemSelection_SwapLeft()
 {
 	if (!startAlign())
Index: scribus/scribusdoc.h
===================================================================
--- scribus/scribusdoc.h	(revision 14404)
+++ scribus/scribusdoc.h	(revision 14405)
@@ -902,6 +902,11 @@
 	//! \brief Set rotation mode
 	void RotMode(const int& val);
 
+	//! \brief Fonctions which avoid doc updater and update manager to send too much
+	// unncessary signals when doing updates on multiple items
+	void beginUpdate();
+	void endUpdate();
+
 protected:
 	void addSymbols();
 	bool m_hasGUI;
Index: scribus/ui/outlinepalette.h
===================================================================
--- scribus/ui/outlinepalette.h	(revision 14404)
+++ scribus/ui/outlinepalette.h	(revision 14405)
@@ -40,6 +40,9 @@
 public:
 	OutlineWidget(QWidget* parent);
 	~OutlineWidget() {};
+
+	void selectItems(QList<QTreeWidgetItem*> items);
+
 protected:
 	bool viewportEvent(QEvent *event);
 };
Index: scribus/ui/outlinepalette.cpp
===================================================================
--- scribus/ui/outlinepalette.cpp	(revision 14404)
+++ scribus/ui/outlinepalette.cpp	(revision 14405)
@@ -54,6 +54,20 @@
 {
 }
 
+void OutlineWidget::selectItems(QList<QTreeWidgetItem*> items)
+{
+	QItemSelection itemSelection;
+	for (int i = 0; i < items.count(); ++i)
+	{
+		QModelIndex index = this->indexFromItem(items.at(i));
+		if (index.isValid())
+		{
+			itemSelection.select(index, index);
+		}
+	}
+	selectionModel()->select(itemSelection, QItemSelectionModel::Select);
+}
+
 bool OutlineWidget::viewportEvent(QEvent *event)
 {
 	if (event->type() == QEvent::ToolTip)
@@ -390,14 +404,16 @@
 	reportDisplay->clearSelection();
 	if (currDoc->m_Selection->count() > 0)
 	{
+		QList<QTreeWidgetItem*> itemSelection;
 		uint docSelectionCount = currDoc->m_Selection->count();
 		for (uint a = 0; a < docSelectionCount; a++)
 		{
 			PageItem *item = currDoc->m_Selection->itemAt(a);
 			QTreeWidgetItem *retVal = getListItem(item->OwnPage, item->ItemNr);
 			if (retVal != 0)
-				retVal->setSelected(true);
+				itemSelection.append(retVal);
 		}
+		reportDisplay->selectItems(itemSelection);
 	}
 	else
 	{
Index: scribus/canvasmode_normal.cpp
===================================================================
--- scribus/canvasmode_normal.cpp	(revision 14404)
+++ scribus/canvasmode_normal.cpp	(revision 14405)
@@ -1213,11 +1213,13 @@
 		m_doc->m_Selection->delaySignalsOff();
 		if (m_doc->m_Selection->count() > 1)
 		{
+			m_doc->beginUpdate();
 			for (int aa = 0; aa < m_doc->m_Selection->count(); ++aa)
 			{
 				PageItem *bb = m_doc->m_Selection->itemAt(aa);
 				bb->update();
 			}
+			m_doc->endUpdate();
 			m_doc->m_Selection->setGroupRect();
 			double x, y, w, h;
 			m_doc->m_Selection->getGroupRect(&x, &y, &w, &h);




More information about the scribus-commit mailing list