kjsembed
qaction_binding.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "qaction_binding.h"
00023 #include "static_binding.h"
00024 #include "kjseglobal.h"
00025
00026 #include <kjs/object.h>
00027 #include <QtCore/QDebug>
00028
00029 #include <QtGui/QAction>
00030 #include <QtUiTools/QUiLoader>
00031
00032 namespace KJSEmbed
00033 {
00034 QUiLoader *uiLoader();
00035 }
00036
00037
00038 using namespace KJSEmbed;
00039
00040 NO_METHODS( Action )
00041 NO_ENUMS( Action )
00042 NO_STATICS( Action )
00043
00044 KJSO_SIMPLE_BINDING_CTOR( Action, QAction, QObjectBinding )
00045 KJSO_QOBJECT_BIND( Action, QAction )
00046
00047 KJSO_START_CTOR( Action, QAction, 0 )
00048 QObject *parent = KJSEmbed::extractObject<QObject>(exec, args, 0, 0);
00049 QString actionName = KJSEmbed::extractQString(exec, args, 1);
00050
00051 QAction *action = uiLoader()->createAction(parent, actionName);
00052 if( action )
00053 {
00054 KJS::JSObject *actionObject = new Action( exec, action );
00055 return actionObject;
00056 }
00057 else
00058 {
00059 return KJS::throwError(exec, KJS::GeneralError, i18n("Action takes 2 args."));
00060 }
00061 KJSO_END_CTOR
00062
00063
00064
00065 NO_METHODS( ActionGroup )
00066 NO_ENUMS( ActionGroup )
00067 NO_STATICS( ActionGroup )
00068
00069 KJSO_SIMPLE_BINDING_CTOR( ActionGroup, QActionGroup, QObjectBinding )
00070 KJSO_QOBJECT_BIND( ActionGroup, QActionGroup )
00071
00072 KJSO_START_CTOR( ActionGroup, QActionGroup, 0 )
00073 if( args.size() == 2 )
00074 {
00075 QObject *parent = KJSEmbed::extractObject<QObject>(exec, args, 0, 0);
00076 QString actionName = KJSEmbed::extractQString(exec, args, 1);
00077
00078 QActionGroup *action = uiLoader()->createActionGroup(parent, actionName);
00079 if( action )
00080 {
00081 KJS::JSObject *actionObject = new ActionGroup( exec, action );
00082 return actionObject;
00083 }
00084 else
00085 {
00086 return KJS::throwError(exec, KJS::GeneralError, i18n("ActionGroup takes 2 args."));
00087
00088 }
00089 }
00090
00091 return KJS::throwError(exec, KJS::GeneralError, i18n("Must supply a valid parent."));
00092
00093 END_CTOR
00094
00095