r17062 by fschmid - Fixed crash when using the item lower, item raise, item to top and item to bottom functions when items are in a group. Also moved the code from ScribusView to ScribusDoc class.

scribus-commit scribus-commit at lists.scribus.net
Tue Dec 6 22:37:29 UTC 2011


Author: fschmid
Date: Tue Dec  6 22:37:29 2011
New Revision: 17062

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17062
Log:
Fixed crash when using the item lower, item raise, item to top and item to bottom functions when items are in a group. Also moved the code from ScribusView to ScribusDoc class.

Modified:
    trunk/Scribus/scribus/actionmanager.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h
    trunk/Scribus/scribus/scribusview.cpp
    trunk/Scribus/scribus/scribusview.h
    trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp
    trunk/Scribus/scribus/ui/propertiespalette_xyz.h

Modified: trunk/Scribus/scribus/actionmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17062&path=/trunk/Scribus/scribus/actionmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/actionmanager.cpp (original)
+++ trunk/Scribus/scribus/actionmanager.cpp Tue Dec  6 22:37:29 2011
@@ -1117,6 +1117,10 @@
 	disconnect( (*scrActions)["itemsUnWeld"], 0, 0, 0);
 	disconnect( (*scrActions)["itemWeld"], 0, 0, 0);
 	disconnect( (*scrActions)["itemEditWeld"], 0, 0, 0);
+	disconnect( (*scrActions)["itemLowerToBottom"], 0, 0, 0);
+	disconnect( (*scrActions)["itemRaiseToTop"], 0, 0, 0);
+	disconnect( (*scrActions)["itemLower"], 0, 0, 0);
+	disconnect( (*scrActions)["itemRaise"], 0, 0, 0);
 
 
 }
@@ -1153,6 +1157,10 @@
 	connect( (*scrActions)["itemsUnWeld"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_UnWeld()) );
 	connect( (*scrActions)["itemWeld"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_Weld()) );
 	connect( (*scrActions)["itemEditWeld"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_EditWeld()) );
+	connect( (*scrActions)["itemLowerToBottom"], SIGNAL(triggered()), currDoc, SLOT(sendItemSelectionToBack()) );
+	connect( (*scrActions)["itemRaiseToTop"], SIGNAL(triggered()), currDoc, SLOT(bringItemSelectionToFront()) );
+	connect( (*scrActions)["itemLower"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_LowerItem()) );
+	connect( (*scrActions)["itemRaise"], SIGNAL(triggered()), currDoc, SLOT(itemSelection_RaiseItem()) );
 }
 
 void ActionManager::disconnectNewViewActions()
@@ -1160,13 +1168,10 @@
 	disconnect( (*scrActions)["viewFitPreview"], 0, 0, 0);
 	disconnect( (*scrActions)["toolsZoomIn"], 0, 0, 0);
 	disconnect( (*scrActions)["toolsZoomOut"], 0, 0, 0);
-	disconnect( (*scrActions)["itemLowerToBottom"], 0, 0, 0);
 	disconnect( (*scrActions)["itemImageIsVisible"], 0, 0, 0);
 	disconnect( (*scrActions)["itemPreviewLow"], SIGNAL(triggeredData(int)), 0, 0 );
 	disconnect( (*scrActions)["itemPreviewNormal"], SIGNAL(triggeredData(int)), 0,0 );
 	disconnect( (*scrActions)["itemPreviewFull"], SIGNAL(triggeredData(int)), 0, 0 );
-	disconnect( (*scrActions)["itemRaise"], 0, 0, 0);
-	disconnect( (*scrActions)["itemLower"], 0, 0, 0);
 	disconnect( (*scrActions)["itemConvertToBezierCurve"], 0, 0, 0);
 	disconnect( (*scrActions)["itemConvertToImageFrame"], 0, 0, 0);
 	disconnect( (*scrActions)["itemConvertToOutlines"], 0, 0, 0);
