View Issue Details

IDProjectCategoryView StatusLast Update
0017490ScribusScripterpublic2025-04-05 22:20
Reporterale Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Product Version1.7.1.svn 
Summary0017490: [PATCH] Scripter: GetItem(name) should look inside of groups
Descriptionin the scripter engine, GetItem() is used by most commands to get the PageItem* corresponding to a give name.

Thanks to 0017052 we can now get the names of the items in a group, but because of GetItem(), we can't do any meaningful action on them.

The attached patch, makes getPageItemByName() look inside of group for an item matching the name.

This is a simpler and partial implementation of 0017399 which might have more chances to be reviewed and accepted.
TagsNo tags attached.
Attached Files
get-by-name-inside-of-groups.diff (894 bytes)   
From e2963348525c6f5489d3751df7db5d1e1a4f4e03 Mon Sep 17 00:00:00 2001
From: ale rimoldi <ale@graphicslab.org>
Date: Sat, 5 Apr 2025 13:58:11 +0200
Subject: get item by name looks inside of groups


diff --git a/scribus/plugins/scriptplugin/cmdutil.cpp b/scribus/plugins/scriptplugin/cmdutil.cpp
index d3bd6da8f..c37f18e23 100644
--- a/scribus/plugins/scriptplugin/cmdutil.cpp
+++ b/scribus/plugins/scriptplugin/cmdutil.cpp
@@ -123,6 +123,14 @@ PageItem* getPageItemByName(const QString& name)
 	{
 		if (name == currentDoc->Items->at(i)->itemName())
 			return currentDoc->Items->at(i);
+		if (currentDoc->Items->at(i)->isGroup())
+		{
+			for (const auto& groupItem: currentDoc->Items->at(i)->getAllChildren())
+			{
+				if (name == groupItem->itemName())
+					return groupItem;
+			}
+		}
 	}
 
 	PyErr_SetString(NoValidObjectError, QString("Object not found").toLocal8Bit().constData());
PatchYes

Relationships

related to 0017399 new Objects in groups are not accessible via the scriptplugin python API 
related to 0017160 new PATCH: scripter: getFillColor() and getLineColor() do not get items by name if they are inside of a group 
related to 0009054 assignedale Feature: Fix Hairline width 

Activities

ale

2025-04-05 14:09

manager   ~0052404

i see now, that i already did the same patch in the past...

0017160

ale

2025-04-05 14:14

manager   ~0052405

this patch is also needed for https://forums.scribus.net/index.php/topic,4934.0.html

ale

2025-04-05 22:20

manager   ~0052409

the patch above misses the .asGroupFrame() ...
new patch attached

It would be nice if somebody could review this patch or, even better, the one in 0017399 , which has a more complete solution.
get-by-name-inside-of-groups-2.diff (909 bytes)   
From e2963348525c6f5489d3751df7db5d1e1a4f4e03 Mon Sep 17 00:00:00 2001
From: ale rimoldi <ale@graphicslab.org>
Date: Sat, 5 Apr 2025 13:58:11 +0200
Subject: get item by name looks inside of groups


diff --git a/scribus/plugins/scriptplugin/cmdutil.cpp b/scribus/plugins/scriptplugin/cmdutil.cpp
index d3bd6da8f..c37f18e23 100644
--- a/scribus/plugins/scriptplugin/cmdutil.cpp
+++ b/scribus/plugins/scriptplugin/cmdutil.cpp
@@ -123,6 +123,14 @@ PageItem* getPageItemByName(const QString& name)
 	{
 		if (name == currentDoc->Items->at(i)->itemName())
 			return currentDoc->Items->at(i);
+		if (currentDoc->Items->at(i)->isGroup())
+		{
+			for (const auto& groupItem: currentDoc->Items->at(i)-asGroupFrame()->getAllChildren())
+			{
+				if (name == groupItem->itemName())
+					return groupItem;
+			}
+		}
 	}
 
 	PyErr_SetString(NoValidObjectError, QString("Object not found").toLocal8Bit().constData());

Issue History

Date Modified Username Field Change
2025-04-05 12:01 ale New Issue
2025-04-05 12:01 ale File Added: get-by-name-inside-of-groups.diff
2025-04-05 12:01 ale Relationship added related to 0017399
2025-04-05 14:09 ale Relationship added related to 0017160
2025-04-05 14:09 ale Note Added: 0052404
2025-04-05 14:14 ale Note Added: 0052405
2025-04-05 14:14 ale Relationship added related to 0009054
2025-04-05 22:20 ale Note Added: 0052409
2025-04-05 22:20 ale File Added: get-by-name-inside-of-groups-2.diff