View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0017490 | Scribus | Scripter | public | 2025-04-05 12:01 | 2025-04-05 22:20 |
| Reporter | ale | Assigned To | |||
| Priority | normal | Severity | feature | Reproducibility | N/A |
| Status | new | Resolution | open | ||
| Product Version | 1.7.1.svn | ||||
| Summary | 0017490: [PATCH] Scripter: GetItem(name) should look inside of groups | ||||
| Description | in 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. | ||||
| Tags | No 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());
| ||||
| Patch | Yes | ||||
|
|
i see now, that i already did the same patch in the past... 0017160 |
|
|
this patch is also needed for https://forums.scribus.net/index.php/topic,4934.0.html |
|
|
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());
|
| 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 |