[Kst] extragear/graphics/kst/kst/extensions/js
George Staikos
staikos at kde.org
Tue Dec 6 06:18:02 CET 2005
SVN commit 485913 by staikos:
allow the user to reparent/move view objects in the hierarchy
M +27 -1 bind_viewobjectcollection.cpp
M +1 -0 bind_viewobjectcollection.h
M +2 -2 js.cpp
--- trunk/extragear/graphics/kst/kst/extensions/js/bind_viewobjectcollection.cpp #485912:485913
@@ -20,6 +20,7 @@
#include <qdeepcopy.h>
+#include <kst.h>
#include <kstviewobject.h>
#include <kdebug.h>
@@ -31,7 +32,7 @@
KstBindViewObjectCollection::KstBindViewObjectCollection(KJS::ExecState *exec, KstViewObjectPtr parent)
-: KstBindCollection(exec, "ViewObjectCollection", true), _parent(parent) {
+: KstBindCollection(exec, "ViewObjectCollection", false), _parent(parent) {
}
@@ -100,4 +101,29 @@
}
+KJS::Value KstBindViewObjectCollection::append(KJS::ExecState *exec, const KJS::List& args) {
+ if (args.size() != 1) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError);
+ exec->setException(eobj);
+ return KJS::Undefined();
+ }
+
+ if (_parent) {
+ KstViewObjectPtr c = extractViewObject(exec, args[0]);
+ if (!c) {
+ return KJS::Undefined();
+ }
+
+ KstWriteLocker rl(_parent);
+ c->detach();
+ _parent->appendChild(c);
+ _parent->setDirty();
+ KstApp::inst()->paintAll(KstPainter::P_PAINT);
+ return KJS::Undefined();
+ }
+
+ return KstBindCollection::append(exec, args);
+}
+
+
// vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/extensions/js/bind_viewobjectcollection.h #485912:485913
@@ -41,6 +41,7 @@
virtual QStringList collection(KJS::ExecState *exec) const;
virtual KJS::Value extract(KJS::ExecState *exec, const KJS::Identifier& item) const;
virtual KJS::Value extract(KJS::ExecState *exec, unsigned item) const;
+ virtual KJS::Value append(KJS::ExecState *exec, const KJS::List& args);
protected:
KstViewObjectList _objects;
--- trunk/extragear/graphics/kst/kst/extensions/js/js.cpp #485912:485913
@@ -319,8 +319,8 @@
KstJSUIHelper::KstJSUIHelper(const QString& ui, KstJS *js)
- : KXMLGUIClient(), _js(js), _ui(ui) {
- setInstance(_js->app()->instance());
+: KXMLGUIClient(), _js(js), _ui(ui) {
+ setInstance(_js->app()->instance());
}
More information about the Kst
mailing list