r16987 by fschmid - Fixed Bug 10179: "change level by moving the items in the outline palette"

scribus-commit scribus-commit at lists.scribus.net
Fri Nov 18 11:05:49 UTC 2011


Author: fschmid
Date: Fri Nov 18 11:05:49 2011
New Revision: 16987

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16987
Log:
Fixed Bug 10179: "change level by moving the items in the outline palette"

Modified:
    trunk/Scribus/scribus/actionmanager.cpp
    trunk/Scribus/scribus/canvasgesture_resize.cpp
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem_group.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h
    trunk/Scribus/scribus/ui/outlinepalette.cpp
    trunk/Scribus/scribus/util_math.cpp
    trunk/Scribus/scribus/util_math.h

Modified: trunk/Scribus/scribus/actionmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16987&path=/trunk/Scribus/scribus/actionmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/actionmanager.cpp (original)
+++ trunk/Scribus/scribus/actionmanager.cpp Fri Nov 18 11:05:49 2011
@@ -1155,7 +1155,6 @@
 	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()) );
-
 }
 
 void ActionManager::disconnectNewViewActions()
@@ -1914,7 +1913,7 @@
 		<< "itemTransform" 
 		<< "itemDelete" 
 		<< "itemGroup" 
-		<< "itemUngroup" 
+		<< "itemUngroup"
 		<< "itemLock" 
 		<< "itemLockSize" 
 		<< "itemImageIsVisible" 

Modified: trunk/Scribus/scribus/canvasgesture_resize.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16987&path=/trunk/Scribus/scribus/canvasgesture_resize.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_resize.cpp (original)
+++ trunk/Scribus/scribus/canvasgesture_resize.cpp Fri Nov 18 11:05:49 2011
@@ -308,7 +308,14 @@
 				}
 			}
 		}
+		double oldX = currItem->xPos();
+		double oldY = currItem->yPos();
 		currItem->setXYPos(newBounds.x() + m_extraX, newBounds.y() + m_extraY);
+		if (currItem->Parent != 0)	// part of a group
+		{
+			currItem->gXpos += currItem->xPos() - oldX;
+			currItem->gYpos += currItem->yPos() - oldY;
+		}
 		currItem->setWidth(newBounds.width() - m_extraWidth);
 		currItem->setHeight(newBounds.height() - m_extraHeight);
 		currItem->updateClip();
@@ -402,7 +409,7 @@
 		qp = rotation.inverted().map(qp);
 		docPoint = FPoint(qp.x(), qp.y());
 	}
-	
+
 	// adjust bounds vertically
 	switch (m_handle)
 	{

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16987&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Fri Nov 18 11:05:49 2011
@@ -5561,6 +5561,8 @@
 		}
 		result.translate(ite->xPos(), ite->yPos());
 		result.rotate(ite->rotation());
+		if (ite == this)
+			return result;
 		if (ite->isGroup())
 			result.scale(ite->width() / ite->groupWidth, ite->height() / ite->groupHeight);
 		for (int aa = 0; aa < itList.count(); aa++)
@@ -5568,6 +5570,8 @@
 			ite = itList.at(aa);
 			result.translate(ite->gXpos, ite->gYpos);
 			result.rotate(ite->rotation());
+			if (ite == this)
+				return result;
 			if (ite->isGroup())
 				result.scale(ite->width() / ite->groupWidth, ite->height() / ite->groupHeight);
 		}

Modified: trunk/Scribus/scribus/pageitem_group.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16987&path=/trunk/Scribus/scribus/pageitem_group.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_group.cpp (original)
+++ trunk/Scribus/scribus/pageitem_group.cpp Fri Nov 18 11:05:49 2011
@@ -178,6 +178,27 @@
 				embedded->DrawObj(p, QRectF());
 				embedded->isEmbedded = false;
 				p->restore();
+				if (m_Doc->guidesPrefs().framesShown)
+				{
+					p->save();
+					double x = embedded->xPos();
+					double y = embedded->yPos();
+					embedded->setXYPos(embedded->gXpos, embedded->gYpos, true);
+					embedded->DrawObj_Decoration(p);
+					embedded->setXYPos(x, y, true);
+					p->restore();
+				}
+				if (m_Doc->layerOutline(LayerID))
+				{
+					p->save();
+					p->setPen(m_Doc->layerMarker(LayerID), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+					p->setFillMode(ScPainter::None);
+					p->setBrushOpacity(1.0);
+					p->setPenOpacity(1.0);
+					p->setupPolygon(&PoLine);
+					p->strokePath();
+					p->restore();
+				}
 			}
 			for (int em = 0; em < groupItemList.count(); ++em)
 			{
@@ -211,27 +232,6 @@
 			}
 			p->endLayer();
 			p->restore();
