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

scribus-commit scribus-commit at lists.scribus.net
Sun Dec 13 01:55:30 CET 2009


Revision: 14404
Author: jghali
Date: 2009-12-12T13:53:45.862768Z
Commit message: fix sluggish selection when selecting multiple items with outline palette showed

Changeset: 
M  /branches/Version135/Scribus/scribus/canvasmode_normal.cpp
M  /branches/Version135/Scribus/scribus/outlinepalette.cpp
M  /branches/Version135/Scribus/scribus/scribusdoc.cpp
M  /branches/Version135/Scribus/scribus/outlinepalette.h
M  /branches/Version135/Scribus/scribus/scribusdoc.h

Diffs:
Index: scribus/outlinepalette.cpp
===================================================================
--- scribus/outlinepalette.cpp	(revision 14403)
+++ scribus/outlinepalette.cpp	(revision 14404)
@@ -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)
@@ -385,14 +399,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/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(revision 14403)
+++ scribus/scribusdoc.cpp	(revision 14404)
@@ -8855,7 +8855,18 @@
 	endAlign();
 }
 
+void ScribusDoc::beginUpdate()
+{
+	m_docUpdater->beginUpdate();
+	m_updateManager.setUpdatesEnabled(false);
+}
 
+void ScribusDoc::endUpdate()
+{
+	m_updateManager.setUpdatesEnabled(true);
+	m_docUpdater->endUpdate();
+}
+
 void ScribusDoc::changed()
 {
 	setModified(true);
Index: scribus/outlinepalette.h
===================================================================
--- scribus/outlinepalette.h	(revision 14403)
+++ scribus/outlinepalette.h	(revision 14404)
@@ -40,6 +40,9 @@
 public:
 	OutlineWidget(QWidget* parent);
 	~OutlineWidget() {};
+
+	void selectItems(QList<QTreeWidgetItem*> items);
+
 protected:
 	bool viewportEvent(QEvent *event);
 };
Index: scribus/scribusdoc.h
===================================================================
--- scribus/scribusdoc.h	(revision 14403)
+++ scribus/scribusdoc.h	(revision 14404)
@@ -890,6 +890,11 @@
 	void scaleGroup(double scx, double scy, bool scaleText=true, Selection* customSelection = 0);
 	//! \brief Get a list of frames of certain type
 	QMap<PageItem*, QString> getDocItemNames(PageItem::ItemType itemType);
+
+	//! \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();
Index: scribus/canvasmode_normal.cpp
===================================================================
--- scribus/canvasmode_normal.cpp	(revision 14403)
+++ scribus/canvasmode_normal.cpp	(revision 14404)
@@ -1203,11 +1203,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