[education/labplot] /: [scripting] WorksheetElement::setPosition(PositionWrapper) cannot be bound because of a nested Qt class QPointF.
Alexander Semke <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 1cc347cd770bd7a698ca5686c6f974a1766489f3 by Alexander Semke.
Committed on 05/08/2026 at 17:42.
Pushed by asemke into branch 'master'.
[scripting] WorksheetElement::setPosition(PositionWrapper) cannot be bound because of a nested Qt class QPointF.
Expose setPositionScene(QPointF) which should be good enough for now. Fixed also the binding for Worksheet::setPageRect().
M +10 -15 lib/python/bindings.xml
M +11 -2 src/backend/worksheet/WorksheetElement.cpp
M +1 -1 src/backend/worksheet/WorksheetElement.h
M +2 -2 src/backend/worksheet/plots/cartesian/Axis.cpp
https://invent.kde.org/education/labplot/-/commit/1cc347cd770bd7a698ca5686c6f974a1766489f3
diff --git a/lib/python/bindings.xml b/lib/python/bindings.xml
index 0f5b083ad5..a9bcab5c3f 100644
--- a/lib/python/bindings.xml
+++ b/lib/python/bindings.xml
@@ -162,15 +162,14 @@
<enum-type name="HorizontalAlignment"/>
<enum-type name="VerticalAlignment"/>
<enum-type name="PositionLimit"/>
- <!-- fails finding QPointF for constructor with flatpak-builder -->
+ <!-- PositionWrapper cannot be bound - nested struct with QPointF causes shiboken issues -->
<!-- <value-type name="PositionWrapper" disable-wrapper="yes"/> -->
- <modify-function signature="position()" return-type="PositionWrapper"/>
- <modify-function signature="setPosition(PositionWrapper)" return-type="void"/>
- <!-- Could not find a minimal constructor for type 'QPointF': Could not find class "QPointF" in the code model -->
- <modify-function signature="setPosition(QPointF)" return-type="void"/>
+ <!-- <declare-function signature="position()const" return-type="PositionWrapper"/> -->
+ <!-- <declare-function signature="setPosition(const PositionWrapper&)" return-type="void"/> -->
<declare-function signature="positionLogical()" return-type="QPointF"/>
- <!-- Could not find a minimal constructor for type 'QPointF': Could not find class "QPointF" in the code model -->
- <modify-function signature="setPositionLogical(QPointF)" return-type="void"/>
+ <declare-function signature="setPositionLogical(const QPointF)" return-type="void"/>
+ <declare-function signature="positionScene()" return-type="QPointF"/>
+ <declare-function signature="setPositionScene(const QPointF)" return-type="void"/>
<declare-function signature="horizontalAlignment()" return-type="WorksheetElement::HorizontalAlignment"/>
<declare-function signature="setHorizontalAlignment(WorksheetElement::HorizontalAlignment)" return-type="void"/>
<declare-function signature="verticalAlignment()" return-type="WorksheetElement::VerticalAlignment"/>
@@ -195,8 +194,7 @@
<object-type name="WorksheetElementContainer" force-abstract="yes" disable-wrapper="yes">
<declare-function signature="retransform()" return-type="void"/>
<declare-function signature="rect()const" return-type="QRectF"/>
- <!-- Could not find a minimal constructor for type 'QRectF': Could not find class "QRectF" in the code model -->
- <modify-function signature="setRect(QRectF)" return-type="void"/>
+ <declare-function signature="setRect(const QRectF&)" return-type="void"/>
</object-type>
<rejection class="XYAnalysisCurve" field-name="*"/>
<rejection class="XYAnalysisCurve" function-name="*"/>
@@ -797,11 +795,9 @@
<declare-function signature="background()const" return-type="Background*"/>
<declare-function signature="line()const" return-type="Line*"/>
<declare-function signature="positionLogicalStart()const" return-type="QPointF"/>
- <!-- Could not find a minimal constructor for type 'QPointF': Could not find class "QPointF" in the code model -->
- <modify-function signature="setPositionLogicalStart(QPointF)" return-type="void"/>
+ <declare-function signature="setPositionLogicalStart(const QPointF)" return-type="void"/>
<declare-function signature="positionLogicalEnd()const" return-type="QPointF"/>
- <!-- Could not find a minimal constructor for type 'QPointF': Could not find class "QPointF" in the code model -->
- <modify-function signature="setPositionLogicalEnd(QPointF)" return-type="void"/>
+ <declare-function signature="setPositionLogicalEnd(const QPointF)" return-type="void"/>
<declare-function signature="orientation()const" return-type="WorksheetElement::Orientation"/>
<declare-function signature="setOrientation(WorksheetElement::Orientation)" return-type="void"/>
</object-type>
@@ -1368,8 +1364,7 @@
</modify-argument>
</declare-function>
<declare-function signature="pageRect()const" return-type="QRectF"/>
- <!-- Could not find a minimal constructor for type 'QRectF': Could not find class "QRectF" in the code model -->
- <modify-function signature="setPageRect(QRectF)" return-type="void"/>
+ <declare-function signature="setPageRect(const QRectF&)" return-type="void"/>
<declare-function signature="scaleContent()const" return-type="bool"/>
<declare-function signature="setScaleContent(bool)" return-type="void"/>
<declare-function signature="useViewSize()const" return-type="bool"/>
diff --git a/src/backend/worksheet/WorksheetElement.cpp b/src/backend/worksheet/WorksheetElement.cpp
index 8c1bb7f442..20a9077afe 100644
--- a/src/backend/worksheet/WorksheetElement.cpp
+++ b/src/backend/worksheet/WorksheetElement.cpp
@@ -808,10 +808,14 @@ void WorksheetElement::setPositionLogical(QPointF pos) {
/*!
* \brief WorksheetElement::setPosition
- * sets the position without undo/redo-stuff
+ * Sets the position in scene coordinates without undo/redo-functionality.
+ * This function is not undo-aware and is used internally only and in python bindings.
* \param point point in scene coordinates
*/
-void WorksheetElement::setPosition(QPointF point) {
+void WorksheetElement::setPositionScene(QPointF point) {
+ // TODO: this function is not undo-aware and is used internally in AxisPrivat only
+ // and in python bindings since we have problems to expose PositionWrapper.
+ // redesign this later - either do it undo-aware or switch to setPosition(PositionWrapper).
Q_D(WorksheetElement);
if (point != d->position.point) {
d->position.point = point;
@@ -819,6 +823,11 @@ void WorksheetElement::setPosition(QPointF point) {
}
}
+QPointF WorksheetElement::positionScene() const {
+ Q_D(const WorksheetElement);
+ return d->position.point;
+}
+
/*!
* position is set to invalid if the parent item is not drawn on the scene
* (e.g. axis is not drawn because it's outside plot ranges -> don't draw axis' title label)
diff --git a/src/backend/worksheet/WorksheetElement.h b/src/backend/worksheet/WorksheetElement.h
index a67fca27d3..c3b0f2f717 100644
--- a/src/backend/worksheet/WorksheetElement.h
+++ b/src/backend/worksheet/WorksheetElement.h
@@ -74,7 +74,7 @@ public:
bool setCoordinateBindingEnabled(bool);
bool coordinateBindingEnabled() const;
BASIC_D_ACCESSOR_DECL(QPointF, positionLogical, PositionLogical)
- void setPosition(QPointF);
+ BASIC_D_ACCESSOR_DECL(QPointF, positionScene, PositionScene)
void setPositionInvalid(bool);
BASIC_D_ACCESSOR_DECL(HorizontalAlignment, horizontalAlignment, HorizontalAlignment)
BASIC_D_ACCESSOR_DECL(VerticalAlignment, verticalAlignment, VerticalAlignment)
diff --git a/src/backend/worksheet/plots/cartesian/Axis.cpp b/src/backend/worksheet/plots/cartesian/Axis.cpp
index 4c7fed96fe..005bb6c828 100644
--- a/src/backend/worksheet/plots/cartesian/Axis.cpp
+++ b/src/backend/worksheet/plots/cartesian/Axis.cpp
@@ -2970,12 +2970,12 @@ void AxisPrivate::recalcShapeAndBoundingRect() {
offsetY -= titleRect.height() * title->scale() / 2.;
if (labelsPosition == Axis::LabelsPosition::Out)
offsetY -= labelsOffset + tickLabelsPath.boundingRect().height();
- title->setPosition(QPointF((rect.topLeft().x() + rect.topRight().x()) / 2. + titleOffsetX, rect.bottomLeft().y() - offsetY));
+ title->setPositionScene(QPointF((rect.topLeft().x() + rect.topRight().x()) / 2. + titleOffsetX, rect.bottomLeft().y() - offsetY));
} else {
offsetX -= titleRect.height() * title->scale() / 2.;
if (labelsPosition == Axis::LabelsPosition::Out)
offsetX -= labelsOffset + tickLabelsPath.boundingRect().width();
- title->setPosition(QPointF(rect.topLeft().x() + offsetX, (rect.topLeft().y() + rect.bottomLeft().y()) / 2. - titleOffsetY));
+ title->setPositionScene(QPointF(rect.topLeft().x() + offsetX, (rect.topLeft().y() + rect.bottomLeft().y()) / 2. - titleOffsetY));
}
titlePath = WorksheetElement::shapeFromPath(title->graphicsItem()->mapToParent(title->graphicsItem()->shape()), linePen);