-			if (m_Doc->layerOutline(LayerID))
-			{
-				p->setPen(m_Doc->layerMarker(LayerID), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
-				p->setFillMode(ScPainter::None);
-				p->setBrushOpacity(1.0);
-				p->setPenOpacity(1.0);
-				p->setupPolygon(&PoLine);
-				p->strokePath();
-			}
-			if (m_Doc->guidesPrefs().framesShown)
-			{
-				for (int em = 0; em < groupItemList.count(); ++em)
-				{
-					PageItem* embedded = groupItemList.at(em);
-					double x = embedded->xPos();
-					double y = embedded->yPos();
-					embedded->setXYPos(embedded->gXpos, embedded->gYpos, true);
-					embedded->DrawObj_Decoration(p);
-					embedded->setXYPos(x, y, true);
-				}
-			}
 		}
 		else
 		{

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16987&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Fri Nov 18 11:05:49 2011
@@ -12208,13 +12208,6 @@
 	return retw;
 }
 
-/*
-void ScribusDoc::RotateItem(double angle, int ite)
-{
-	RotateItem(angle, Items->at(ite));
-}
-*/
-
 void ScribusDoc::RotateItem(double angle, PageItem *currItem)
 {
 	if (currItem->locked())
@@ -12284,13 +12277,6 @@
 	MoveItem(-mxc, -myc, currItem, fromMP);
 }
 
-/*
-bool ScribusDoc::SizeItem(double newX, double newY, int ite, bool fromMP, bool DoUpdateClip, bool redraw)
-{
-	return SizeItem(newX, newY, Items->at(ite), fromMP, DoUpdateClip, redraw);
-}
-*/
-
 bool ScribusDoc::SizeItem(double newX, double newY, PageItem *pi, bool fromMP, bool DoUpdateClip, bool redraw)
 {
 	PageItem *currItem = pi;
@@ -12433,13 +12419,6 @@
 	return true;
 }
 
-/*
-bool ScribusDoc::MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP, bool constrainRotation)
-{
-	PageItem *currItem = Items->at(ite);
-	return MoveSizeItem(newX, newY, currItem, fromMP, constrainRotation);
-}
-*/
 bool ScribusDoc::MoveSizeItem(FPoint newX, FPoint newY, PageItem* currItem, bool fromMP, bool constrainRotation)
 {
 	QRectF oldR(currItem->getBoundingRect());
@@ -12566,8 +12545,6 @@
 	currItem->updateGradientVectors();
 	currItem->Sizing = siz;
 }
-
-
 
 void ScribusDoc::moveGroup(double x, double y, bool fromMP, Selection* customSelection)
 {
@@ -13193,9 +13170,7 @@
 			}
 			if ((currItem->width() != currItem->groupWidth) || (currItem->height() != currItem->groupHeight))
 				scaleGroup(currItem->width() / currItem->groupWidth, currItem->height() / currItem->groupHeight, true, &tempSelection, true);
-			QTransform ma;
-			ma.translate(currItem->xPos(), currItem->yPos());
-			ma.rotate(currItem->rotation());
+			QTransform ma = currItem->getTransform();
 			FPoint n;
 			for (int a = 0; a < tempSelection.count(); ++a)
 			{
@@ -13264,6 +13239,58 @@
 		m_ScMW->HaveNewSel(itemSelection->itemAt(0)->itemType());
 		regionsChanged()->update(QRectF(x-5, y-5, w+10, h+10));
 	}
