• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

kjsembed

  • kjsembed
  • kjsembed
qaction_binding.cpp
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org>
3 Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com>
4 Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org>
5 Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22#include "qaction_binding.h"
23#include "static_binding.h"
24#include "kjseglobal.h"
25
26#include <kjs/object.h>
27#include <QtCore/QDebug>
28
29#include <QtGui/QAction>
30#include <QtUiTools/QUiLoader>
31
32namespace KJSEmbed
33{
34 QUiLoader *uiLoader();
35}
36
37
38using namespace KJSEmbed;
39
40NO_METHODS( Action )
41NO_ENUMS( Action )
42NO_STATICS( Action )
43
44KJSO_SIMPLE_BINDING_CTOR( Action, QAction, QObjectBinding )
45KJSO_QOBJECT_BIND( Action, QAction )
46
47KJSO_START_CTOR( Action, QAction, 0 )
48 QObject *parent = KJSEmbed::extractObject<QObject>(exec, args, 0, 0);
49 QString actionName = KJSEmbed::extractQString(exec, args, 1);
50
51 QAction *action = uiLoader()->createAction(parent, actionName);
52 if( action )
53 {
54 KJS::JSObject *actionObject = new Action( exec, action );
55 return actionObject;
56 }
57 else
58 {
59 return KJS::throwError(exec, KJS::GeneralError, i18n("Action takes 2 args."));
60 }
61KJSO_END_CTOR
62
63
64
65NO_METHODS( ActionGroup )
66NO_ENUMS( ActionGroup )
67NO_STATICS( ActionGroup )
68
69KJSO_SIMPLE_BINDING_CTOR( ActionGroup, QActionGroup, QObjectBinding )
70KJSO_QOBJECT_BIND( ActionGroup, QActionGroup )
71
72KJSO_START_CTOR( ActionGroup, QActionGroup, 0 )
73 if( args.size() == 2 )
74 {
75 QObject *parent = KJSEmbed::extractObject<QObject>(exec, args, 0, 0);
76 QString actionName = KJSEmbed::extractQString(exec, args, 1);
77
78 QActionGroup *action = uiLoader()->createActionGroup(parent, actionName);
79 if( action )
80 {
81 KJS::JSObject *actionObject = new ActionGroup( exec, action );
82 return actionObject;
83 }
84 else
85 {
86 return KJS::throwError(exec, KJS::GeneralError, i18n("ActionGroup takes 2 args."));
87 // return KJSEmbed::throwError(exec, i18n("ActionGroup takes 2 args."));
88 }
89 }
90 // Trow error incorrect args
91 return KJS::throwError(exec, KJS::GeneralError, i18n("Must supply a valid parent."));
92 // return KJSEmbed::throwError(exec, i18n("Must supply a valid parent."));
93END_CTOR
94
95//kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
END_CTOR
#define END_CTOR
Definition: binding_support.h:166
NO_ENUMS
#define NO_ENUMS(TYPE)
Definition: binding_support.h:147
KJSO_START_CTOR
#define KJSO_START_CTOR(TYPE, JSNAME, ARGS)
Definition: binding_support.h:169
NO_STATICS
#define NO_STATICS(TYPE)
Definition: binding_support.h:153
KJSO_QOBJECT_BIND
#define KJSO_QOBJECT_BIND(NAME, TYPE)
Definition: binding_support.h:205
NO_METHODS
#define NO_METHODS(TYPE)
Definition: binding_support.h:150
KJSO_SIMPLE_BINDING_CTOR
#define KJSO_SIMPLE_BINDING_CTOR(NAME, TYPE, BASENAME)
Definition: binding_support.h:113
KJSO_END_CTOR
#define KJSO_END_CTOR
Definition: binding_support.h:178
KJSEmbed::QObjectBinding
Definition: qobject_binding.h:80
QObject
kjseglobal.h
KJSEmbed
Definition: application.h:33
KJSEmbed::extractQString
QString KJSEMBED_EXPORT extractQString(KJS::ExecState *exec, const KJS::List &args, int idx, const QString defaultValue=QString())
Extracts a QString from an argument list.
Definition: binding_support.cpp:34
KJSEmbed::uiLoader
QUiLoader * uiLoader()
Definition: qwidget_binding.cpp:41
KJSEmbed::extractObject
T * extractObject(KJS::ExecState *exec, KJS::JSValue *arg, T *defaultValue)
Extracts a pointer based type from an ObjectBinding object.
Definition: object_binding.h:158
KJS::throwError
JSObject * throwError(ExecState *e, ErrorType t, const QString &m)
Definition: binding_support.h:241
actionName
QString actionName
Definition: qaction_binding.cpp:49
action
QAction * action
Definition: qaction_binding.cpp:51
if
if(action)
Definition: qaction_binding.cpp:52
parent
QObject * parent
Definition: qaction_binding.cpp:48
qaction_binding.h
static_binding.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kjsembed

Skip menu "kjsembed"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal