r14295 by jghali - 8575, grouping object on a different layer makes some / all other objects invisible : - when grouping objects, create layer on same layer as items, was possibly not the case before - check that all objects belong to a common layer before allowing user to group them

scribus-commit scribus-commit at lists.scribus.net
Sun Nov 15 03:45:31 CET 2009


Revision: 14295
Author: jghali
Date: 2009-11-14T18:42:52.828233Z
Commit message: 8575, grouping object on a different layer makes some / all other objects invisible :
- when grouping objects, create layer on same layer as items, was possibly not the case before
- check that all objects belong to a common layer before allowing user to group them

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

Diffs:
Index: scribus/selection.h
===================================================================
--- scribus/selection.h	(revision 14294)
+++ scribus/selection.h	(revision 14295)
@@ -148,6 +148,12 @@
 		//!\brief Test to see if all items in the selection are the same typedef
 		bool itemsAreSameType() const;
 
+		/**
+		 * \brief get the layer ID of items in the selection
+		 * @return the layer ID or -1 if items do not belong to the same layer
+		 */
+		int objectsLayer(void) const;
+
 		bool signalsDelayed(void);
 		void delaySignalsOn(void);
 		void delaySignalsOff(void);
Index: scribus/selection.cpp
===================================================================
--- scribus/selection.cpp	(revision 14294)
+++ scribus/selection.cpp	(revision 14295)
@@ -481,8 +481,8 @@
 		return true;
 	if (m_SelList.isEmpty())
 		return false;
-	SelectionList::ConstIterator it=m_SelList.begin();
-	SelectionList::ConstIterator itend=m_SelList.end();
+	SelectionList::ConstIterator it = m_SelList.begin();
+	SelectionList::ConstIterator itend = m_SelList.end();
 	PageItem::ItemType itemType = (*it)->itemType();
 	for ( ; it!=itend ; ++it)
 	{
@@ -494,6 +494,22 @@
 	return true;
 }
 
+int Selection::objectsLayer(void) const
+{
+	if (m_SelList.isEmpty())
+		return -1;
+	int layerID = m_SelList.at(0)->LayerNr;
+	for (int i = 1; i < m_SelList.count(); ++i)
+	{
+		if (m_SelList.at(i)->LayerNr != layerID)
+		{
+			layerID = -1;
+			break;
+		}
+	}
+	return layerID;
+}
+
 bool Selection::signalsDelayed(void)
 {
 	return (m_isGUISelection && (m_delaySignals > 0));
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp	(revision 14294)
+++ scribus/scribus.cpp	(revision 14295)
@@ -3206,7 +3206,11 @@
 			else
 				isGroup = false;
 		}
-		scrActions["itemGroup"]->setEnabled(!isGroup);
+		// It is possible to select objects on different layer using
+		// document outline palette. We need to check selected objects
+		// are on a common layer before allowing user to group them
+		bool objectsOnSameLayer = (doc->m_Selection->objectsLayer() != -1);
+		scrActions["itemGroup"]->setEnabled(!isGroup && objectsOnSameLayer);
 		scrActions["itemCombinePolygons"]->setEnabled(hPoly);
 		if (docSelectionCount == 2)
 		{
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(revision 14294)
+++ scribus/scribusdoc.cpp	(revision 14295)
@@ -9965,6 +9965,9 @@
 		Selection* itemSelection = (customSelection!=0) ? customSelection : m_Selection;
 		if (itemSelection->count() < 1)
 			return;
+		int objectsLayer = itemSelection->objectsLayer();
+		if (objectsLayer == -1)
+			return;
 		PageItem *currItem;
 		PageItem* bb;
 		double x, y, w, h;
@@ -10062,12 +10065,13 @@
 		PageItem *high = Items->at(highestItem);
 		undoManager->setUndoEnabled(false);
 		int z = itemAdd(PageItem::Polygon, PageItem::Rectangle, gx, gy, gw, gh, 0, toolSettings.dBrush, toolSettings.dPen, true);
-		PageItem *neu = Items->takeAt(z);
-		Items->insert(lowestItem, neu);
-		neu->setItemName( tr("Group%1").arg(GroupCounter));
-		neu->AutoName = false;
-		neu->isGroupControl = true;
-		neu->groupsLastItem = high;
+		PageItem *groupItem = Items->takeAt(z);
+		Items->insert(lowestItem, groupItem);
+		groupItem->setItemName( tr("Group%1").arg(GroupCounter));
+		groupItem->AutoName = false;
+		groupItem->isGroupControl = true;
+		groupItem->groupsLastItem = high;
+		groupItem->LayerNr = objectsLayer;
 		undoManager->setUndoEnabled(true);
 
 		QMap<int, uint> ObjOrder;
@@ -10085,7 +10089,7 @@
 		}
 
 		renumberItemsInListOrder();
-		itemSelection->prependItem(neu);
+		itemSelection->prependItem(groupItem);
 		selectedItemCount=itemSelection->count();
 		SimpleState *ss = new SimpleState(Um::Group, tooltip);
 		ss->set("GROUP", "group");




More information about the scribus-commit mailing list