+}
+
+void ScribusDoc::addToGroup(PageItem* group, PageItem* item)
+{
+	QTransform groupTrans = group->getTransform();
+	QTransform itemTrans = item->getTransform();
+	QPointF grPos = groupTrans.map(QPointF(0, 0));
+	QPointF itPos = itemTrans.map(QPointF(0, 0));
+	double gRot = getRotationDFromMatrix(groupTrans);
+	groupTrans.scale(group->width() / group->groupWidth, group->height() / group->groupHeight);
+	double grScXi = 1.0;
+	double grScYi = 1.0;
+	getScaleFromMatrix(groupTrans, grScXi, grScYi);
+	QTransform mm;
+	mm.rotate(gRot);
+	mm.scale(1.0 / grScXi, 1.0 / grScYi);
+	QLineF d = QLineF(0.0, 0.0, itPos.x() - grPos.x(), itPos.y() - grPos.y());
+	d = mm.map(d);
+	item->gXpos = d.p2().x();
+	item->gYpos = d.p2().y();
+	SizeItem(item->width() * (1.0 / grScXi), item->height() * (1.0 / grScYi), item, false, true, false);
+	if (item->Parent != NULL)
+		item->Parent->groupItemList.removeAll(item);
+	else
+		Items->removeAll(item);
+	item->Parent = group;
+	item->rotateBy(gRot);
+	item->setLineWidth(item->lineWidth() / qMax(grScXi, grScYi));
+	item->setImageXScale(item->imageXScale() / grScXi);
+	item->setImageYScale(item->imageYScale() / grScYi);
+}
+
+void ScribusDoc::removeFromGroup(PageItem* item)
+{
+	if (item->Parent == NULL)
+		return;
+	PageItem* group = item->Parent;
+	QTransform itemTrans = item->getTransform();
+	QTransform groupTrans = group->getTransform();
+	QPointF itPos = itemTrans.map(QPointF(0, 0));
+	double grScXi = 1.0;
+	double grScYi = 1.0;
+	getScaleFromMatrix(itemTrans, grScXi, grScYi);
+	double gRot = getRotationDFromMatrix(groupTrans);
+	SizeItem(item->width() * grScXi, item->height() * grScYi, item, false, true, false);
+	item->setXYPos(itPos.x(), itPos.y(), true);
+	item->rotateBy(-gRot);
+	group->groupItemList.removeAll(item);
+	item->Parent = NULL;
+	item->setLineWidth(item->lineWidth() * qMax(grScXi, grScYi));
+	item->setImageXScale(item->imageXScale() * grScXi);
+	item->setImageYScale(item->imageYScale() * grScYi);
 }
 
 void ScribusDoc::itemSelection_UniteItems(Selection* /*customSelection*/)

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16987&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Fri Nov 18 11:05:49 2011
@@ -974,6 +974,8 @@
 	void groupObjectsToItem(PageItem* groupItem, QList<PageItem*> &itemList);
 	const PageItem * itemSelection_GroupObjects  (bool changeLock, bool lock, Selection* customSelection=0);
 	void itemSelection_UnGroupObjects(Selection* customSelection=0);
+	void addToGroup(PageItem* group, PageItem* item);
+	void removeFromGroup(PageItem* item);
 	void itemSelection_convertItemsTo(const PageItem::ItemType newType, Selection* restoredSelection=0, Selection* customSelection=0);
 
 	void itemSelection_ApplyParagraphStyle(const ParagraphStyle & newstyle, Selection* customSelection=0, bool rmDirectFormatting = false);
@@ -1056,12 +1058,9 @@
 	bool ApplyGuides(double *x, double *y);
 	bool ApplyGuides(FPoint* point);
 	bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
-//	void RotateItem(double win, int ite);
 	void RotateItem(double win, PageItem *currItem);
 	void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
-//	bool SizeItem(double newX, double newY, int ite, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
 	bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
-//	bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false, bool constrainRotation=false);
 	bool MoveSizeItem(FPoint newX, FPoint newY, PageItem* currItem, bool fromMP = false, bool constrainRotation = false);
 	void AdjustItemSize(PageItem *currItem, bool includeGroup = false, bool moveInGroup = true);
 	void moveGroup(double x, double y, bool fromMP = false, Selection* customSelection = 0);

Modified: trunk/Scribus/scribus/ui/outlinepalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16987&path=/trunk/Scribus/scribus/ui/outlinepalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/outlinepalette.cpp (original)
+++ trunk/Scribus/scribus/ui/outlinepalette.cpp Fri Nov 18 11:05:49 2011
@@ -88,16 +88,13 @@
 		id = idxs.at(0);
 	if (id.isValid())
 		it = itemFromIndex(id);