@@ -1184,10 +1189,6 @@
 	connect( (*scrActions)["viewFitPreview"], SIGNAL(triggered()), currView, SLOT(togglePreview()) );
 	connect( (*scrActions)["toolsZoomIn"], SIGNAL(triggered()) , currView, SLOT(slotZoomIn()) );
 	connect( (*scrActions)["toolsZoomOut"], SIGNAL(triggered()) , currView, SLOT(slotZoomOut()) );
-	connect( (*scrActions)["itemLowerToBottom"], SIGNAL(triggered()), currView, SLOT(ToBack()) );
-	connect( (*scrActions)["itemRaiseToTop"], SIGNAL(triggered()), currView, SLOT(ToFront()) );
-	connect( (*scrActions)["itemRaise"], SIGNAL(triggered()), currView, SLOT(RaiseItem()) );
-	connect( (*scrActions)["itemLower"], SIGNAL(triggered()), currView, SLOT(LowerItem()) );
 	connect( (*scrActions)["itemConvertToBezierCurve"], SIGNAL(triggered()), currView, SLOT(ToBezierFrame()) );
 	connect( (*scrActions)["itemConvertToImageFrame"], SIGNAL(triggered()), currView, SLOT(ToPicFrame()) );
 	connect( (*scrActions)["itemConvertToOutlines"], SIGNAL(triggered()), currView, SLOT(TextToPath()) );

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17062&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Tue Dec  6 22:37:29 2011
@@ -3142,13 +3142,26 @@
 			scrActions["itemMulDuplicate"]->setEnabled(setter);
 			scrActions["itemTransform"]->setEnabled(setter);
 			scrActions["itemDelete"]->setEnabled(true);
-			scrActions["itemLowerToBottom"]->setEnabled(setter);
-			scrActions["itemRaiseToTop"]->setEnabled(setter);
-			scrActions["itemRaise"]->setEnabled(setter);
-			scrActions["itemLower"]->setEnabled(setter);
 //			scrActions["itemSendToScrapbook"]->setEnabled(setter);
 			scrMenuMgr->setMenuEnabled("itemSendToScrapbook", setter);
 			scrActions["itemSendToPattern"]->setEnabled(setter);
+			if (docSelectionCount > 1)
+			{
+				bool haveSameParent = true;
+				PageItem *firstItem = doc->m_Selection->itemAt(0);
+				for (uint a = 1; a < docSelectionCount; ++a)
+				{
+					if (doc->m_Selection->itemAt(a)->Parent != firstItem->Parent)
+					{
+						haveSameParent = false;
+						break;
+					}
+				}
+				scrActions["itemRaise"]->setEnabled(haveSameParent);
+				scrActions["itemLower"]->setEnabled(haveSameParent);
+				scrActions["itemRaiseToTop"]->setEnabled(haveSameParent);
+				scrActions["itemLowerToBottom"]->setEnabled(haveSameParent);
+			}
 		}
 		scrActions["itemLock"]->setChecked(currItem->locked());
 		scrActions["itemLockSize"]->setChecked(currItem->sizeLocked());

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17062&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Tue Dec  6 22:37:29 2011
@@ -6338,63 +6338,261 @@
 	}
 }
 
-
-
-bool ScribusDoc::sendItemSelectionToBack()
-{
-	uint docSelectionCount=m_Selection->count();
-	if ((Items->count() > 1) && (docSelectionCount != 0))
-	{
-		QMap<int, uint> ObjOrder;
-		PageItem *currItem;
-		for (uint c = 0; c < docSelectionCount; ++c)
+struct objOrdHelper
+{
+	int objNrSel;
+	PageItem* parent;
+};
+
+void ScribusDoc::sendItemSelectionToBack()
+{
+	int docSelectionCount = m_Selection->count();
+	if (docSelectionCount == 0)
+		return;
+	if (docSelectionCount > 1)
+	{
+		PageItem *firstItem = m_Selection->itemAt(0);
+		for (int a = 1; a < docSelectionCount; ++a)
+		{
+			if (m_Selection->itemAt(a)->Parent != firstItem->Parent)
+				return;
+		}
+	}
+	PageItem *currItem;
+	QMap<int, objOrdHelper> ObjOrder;
+	int d;
+	for (int c = 0; c < docSelectionCount; ++c)
+	{
+		objOrdHelper oHlp;
+		currItem = m_Selection->itemAt(c);
+		oHlp.objNrSel = c;
+		if (currItem->Parent != NULL)
+		{
+			if (currItem->Parent->asGroupFrame()->groupItemList.count() > 1)
+			{
+				d = currItem->Parent->asGroupFrame()->groupItemList.indexOf(currItem);
+				oHlp.parent = currItem->Parent;
+				ObjOrder.insert(d, oHlp);
+				currItem->Parent->asGroupFrame()->groupItemList.takeAt(d);
+			}
+		}
+		else
+		{
+			if (Items->count() > 1)
+			{
+				d = Items->indexOf(currItem);
+				oHlp.parent = NULL;
+				ObjOrder.insert(d, oHlp);
+				Items->takeAt(d);
+			}
+		}
+	}
+	QList<objOrdHelper> Oindex = ObjOrder.values();
+	for (int c = static_cast<int>(Oindex.count()-1); c > -1; c--)
+	{
+		objOrdHelper oHlp = Oindex[c];
+		if (oHlp.parent == NULL)
+			Items->prepend(m_Selection->itemAt(oHlp.objNrSel));
+		else
+			oHlp.parent->asGroupFrame()->groupItemList.prepend(m_Selection->itemAt(oHlp.objNrSel));
+	}
+	changed();
+	regionsChanged()->update(QRectF());
+	return;
+}
+
+void ScribusDoc::bringItemSelectionToFront()
+{
+	int docSelectionCount = m_Selection->count();
+	if (docSelectionCount == 0)
+		return;
+	if (docSelectionCount > 1)
+	{
+		PageItem *firstItem = m_Selection->itemAt(0);
+		for (int a = 1; a < docSelectionCount; ++a)
+		{
+			if (m_Selection->itemAt(a)->Parent != firstItem->Parent)
+				return;
+		}
+	}
+	PageItem *currItem;
+	QMap<int, objOrdHelper> ObjOrder;
+	int d;
+	for (int c = 0; c < docSelectionCount; ++c)
+	{
+		objOrdHelper oHlp;
+		currItem = m_Selection->itemAt(c);
+		oHlp.objNrSel = c;
+		if (currItem->Parent != NULL)
+		{
+			if (currItem->Parent->asGroupFrame()->groupItemList.count() > 1)
+			{
+				d = currItem->Parent->asGroupFrame()->groupItemList.indexOf(currItem);
+				oHlp.parent = currItem->Parent;
+				ObjOrder.insert(d, oHlp);
+				currItem->Parent->asGroupFrame()->groupItemList.takeAt(d);
+			}
+		}
+		else
+		{
+			if (Items->count() > 1)
+			{
+				d = Items->indexOf(currItem);
+				oHlp.parent = NULL;
+				ObjOrder.insert(d, oHlp);
+				Items->takeAt(d);
+			}
+		}
+	}
+	QList<objOrdHelper> Oindex = ObjOrder.values();
+	for (int c = 0; c <static_cast<int>(Oindex.count()); ++c)
+	{
+		objOrdHelper oHlp = Oindex[c];
+		if (oHlp.parent == NULL)
+			Items->append(m_Selection->itemAt(oHlp.objNrSel));
+		else
+			oHlp.parent->asGroupFrame()->groupItemList.append(m_Selection->itemAt(oHlp.objNrSel));
+	}
+	changed();
+	regionsChanged()->update(QRectF());
+	return;
+}
+
+void ScribusDoc::itemSelection_LowerItem()
+{
+	int docSelectionCount = m_Selection->count();
+	if (docSelectionCount == 0)
+		return;
+	if (docSelectionCount > 1)
+	{
+		PageItem *firstItem = m_Selection->itemAt(0);
+		for (int a = 1; a < docSelectionCount; ++a)
+		{
+			if (m_Selection->itemAt(a)->Parent != firstItem->Parent)
+				return;
+		}
+	}
+	QList<PageItem*> *itemList;
+	if (m_Selection->itemAt(0)->Parent == NULL)
+		itemList = Items;
+	else
+		itemList = &(m_Selection->itemAt(0)->Parent->asGroupFrame()->groupItemList);
+	int low = itemList->count();
+	int high = 0;
+	int d;
+	QMap<int, int> ObjOrder;
+	PageItem *currItem;
+	PageItem *b2;
+	if (itemList->count() > 1)
+	{
+		for (int c = 0; c < docSelectionCount; ++c)
 		{
 			currItem = m_Selection->itemAt(c);
-			if (((currItem->isSingleSel) && (currItem->isGroup())) || ((currItem->isSingleSel) && (currItem->isTableItem)))
-				return false;
-			int d = Items->indexOf(currItem);
+			if (currItem->isTableItem && currItem->isSingleSel)
+				return;
+			int id = itemList->indexOf(currItem);
+			low = qMin(id, low);
+			high = qMax(id, high);
+		}
+		if (low == 0)
+			return;
+		b2 = itemList->at(high);
+		bool wasSignalDelayed = !m_Selection->signalsDelayed();
+		m_Selection->delaySignalsOn();
+		if (!wasSignalDelayed)
+			m_Selection->disconnectAllItemsFromGUI();
+		Selection tempSelection(*m_Selection);
+		m_Selection->clear();
+		m_Selection->addItem(itemList->at(low - 1));
+		for (int c = 0; c < m_Selection->count(); ++c)
+		{
+			currItem = m_Selection->itemAt(c);
+			d = itemList->indexOf(currItem);
 			ObjOrder.insert(d, c);
-			Items->takeAt(d);
-		}
-		QList<uint> Oindex = ObjOrder.values();
+			itemList->takeAt(d);
+		}
+		d = itemList->indexOf(b2);
+		QList<int> Oindex = ObjOrder.values();
 		for (int c = static_cast<int>(Oindex.count()-1); c > -1; c--)
 		{
-			Items->prepend(m_Selection->itemAt(Oindex[c]));
-		}
-		return true;
-	}
-	return false;
-}
-
-
-
-bool ScribusDoc::bringItemSelectionToFront()
-{
-	uint docSelectionCount=m_Selection->count();
-	if ((Items->count() > 1) && (docSelectionCount != 0))
-	{
-		QMap<int, uint> ObjOrder;
-		PageItem *currItem;
-		for (uint c = 0; c < docSelectionCount; ++c)
+			itemList->insert(d+1, m_Selection->itemAt(Oindex[c]));
+		}
+		m_Selection->clear();
+		*m_Selection = tempSelection;
+		m_Selection->delaySignalsOff();
+		changed();
+		regionsChanged()->update(QRectF());
+	}
+}
+
+void ScribusDoc::itemSelection_RaiseItem()
+{
+	int docSelectionCount = m_Selection->count();
+	if (docSelectionCount == 0)
+		return;
+	if (docSelectionCount > 1)
+	{
+		PageItem *firstItem = m_Selection->itemAt(0);
+		for (int a = 1; a < docSelectionCount; ++a)
+		{
+			if (m_Selection->itemAt(a)->Parent != firstItem->Parent)
+				return;
+		}
+	}
+	QList<PageItem*> *itemList;
+	if (m_Selection->itemAt(0)->Parent == NULL)
+		itemList = Items;
+	else
+		itemList = &(m_Selection->itemAt(0)->Parent->asGroupFrame()->groupItemList);
+	int low = itemList->count();
+	int high = 0;
+	int d;
+	QMap<int, int> ObjOrder;
+	PageItem *currItem;
+	PageItem *b2;
+	if (itemList->count() > 1)
+	{
+		for (int c = 0; c < docSelectionCount; ++c)
 		{
 			currItem = m_Selection->itemAt(c);
-			if (((currItem->isSingleSel) && (currItem->isGroup())) || ((currItem->isSingleSel) && (currItem->isTableItem)))
-				return false;
-			int d = Items->indexOf(currItem);
+			if (currItem->isTableItem && currItem->isSingleSel)
+				return;
+			int id = itemList->indexOf(currItem);
+			low = qMin(id, low);
+			high = qMax(id, high);
+		}
+		if (high == itemList->count()-1)
+			return;
+		b2 = itemList->at(low);
+		bool wasSignalDelayed = !m_Selection->signalsDelayed();
+		m_Selection->delaySignalsOn();
+		if (!wasSignalDelayed)
+			m_Selection->disconnectAllItemsFromGUI();
+		Selection tempSelection(*m_Selection);
+		m_Selection->clear();
+		m_Selection->addItem(itemList->at(high + 1));
+		for (int c = 0; c < m_Selection->count(); ++c)
+		{
+			currItem = m_Selection->itemAt(c);
+			d = itemList->indexOf(currItem);
 			ObjOrder.insert(d, c);
-			Items->takeAt(d);
-		}
-		QList<uint> Oindex = ObjOrder.values();
+			itemList->takeAt(d);
+		}
+		QList<int> Oindex = ObjOrder.values();
 		for (int c = 0; c <static_cast<int>(Oindex.count()); ++c)
 		{
-			Items->append(m_Selection->itemAt(Oindex[c]));
-		}
-		return true;
-	}
-	return false;
-}
-
-
+			d = itemList->indexOf(b2);
+			if (d == -1)
+				d = 0;
+			itemList->insert(d, m_Selection->itemAt(Oindex[c]));
+		}
+		m_Selection->clear();
+		*m_Selection = tempSelection;
+		m_Selection->delaySignalsOff();
+		changed();
+		regionsChanged()->update(QRectF());
+	}
+}
 
 void ScribusDoc::itemSelection_SetLineWidth(double w)
 {

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17062&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Tue Dec  6 22:37:29 2011
@@ -964,9 +964,7 @@
 	 * @return int of 0,1,2,3
 	 */
 	int columnOfPage(int pageIndex) const;
-	
-	bool sendItemSelectionToBack();
-	bool bringItemSelectionToFront();
+
 
 	QList<PageItem*>* GroupOfItem(QList<PageItem*>* itemList, PageItem* item);
 	PageItem* groupObjectsSelection(Selection* customSelection=0);
@@ -1346,6 +1344,10 @@
 	void itemSelection_AlignTopOut(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition);
 	void itemSelection_AlignTopIn(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition);
 
+	void sendItemSelectionToBack();
+	void bringItemSelectionToFront();
+	void itemSelection_LowerItem();
+	void itemSelection_RaiseItem();
 	void itemSelection_DistributeDistH(bool usingDistance=false, double distance=0.0, bool reverseDistribute=false);
 	void itemSelection_DistributeAcrossPage(bool useMargins=false);
 	void itemSelection_DistributeRight();

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17062&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Tue Dec  6 22:37:29 2011
@@ -1869,157 +1869,6 @@
 	}
 }
 
