lib

eventaction.cpp
1/***************************************************************************
2 * eventaction.cpp
3 * This file is part of the KDE project
4 * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this program; see the file COPYING. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 ***************************************************************************/
19
20#include "eventaction.h"
21#include "variant.h"
22
23//#include <tqobject.h>
24//#include <tdeaction.h>
25
26using namespace Kross::Api;
27
28EventAction::EventAction(const TQString& name, TDEAction* action)
29 : Event<EventAction>(name.isEmpty() ? TQString(action->name()) : name)
30 , m_action(action)
31{
32 addFunction("getText", &EventAction::getText);
33 addFunction("setText", &EventAction::setText);
34
35 addFunction("isEnabled", &EventAction::isEnabled);
36 addFunction("setEnabled", &EventAction::setEnabled);
37
38 addFunction("activate", &EventAction::activate);
39}
40
44
45const TQString EventAction::getClassName() const
46{
47 return "Kross::Api::EventAction";
48}
49
50Object::Ptr EventAction::getText(List::Ptr)
51{
52 return new Variant(m_action->text());
53}
54
55Object::Ptr EventAction::setText(List::Ptr args)
56{
57 m_action->setText( Variant::toString(args->item(0)) );
58 return 0;
59}
60
61Object::Ptr EventAction::isEnabled(List::Ptr)
62{
63 return new Variant(m_action->isEnabled());
64}
65
66Object::Ptr EventAction::setEnabled(List::Ptr args)
67{
68 m_action->setEnabled( Variant::toBool(args->item(0)) );
69 return 0;
70}
71
72Object::Ptr EventAction::activate(List::Ptr)
73{
74 m_action->activate();
75 return 0;
76}
77
virtual ~EventAction()
Destructor.
EventAction(const TQString &name, TDEAction *action)
Constructor.
virtual const TQString getClassName() const
void addFunction(const TQString &name, FunctionPtr function)
Definition event.h:99
Event(const TQString &name)
Definition event.h:68
TDESharedPtr< List > Ptr
Shared pointer to implement reference-counting.
Definition list.h:46
TDESharedPtr< Object > Ptr
Shared pointer to implement reference-counting.
Definition object.h:56
Variant value to wrap a TQVariant into a Kross::Api::Value to enable primitive types like strings or ...
Definition variant.h:39
virtual const TQString toString()
Definition variant.cpp:41
static bool toBool(Object::Ptr object)
Try to convert the given Object into a boolean value.
Definition variant.cpp:128
virtual bool isEnabled() const
virtual TQString text() const
virtual void setText(const TQString &text)
The common Kross API used as common codebase.
Definition callable.h:33