-	QTreeWidgetItem *oldParent = it->parent();
-	QTreeWidgetItem *oldPageParent = NULL;
-	OutlineTreeItem *itemP = (OutlineTreeItem*)oldParent;
-	if (itemP->type == 5)		// old Parent is a Layer
-	{
-		oldPageParent = it->parent()->parent();
-		haveLayers = true;
-	}
-	else
-		oldPageParent = it->parent();
+	OutlineTreeItem *itemPar = (OutlineTreeItem*)it->parent();
+	while (itemPar->type != 2)
+	{
+		if (itemPar->type == 5)
+			haveLayers = true;
+		itemPar = (OutlineTreeItem*)itemPar->parent();
+	}
 	QTreeWidget::dropEvent(e);
 	if (it != NULL)
 	{
@@ -105,96 +102,112 @@
 		if (item != NULL)
 		{
 			OutlineTreeItem *itemPl = (OutlineTreeItem*)it->parent();
-			OutlineTreeItem *itemPar = (OutlineTreeItem*)oldPageParent;
 			OutlineTreeItem *itemPg;
 			if (itemPl->type == 5)
 			{
 				itemPg = (OutlineTreeItem*)it->parent()->parent();
 			}
-			else
+			else if (itemPl->type == 2)
 			{
 				itemPg = (OutlineTreeItem*)it->parent();
 				if (haveLayers)
 				{
-					itemPl = (OutlineTreeItem*)itemBelow(itemPg);
+					itemPl = (OutlineTreeItem*)itemPg->child(0);
 					itemPg->removeChild(it);
 					itemPl->addChild(it);
 				}
 			}
-			if (itemPl->childCount() > 1)
-			{
-				if (itemAbove(it) != NULL)		// do we have a pageitem above us
-				{
-					OutlineTreeItem *itemAb = (OutlineTreeItem*)itemAbove(it);
-					if ((itemAb->type == 1) || (itemAb->type == 3) || (itemAb->type == 4))
-					{
+			else
+			{
+				itemPg = (OutlineTreeItem*)it->parent();
+				while (itemPg->type != 2)
+				{
+					itemPg = (OutlineTreeItem*)itemPg->parent();
+				}
+			}
+			if (itemPl->indexOfChild(it) != itemPl->childCount() - 1)
+			{
+				OutlineTreeItem *itemBe = (OutlineTreeItem*)itemPl->child(itemPl->indexOfChild(it) + 1);
+				if ((itemBe->type == 1) || (itemBe->type == 3) || (itemBe->type == 4))
+				{
+					if (item->PageItemObject->Parent == NULL)
 						item->DocObject->Items->takeAt(item->DocObject->Items->indexOf(item->PageItemObject));
-						int d = item->DocObject->Items->indexOf(itemAb->PageItemObject);
-						item->DocObject->Items->insert(d, item->PageItemObject);
+					else
+						item->DocObject->removeFromGroup(item->PageItemObject);
+					if (itemBe->PageItemObject->Parent == NULL)
+					{
+						int d = item->DocObject->Items->indexOf(itemBe->PageItemObject);
+						item->DocObject->Items->insert(d+1, item->PageItemObject);
 						if (itemPl->type == 5)
 							item->PageItemObject->setLayer(itemPl->LayerID);
 						double xx = item->PageItemObject->xPos() - itemPar->PageObject->xOffset() + itemPg->PageObject->xOffset();
 						double yy = item->PageItemObject->yPos() - itemPar->PageObject->yOffset() + itemPg->PageObject->yOffset();
 						item->PageItemObject->setXYPos(xx, yy);
-						item->DocObject->setModified(true);
-						item->PageItemObject->setRedrawBounding();
-						item->DocObject->scMW()->showLayer();
-						item->DocObject->scMW()->closeActiveWindowMasterPageEditor();
-						if (item->PageItemObject->isGroup())
-						{
-							item->DocObject->GroupOnPage(item->PageItemObject);
-							item->DocObject->scMW()->selectItemsFromOutlines(item->PageItemObject, false);
-						}
+					}
+					else
+					{
+						PageItem* group = itemBe->PageItemObject->Parent;
+						int d = group->groupItemList.indexOf(itemBe->PageItemObject);
+						double xx = item->PageItemObject->xPos() - itemPar->PageObject->xOffset() + itemPg->PageObject->xOffset();
+						double yy = item->PageItemObject->yPos() - itemPar->PageObject->yOffset() + itemPg->PageObject->yOffset();
+						item->PageItemObject->setXYPos(xx, yy);
+						item->DocObject->addToGroup(group, item->PageItemObject);
+						group->groupItemList.insert(d, item->PageItemObject);
+						item->PageItemObject->setLayer(group->LayerID);
+					}
+					item->PageItemObject->setRedrawBounding();
+					item->DocObject->setModified(true);
+					item->DocObject->scMW()->showLayer();
+					item->DocObject->scMW()->closeActiveWindowMasterPageEditor();
+					if (item->PageItemObject->isGroup())
+					{
+						item->DocObject->GroupOnPage(item->PageItemObject);
+						item->DocObject->scMW()->selectItemsFromOutlines(item->PageItemObject, false);
+					}
+					else
+					{
+						item->PageItemObject->OwnPage = item->DocObject->OnPage(item->PageItemObject);
+						item->DocObject->scMW()->selectItemsFromOutlines(item->PageItemObject, true);
+					}
+					QList<QTreeWidgetItem*> selList;
+					selList.append(it);
+					selectItems(selList);
+				}
+			}
+			else
+			{
+		//		itemPl->insertChild(0, itemPl->takeChild(itemPl->indexOfChild(it)));
+				if ((itemPl->type == 2) || (itemPl->type == 5))
+				{
+					if (item->PageItemObject->Parent != NULL)
+					{
+						item->DocObject->removeFromGroup(item->PageItemObject);
+						item->DocObject->Items->append(item->PageItemObject);
+					}
+					if (itemPl->type == 5)
+						item->PageItemObject->setLayer(itemPl->LayerID);
+					double xx = item->PageItemObject->xPos() - itemPar->PageObject->xOffset() + itemPg->PageObject->xOffset();
+					double yy = item->PageItemObject->yPos() - itemPar->PageObject->yOffset() + itemPg->PageObject->yOffset();
+					item->PageItemObject->setXYPos(xx, yy);
+				}
+				else
+				{
+					OutlineTreeItem *itemBe = (OutlineTreeItem*)it->parent();
+					if ((itemBe->type == 1) || (itemBe->type == 3) || (itemBe->type == 4))
+					{
+						if (item->PageItemObject->Parent == NULL)
+							item->DocObject->Items->takeAt(item->DocObject->Items->indexOf(item->PageItemObject));
 						else
-						{
-							item->PageItemObject->OwnPage = item->DocObject->OnPage(item->PageItemObject);
-							item->DocObject->scMW()->selectItemsFromOutlines(item->PageItemObject, true);
-						}
-						QList<QTreeWidgetItem*> selList;
-						selList.append(it);
-						selectItems(selList);
-					}
-					else if (itemBelow(it) != NULL)
-					{
-						OutlineTreeItem *itemBe = (OutlineTreeItem*)itemBelow(it);
-						if ((itemBe->type == 1) || (itemBe->type == 3) || (itemBe->type == 4))
-						{
-							item->DocObject->Items->takeAt(item->DocObject->Items->indexOf(item->PageItemObject));
-							int d = item->DocObject->Items->indexOf(itemBe->PageItemObject);
-							item->DocObject->Items->insert(d+1, item->PageItemObject);
-							if (itemPl->type == 5)
-								item->PageItemObject->setLayer(itemPl->LayerID);
-							double xx = item->PageItemObject->xPos() - itemPar->PageObject->xOffset() + itemPg->PageObject->xOffset();
-							double yy = item->PageItemObject->yPos() - itemPar->PageObject->yOffset() + itemPg->PageObject->yOffset();
-							item->PageItemObject->setXYPos(xx, yy);
-							item->PageItemObject->setRedrawBounding();
-							item->DocObject->setModified(true);
-							item->DocObject->scMW()->showLayer();
-							item->DocObject->scMW()->closeActiveWindowMasterPageEditor();
-							if (item->PageItemObject->isGroup())
-							{
-								item->DocObject->GroupOnPage(item->PageItemObject);
-								item->DocObject->scMW()->selectItemsFromOutlines(item->PageItemObject, false);
-							}
-							else
-							{
-								item->PageItemObject->OwnPage = item->DocObject->OnPage(item->PageItemObject);
-								item->DocObject->scMW()->selectItemsFromOutlines(item->PageItemObject, true);
-							}
-							QList<QTreeWidgetItem*> selList;
-							selList.append(it);
-							selectItems(selList);
-						}
-					}
-				}
-			}
-			else
-			{
-				if (itemPl->type == 5)
-					item->PageItemObject->setLayer(itemPl->LayerID);
-				double xx = item->PageItemObject->xPos() - itemPar->PageObject->xOffset() + itemPg->PageObject->xOffset();
-				double yy = item->PageItemObject->yPos() - itemPar->PageObject->yOffset() + itemPg->PageObject->yOffset();
-				item->PageItemObject->setXYPos(xx, yy);
+							item->DocObject->removeFromGroup(item->PageItemObject);
+						PageItem* group = itemBe->PageItemObject;
+						double xx = item->PageItemObject->xPos() - itemPar->PageObject->xOffset() + itemPg->PageObject->xOffset();
+						double yy = item->PageItemObject->yPos() - itemPar->PageObject->yOffset() + itemPg->PageObject->yOffset();
+						item->PageItemObject->setXYPos(xx, yy);
+						item->DocObject->addToGroup(group, item->PageItemObject);
+						group->groupItemList.append(item->PageItemObject);
+						item->PageItemObject->setLayer(group->LayerID);
+					}
+				}
 				item->PageItemObject->setRedrawBounding();
 				item->DocObject->setModified(true);
 				item->DocObject->scMW()->showLayer();
@@ -990,7 +1003,7 @@
 				object->type = 3;
 				object->setText(0, pgItem->itemName());
 				object->setIcon( 0, groupIcon );
-				object->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled);
+				object->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
 				parseSubGroup(object, &pgItem->groupItemList, 3, currDoc->Pages->at(0));
 			}
 		}
@@ -1094,7 +1107,7 @@
 							object->type = 3;
 							object->setText(0, pgItem->itemName());
 							object->setIcon( 0, groupIcon );
-							object->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled);
+							object->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
 							parseSubGroup(object, &pgItem->groupItemList, 3, currDoc->DocPages.at(a));
 						}
 					}