-//CB Unused
-// void ScribusView::sentToScrap()
-// {
-// 	ScriXmlDoc *ss = new ScriXmlDoc();
-// 	emit ToScrap(ss->WriteElem(Doc, this, Doc->m_Selection));
-// 	delete ss;
-// 	ss=NULL;
-// }
-
-//CB-->Doc/Fix
-void ScribusView::ToBack()
-{
-	if (Doc->sendItemSelectionToBack())
-	{
-//		m_ScMW->outlinePalette->BuildTree();
-		emit LevelChanged(0);
-		emit DocChanged();
-		m_canvas->m_viewMode.forceRedraw = true;
-		updateContents();
-	}
-}
-
-//CB-->Doc/Fix
-void ScribusView::ToFront()
-{
-	if (Doc->bringItemSelectionToFront())
-	{
-//		m_ScMW->outlinePalette->BuildTree();
-//		emit LevelChanged(Doc->m_Selection->itemAt(0)->ItemNr);
-		emit DocChanged();
-		m_canvas->m_viewMode.forceRedraw = true;
-		updateContents();
-	}
-}
-
-//CB-->Doc/Fix
-void ScribusView::LowerItem()
-{
-	uint low = Doc->Items->count();
-	uint high = 0;
-	int d;
-	QMap<int, uint> ObjOrder;
-	PageItem *currItem;
-	PageItem *b2;
-	uint docSelectionCount=Doc->m_Selection->count();
-	if ((Doc->Items->count() > 1) && (docSelectionCount != 0))
-	{
-		for (uint c = 0; c < docSelectionCount; ++c)
-		{
-			currItem = Doc->m_Selection->itemAt(c);
-			if (currItem->isTableItem && currItem->isSingleSel)
-				return;
-			uint id = Doc->Items->indexOf(currItem);
-			low = qMin(id, low);
-			high = qMax(id, high);
-		}
-		if (low == 0)
-			return;
-		bool wasSignalDelayed = !Doc->m_Selection->signalsDelayed();
-		Doc->m_Selection->delaySignalsOn();
-		if (!wasSignalDelayed)
-			Doc->m_Selection->disconnectAllItemsFromGUI();
-		Selection tempSelection(*Doc->m_Selection);
-		b2 = Doc->Items->at(high);
-		Doc->m_Selection->clear();
-		SelectItemNr(low-1, false);
-		for (int c = 0; c < Doc->m_Selection->count(); ++c)
-		{
-			currItem = Doc->m_Selection->itemAt(c);
-			d = Doc->Items->indexOf(currItem);
-			ObjOrder.insert(d, c);
-			Doc->Items->takeAt(d);
-		}
-		d = Doc->Items->indexOf(b2);
-		QList<uint> Oindex = ObjOrder.values();
-		for (int c = static_cast<int>(Oindex.count()-1); c > -1; c--)
-		{
-			Doc->Items->insert(d+1, Doc->m_Selection->itemAt(Oindex[c]));
-		}
-		Doc->m_Selection->clear();
-//		m_ScMW->outlinePalette->BuildTree();
-		/*if (wasGUISelection)
-			tempSelection.setIsGUISelection(true);*/
-		*Doc->m_Selection=tempSelection;
-		Doc->m_Selection->delaySignalsOff();
-//		emit LevelChanged(Doc->m_Selection->itemAt(0)->ItemNr);
-		emit DocChanged();
-		m_canvas->m_viewMode.forceRedraw = true;
-		updateContents();
-	}
-}
-
-//CB-->Doc/Fix
-void ScribusView::RaiseItem()
-{
-	uint low = Doc->Items->count();
-	uint high = 0;
-	int d;
-	QMap<int, uint> ObjOrder;
-	PageItem *currItem;
-	PageItem *b2;
-	uint docSelectionCount=Doc->m_Selection->count();
-	if ((Doc->Items->count() > 1) && (docSelectionCount != 0))
-	{
-		for (uint c = 0; c < docSelectionCount; ++c)
-		{
-			currItem = Doc->m_Selection->itemAt(c);
-			if (currItem->isTableItem && currItem->isSingleSel)
-				return;
-			uint id = Doc->Items->indexOf(currItem);
-			low = qMin(id, low);
-			high = qMax(id, high);
-		}
-		if (high == static_cast<uint>(Doc->Items->count()-1))
-			return;
-		bool wasSignalDelayed = !Doc->m_Selection->signalsDelayed();
-		Doc->m_Selection->delaySignalsOn();
-		if (!wasSignalDelayed)
-			Doc->m_Selection->disconnectAllItemsFromGUI();
-		Selection tempSelection(*Doc->m_Selection);
-		b2 = Doc->Items->at(low);
-		Doc->m_Selection->clear();
-		SelectItemNr(high+1, false);
-		for (int c = 0; c < Doc->m_Selection->count(); ++c)
-		{
-			currItem = Doc->m_Selection->itemAt(c);
-			d = Doc->Items->indexOf(currItem);
-			ObjOrder.insert(d, c);
-			Doc->Items->takeAt(d);
-		}
-		QList<uint> Oindex = ObjOrder.values();
-		for (int c = 0; c <static_cast<int>(Oindex.count()); ++c)
-		{
-			d = Doc->Items->indexOf(b2);
-			if (d==-1)
-				d=0;
-			Doc->Items->insert(d, Doc->m_Selection->itemAt(Oindex[c]));
-		}
-		Doc->m_Selection->clear();
-//		m_ScMW->outlinePalette->BuildTree();
-		/*if (wasGUISelection)
-			tempSelection.setIsGUISelection(true);*/
-		*Doc->m_Selection=tempSelection;
-		Doc->m_Selection->delaySignalsOff();
-//		emit LevelChanged(Doc->m_Selection->itemAt(0)->ItemNr);
-		emit DocChanged();
-		m_canvas->m_viewMode.forceRedraw = true;
-		updateContents();
-	}
-}
-
  // FIXME:av -> CanvasMode_legacy / Doc
 //CB Remove emit/start pasting objects
 void ScribusView::PasteToPage()
