View Issue Details

IDProjectCategoryView StatusLast Update
0001612ScribusScripterpublic2005-02-04 18:30
ReporterringercAssigned Tosubik  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformx86 LinuxOSFedora CoreOS Version1
Product Version1.3.0cvs 
Fixed in Version1.2.2cvs 
Summary0001612: PATCH: fix moveObject and moveObjectAbs for groups
DescriptionThe attached patch causes moveObject and moveObjectAbs to behave correctly when moving groups that are not currently selected when they're called. Patches for both 1.2.2cvs and 1.3cvs included.
TagsNo tags attached.
Patch

Relationships

child of 0003812 acknowledged Metabug: Grouped objects 

Activities

2005-02-01 15:03

 

scripter_move_fixes13.diff (2,625 bytes)   
Index: cmdmani.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp,v
retrieving revision 1.7.2.16
diff -u -r1.7.2.16 cmdmani.cpp
--- cmdmani.cpp	1 Feb 2005 10:41:40 -0000	1.7.2.16
+++ cmdmani.cpp	1 Feb 2005 16:01:37 -0000
@@ -57,10 +57,23 @@
 	PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
 	if (item==NULL)
 		return NULL;
-	if (Carrier->view->GroupSel)
+	// Grab the old selection
+	QPtrList<PageItem> oldSelection = Carrier->view->SelItem;
+	// Clear the selection
+	Carrier->view->Deselect();
+	// Select the item, which will also select its group if
+	// there is one.
+	Carrier->view->SelectItemNr(item->ItemNr);
+	// Move the item, or items
+	if (Carrier->view->SelItem.count() > 1)
 		Carrier->view->moveGroup(ValueToPoint(x), ValueToPoint(y));
 	else
 		Carrier->view->MoveItem(ValueToPoint(x), ValueToPoint(y), item);
+	// Now restore the selection. We just have to go through and select
+	// each and every item, unfortunately.
+	Carrier->view->Deselect();
+	for ( oldSelection.first(); oldSelection.current(); oldSelection.next() )
+		Carrier->view->SelectItemNr(oldSelection.current()->ItemNr);
 	Py_INCREF(Py_None);
 	return Py_None;
 }
@@ -76,19 +89,27 @@
 	PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
 	if (item == NULL)
 		return NULL;
-	if (Carrier->view->GroupSel)
+	// Grab the old selection
+	QPtrList<PageItem> oldSelection = Carrier->view->SelItem;
+	// Clear the selection
+	Carrier->view->Deselect();
+	// Select the item, which will also select its group if
+	// there is one.
+	Carrier->view->SelectItemNr(item->ItemNr);
+	// Move the item, or items
+	if (Carrier->view->SelItem.count() > 1)
 	{
-		if (Carrier->view->GroupSel)
-		{
-			double x2, y2, w, h;
-			Carrier->view->getGroupRect(&x2, &y2, &w, &h);
-			Carrier->view->moveGroup(pageUnitXToDocX(x) - x2, pageUnitYToDocY(y) - y2);
-		}
-		else
-			Carrier->view->MoveItem(pageUnitXToDocX(x) - item->Xpos, pageUnitYToDocY(y) - item->Ypos, item);
+		double x2, y2, w, h;
+		Carrier->view->getGroupRect(&x2, &y2, &w, &h);
+		Carrier->view->moveGroup(pageUnitXToDocX(x) - x2, pageUnitYToDocY(y) - y2);
 	}
 	else
 		Carrier->view->MoveItem(pageUnitXToDocX(x) - item->Xpos, pageUnitYToDocY(y) - item->Ypos, item);
+	// Now restore the selection. We just have to go through and select
+	// each and every item, unfortunately.
+	Carrier->view->Deselect();
+	for ( oldSelection.first(); oldSelection.current(); oldSelection.next() )
+		Carrier->view->SelectItemNr(oldSelection.current()->ItemNr);
 	Py_INCREF(Py_None);
 	return Py_None;
 }
scripter_move_fixes13.diff (2,625 bytes)   

ringerc

2005-02-02 09:21

reporter   ~0003585

Tsoots needed these, so assigning to him.

ringerc

2005-02-04 04:56

reporter   ~0003610

Sorry Petr, I shouldn't have changed the assignment on this to Riku. I wrote these as a fix for a problem Riku was having and thought he was going to apply them. I didn't notice you'd already taken ownership of the bug.

subik

2005-02-04 06:18

manager   ~0003613

OK

ringerc

2005-02-04 18:01

reporter   ~0003627

Proving my idiocy, the 1.2 patch was actually just the 1.3 patch again. Real 1.2 patch coming when I find it.