@@ -1129,7 +1142,7 @@
 							object->type = 3;
 							object->setText(0, pgItem->itemName());
 							object->setIcon( 0, groupIcon );
-							object->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled);
+							object->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
 							parseSubGroup(object, &pgItem->groupItemList, 3, currDoc->DocPages.at(a));
 						}
 					}
@@ -1288,7 +1301,10 @@
 			grp->type = itemType;
 			grp->setText(0, pgItem->itemName());
 			setItemIcon(grp, pgItem);
-			grp->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+			if (itemType == 3)
+				grp->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled);
+			else
+				grp->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
 //			grp->setFlags(Qt::ItemIsEnabled);
 		}
 		else
@@ -1300,7 +1316,10 @@
 			grp->type = itemType;
 			grp->setText(0, pgItem->itemName());
 			grp->setIcon( 0, groupIcon );
-			grp->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+			if (itemType == 3)
+				grp->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
+			else
+				grp->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
 //			grp->setFlags(Qt::ItemIsEnabled);
 			parseSubGroup(grp, &pgItem->groupItemList, itemType, a);
 		}

Modified: trunk/Scribus/scribus/util_math.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16987&path=/trunk/Scribus/scribus/util_math.cpp
==============================================================================
--- trunk/Scribus/scribus/util_math.cpp (original)
+++ trunk/Scribus/scribus/util_math.cpp Fri Nov 18 11:05:49 2011
@@ -447,3 +447,19 @@
 	return value;
 }
 