@@ -3369,7 +3218,7 @@
 		Deselect(true);
 		PageItem* newItem=Doc->convertItemTo(currItem, PageItem::TextFrame);
 		SelectItem(newItem);
-		ToFront();
+		Doc->bringItemSelectionToFront();
 		update();
 	}
 }

Modified: trunk/Scribus/scribus/scribusview.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17062&path=/trunk/Scribus/scribus/scribusview.h
==============================================================================
--- trunk/Scribus/scribus/scribusview.h (original)
+++ trunk/Scribus/scribus/scribusview.h Tue Dec  6 22:37:29 2011
@@ -281,10 +281,6 @@
 	void RefreshGradient(PageItem *currItem, double dx = 8, double dy = 8);
 	void ToggleBookmark();
 	void ToggleAnnotation();
-	void ToBack();
-	void ToFront();
-	void LowerItem();
-	void RaiseItem();
 	void ToPicFrame();
 	void ToPolyFrame();
 	void ToTextFrame();

Modified: trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17062&path=/trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp Tue Dec  6 22:37:29 2011
@@ -20,6 +20,7 @@
 #include "sccolorengine.h"
 #include "pageitem.h"
 #include "pageitem_arc.h"
+#include "pageitem_group.h"
 #include "pageitem_spiral.h"
 #include "pageitem_textframe.h"
 #include "propertiespalette_utils.h"