2005-02-04 18:11

 

scripter_move_fixes12.diff (2,351 bytes)   
Index: cmdmani.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp,v
retrieving revision 1.18
diff -u -r1.18 cmdmani.cpp
--- cmdmani.cpp	2 Feb 2005 15:13:05 -0000	1.18
+++ cmdmani.cpp	4 Feb 2005 19:11:01 -0000
@@ -57,10 +57,23 @@
 	PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
 	if (item == NULL)
 		return NULL;
-	if (item->OwnPage->GroupSel)
+	// Grab the old selection
+	QPtrList<PageItem> oldSelection = item->OwnPage->SelItem;
+	// Clear the selection
+	item->OwnPage->Deselect();
+	// Select the item, which will also select its group if
+	// there is one.
+	item->OwnPage->SelectItemNr(item->ItemNr);
+	// Move the item, or items
+	if (item->OwnPage->SelItem.count() > 1)
 		item->OwnPage->moveGroup(ValueToPoint(x), ValueToPoint(y));
 	else
 		item->OwnPage->MoveItem(ValueToPoint(x), ValueToPoint(y), item);
+	// Now restore the selection. We just have to go through and select
+	// each and every item, unfortunately.
+	item->OwnPage->Deselect();
+	for ( oldSelection.first(); oldSelection.current(); oldSelection.next() )
+		item->OwnPage->SelectItemNr(oldSelection.current()->ItemNr);
 	Py_INCREF(Py_None);
 	return Py_None;
 }
@@ -76,15 +89,27 @@
 	PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
 	if (item == NULL)
 		return NULL;
-	if (item->OwnPage->GroupSel)
+	// Grab the old selection
+	QPtrList<PageItem> oldSelection = item->OwnPage->SelItem;
+	// Clear the selection
+	item->OwnPage->Deselect();
+	// Select the item, which will also select its group if
+	// there is one.
+	item->OwnPage->SelectItemNr(item->ItemNr);
+	// Move the item, or items
+	if (item->OwnPage->SelItem.count() > 1)
 	{
 		double x2, y2, w, h;
 		item->OwnPage->getGroupRect(&x2, &y2, &w, &h);
 		item->OwnPage->moveGroup(ValueToPoint(x) - x2, ValueToPoint(y) - y2);
 	}
 	else
-		//PageItem *b = Carrier->doc->ActPage->Items.at(i);
 		item->OwnPage->MoveItem(ValueToPoint(x) - item->Xpos, ValueToPoint(y) - item->Ypos, item);
+	// Now restore the selection. We just have to go through and select
+	// each and every item, unfortunately.
+	item->OwnPage->Deselect();
+	for ( oldSelection.first(); oldSelection.current(); oldSelection.next() )
+		item->OwnPage->SelectItemNr(oldSelection.current()->ItemNr);
 	Py_INCREF(Py_None);
 	return Py_None;
 }
scripter_move_fixes12.diff (2,351 bytes)   

ringerc

2005-02-04 18:12

reporter   ~0003628

Correct 1.2 patch attached.

ringerc

2005-02-04 18:30

reporter   ~0003629

Thanks very much for that Petr (and for putting up with the stuff-ups!).

Issue History

Date Modified Username Field Change
2005-02-01 15:03 ringerc New Issue
2005-02-01 15:03 ringerc File Added: scripter_move_fixes13.diff
2005-02-01 15:47 ringerc File Added: scripter_move_fixes12.diff
2005-02-01 15:48 ringerc Description Updated
2005-02-01 16:54 subik Status new => assigned
2005-02-01 16:54 subik Assigned To => subik
2005-02-02 09:21 ringerc Assigned To subik => Tsoots
2005-02-02 09:21 ringerc Note Added: 0003585
2005-02-04 04:54 ringerc Assigned To Tsoots => subik
2005-02-04 04:56 ringerc Note Added: 0003610
2005-02-04 06:18 subik Note Added: 0003613
2005-02-04 18:00 ringerc File Deleted: scripter_move_fixes12.diff
2005-02-04 18:01 ringerc Note Added: 0003627
2005-02-04 18:11 ringerc File Added: scripter_move_fixes12.diff
2005-02-04 18:12 ringerc Note Added: 0003628
2005-02-04 18:20 subik Status assigned => resolved
2005-02-04 18:20 subik Fixed in Version => 1.2.2cvs
2005-02-04 18:20 subik Resolution open => fixed
2005-02-04 18:30 ringerc Status resolved => closed
2005-02-04 18:30 ringerc Note Added: 0003629
2006-05-13 17:17 christoph_s Relationship added child of 0003812