+double getRotationDFromMatrix(QTransform& matrix)
+{
+	QLineF line = QLineF(0.0, 0.0, 1.0, 0.0);
+	line = matrix.map(line);
+	return line.angle();
+}
+
+void getScaleFromMatrix(QTransform &matrix, double &scX, double &scY)
+{
+	QLineF lineX = QLineF(0.0, 0.0, 1.0, 0.0);
+	QLineF lineY = QLineF(0.0, 0.0, 0.0, 1.0);
+	lineX = matrix.map(lineX);
+	lineY = matrix.map(lineY);
+	scX = lineX.length();
+	scY = lineY.length();
+}

Modified: trunk/Scribus/scribus/util_math.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16987&path=/trunk/Scribus/scribus/util_math.h
==============================================================================
--- trunk/Scribus/scribus/util_math.h (original)
+++ trunk/Scribus/scribus/util_math.h Fri Nov 18 11:05:49 2011
@@ -17,6 +17,7 @@
 #include <QPolygon>
 #include <QList>
 #include <QPainterPath>
+#include <QLineF>
 
 #include "scribusapi.h"
 
@@ -55,6 +56,12 @@
    \retval double the rotation angle
  */
 double SCRIBUS_API getRotationFromMatrix(QTransform& matrix, double def);
+/*! \brief Get the rotation angle (in degree) from a transformation matrix
+   \param matrix the transformation matrix
+   \retval double the rotation angle
+ */
+double SCRIBUS_API getRotationDFromMatrix(QTransform& matrix);
+void SCRIBUS_API getScaleFromMatrix(QTransform &matrix, double &scX, double &scY);
 
 
 // IMPLEMENTATION




More information about the scribus-commit mailing list