@@ -294,7 +295,10 @@
 
 	nameEdit->setText(m_item->itemName());
 	QString tm;
-	levelLabel->setText(tm.setNum(m_doc->Items->indexOf(m_item) + 1));
+	if (m_item->Parent == NULL)
+		levelLabel->setText(tm.setNum(m_doc->Items->indexOf(m_item) + 1));
+	else
+		levelLabel->setText(tm.setNum(m_item->Parent->asGroupFrame()->groupItemList.indexOf(m_item) + 1));
 
 	connect(nameEdit, SIGNAL(Leaved()), this, SLOT(handleNewName()));
 
@@ -352,7 +356,21 @@
 	}
 	xposSpin->setEnabled(!setter);
 	yposSpin->setEnabled(!setter);
-	levelGroup->setEnabled(!setter);
+	bool haveSameParent = true;
+	int selectedItemCount = m_doc->m_Selection->count();
+	if (selectedItemCount > 1)
+	{
+		PageItem *firstItem = m_doc->m_Selection->itemAt(0);
+		for (int a = 1; a < selectedItemCount; ++a)
+		{
+			if (m_doc->m_Selection->itemAt(a)->Parent != firstItem->Parent)
+			{
+				haveSameParent = false;
+				break;
+			}
+		}
+	}
+	levelGroup->setEnabled(haveSameParent && !i->locked());
 	if ((m_item->isGroup()) && (!m_item->isSingleSel))
 	{
 		setEnabled(true);
@@ -395,7 +413,7 @@
 	
 	doGroup->setEnabled(false);
 	doUnGroup->setEnabled(false);
-	if (m_doc->m_Selection->count() > 1)
+	if ((m_doc->m_Selection->count() > 1) && (haveSameParent))
 		doGroup->setEnabled(true);
 	if (m_doc->m_Selection->count() == 1)
 		doUnGroup->setEnabled(m_item->isGroup());
@@ -555,12 +573,6 @@
 	widthSpin->setNewUnit( m_unitIndex );
 	heightSpin->setNewUnit( m_unitIndex );
 	m_haveItem = tmp;
-}
-
-void PropertiesPalette_XYZ::displayLevel(uint l)
-{
-	QString tm;
-	levelLabel->setText(tm.setNum(l + 1));
 }
 
 void PropertiesPalette_XYZ::displayXY(double x, double y)
