From abcc5a4ea27a365e9204370e91bcbf4888f27efb Mon Sep 17 00:00:00 2001 From: Artur Duque de Souza Date: Fri, 6 Nov 2009 20:06:53 +0000 Subject: [PATCH] Add missing QGraphicsAnchorLayout methods do JS bindings The methods anchor() (that returns an anchor between two items) and addAnchors() (convenience method) were missing on the binding. The binding for this layout is probably 100% now :) svn path=/trunk/KDE/kdebase/runtime/; revision=1045801 --- .../javascript/qtgui/anchorlayout.cpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scriptengines/javascript/qtgui/anchorlayout.cpp b/scriptengines/javascript/qtgui/anchorlayout.cpp index 5780936ee..f13a1fb7b 100644 --- a/scriptengines/javascript/qtgui/anchorlayout.cpp +++ b/scriptengines/javascript/qtgui/anchorlayout.cpp @@ -92,6 +92,31 @@ BEGIN_DECLARE_METHOD(QGraphicsAnchorLayout, addAnchor) { return eng->newQObject(anchor, QScriptEngine::QtOwnership); } END_DECLARE_METHOD +BEGIN_DECLARE_METHOD(QGraphicsAnchorLayout, anchor) { + QGraphicsLayoutItem *item1 = convertToLayoutItem(ctx, 0); + QGraphicsLayoutItem *item2 = convertToLayoutItem(ctx, 2); + + if (!item1 || !item2) { + return eng->undefinedValue(); + } + + QGraphicsAnchor *anchor = self->anchor(item1, static_cast(ctx->argument(1).toInt32()), + item2, static_cast(ctx->argument(3).toInt32())); + + return eng->newQObject(anchor, QScriptEngine::QtOwnership); +} END_DECLARE_METHOD + +BEGIN_DECLARE_METHOD(QGraphicsAnchorLayout, addAnchors) { + QGraphicsLayoutItem *item1 = convertToLayoutItem(ctx, 0); + QGraphicsLayoutItem *item2 = convertToLayoutItem(ctx, 1); + + if (!item1 || !item2) { + return eng->undefinedValue(); + } + + self->addAnchors(item1, item2, static_cast(ctx->argument(2).toInt32())); + return eng->undefinedValue(); +} END_DECLARE_METHOD BEGIN_DECLARE_METHOD(QGraphicsItem, toString) { return QScriptValue(eng, "QGraphicsAnchorLayout"); @@ -117,6 +142,8 @@ QScriptValue constructAnchorLayoutClass(QScriptEngine *eng) ADD_GET_SET_METHODS(proto, verticalSpacing, setVerticalSpacing); ADD_METHOD(proto, removeAt); ADD_METHOD(proto, addAnchor); + ADD_METHOD(proto, anchor); + ADD_METHOD(proto, addAnchors); ADD_METHOD(proto, toString); QScript::registerPointerMetaType(eng, proto);