@@ -1118,36 +1130,48 @@
 {
 	if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
-	m_ScMW->view->LowerItem();
+	m_doc->itemSelection_LowerItem();
 	QString tm;
-	levelLabel->setText(tm.setNum(m_doc->Items->indexOf(m_item) + 1));
+	if (m_item->Parent == NULL)
+		levelLabel->setText(tm.setNum(m_doc->Items->indexOf(m_item) + 1));
+	else
+		levelLabel->setText(tm.setNum(m_item->Parent->asGroupFrame()->groupItemList.indexOf(m_item) + 1));
 }
 
 void PropertiesPalette_XYZ::handleRaise()
 {
 	if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
-	m_ScMW->view->RaiseItem();
+	m_doc->itemSelection_RaiseItem();
 	QString tm;
-	levelLabel->setText(tm.setNum(m_doc->Items->indexOf(m_item) + 1));
+	if (m_item->Parent == NULL)
+		levelLabel->setText(tm.setNum(m_doc->Items->indexOf(m_item) + 1));
+	else
+		levelLabel->setText(tm.setNum(m_item->Parent->asGroupFrame()->groupItemList.indexOf(m_item) + 1));
 }
 
 void PropertiesPalette_XYZ::handleFront()
 {
 	if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
-	m_ScMW->view->ToFront();
+	m_doc->bringItemSelectionToFront();
 	QString tm;
-	levelLabel->setText(tm.setNum(m_doc->Items->indexOf(m_item) + 1));
+	if (m_item->Parent == NULL)
+		levelLabel->setText(tm.setNum(m_doc->Items->indexOf(m_item) + 1));
+	else
+		levelLabel->setText(tm.setNum(m_item->Parent->asGroupFrame()->groupItemList.indexOf(m_item) + 1));
 }
 
 void PropertiesPalette_XYZ::handleBack()
 {
 	if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
-	m_ScMW->view->ToBack();
+	m_doc->sendItemSelectionToBack();
 	QString tm;
-	levelLabel->setText(tm.setNum(m_doc->Items->indexOf(m_item) + 1));
+	if (m_item->Parent == NULL)
+		levelLabel->setText(tm.setNum(m_doc->Items->indexOf(m_item) + 1));
+	else
+		levelLabel->setText(tm.setNum(m_item->Parent->asGroupFrame()->groupItemList.indexOf(m_item) + 1));
 }
 
 void PropertiesPalette_XYZ::handleBasePoint(int m)
@@ -1419,7 +1443,7 @@
 	levelDown->setToolTip( tr("Move one level down"));
 	levelTop->setToolTip( tr("Move to front"));
 	levelBottom->setToolTip( tr("Move to back"));
-	levelLabel->setToolTip( tr("Indicates the level the object is on, 0 means the object is at the bottom"));
+	levelLabel->setToolTip( tr("Indicates the level the object is on, 1 means the object is at the bottom"));
 	doLock->setToolTip( tr("Lock or unlock the object"));
 	noResize->setToolTip( tr("Lock or unlock the size of the object"));
 	noPrint->setToolTip( tr("Enable or disable exporting of the object"));
@@ -1457,7 +1481,6 @@
 	heightSpin->setPalette(pal);
 	rotationSpin->setPalette(pal);
 
-	levelGroup->setEnabled(!isLocked);
 	doLock->setChecked(isLocked);
 }
 

Modified: trunk/Scribus/scribus/ui/propertiespalette_xyz.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17062&path=/trunk/Scribus/scribus/ui/propertiespalette_xyz.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_xyz.h (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_xyz.h Tue Dec  6 22:37:29 2011
@@ -56,7 +56,6 @@
 	void languageChange();
 	void unitChange();
 
-	void displayLevel(uint l);
 	void displayXY(double x, double y);
 	void displayWH(double x, double y);
 	void displayRotation(double r);




More information about the scribus-commit mailing list