lib

eventaction.cpp

00001 /***************************************************************************
00002  * eventaction.cpp
00003  * This file is part of the KDE project
00004  * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this program; see the file COPYING.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  ***************************************************************************/
00019 
00020 #include "eventaction.h"
00021 #include "variant.h"
00022 
00023 //#include <qobject.h>
00024 //#include <kaction.h>
00025 
00026 using namespace Kross::Api;
00027 
00028 EventAction::EventAction(const QString& name, KAction* action)
00029     : Event<EventAction>(name.isEmpty() ? action->name() : name)
00030     , m_action(action)
00031 {
00032     addFunction("getText", &EventAction::getText);
00033     addFunction("setText", &EventAction::setText);
00034 
00035     addFunction("isEnabled", &EventAction::isEnabled);
00036     addFunction("setEnabled", &EventAction::setEnabled);
00037 
00038     addFunction("activate", &EventAction::activate);
00039 }
00040 
00041 EventAction::~EventAction()
00042 {
00043 }
00044 
00045 const QString EventAction::getClassName() const
00046 {
00047     return "Kross::Api::EventAction";
00048 }
00049 
00050 Object::Ptr EventAction::getText(List::Ptr)
00051 {
00052     return new Variant(m_action->text());
00053 }
00054 
00055 Object::Ptr EventAction::setText(List::Ptr args)
00056 {
00057     m_action->setText( Variant::toString(args->item(0)) );
00058     return 0;
00059 }
00060 
00061 Object::Ptr EventAction::isEnabled(List::Ptr)
00062 {
00063     return new Variant(m_action->isEnabled());
00064 }
00065 
00066 Object::Ptr EventAction::setEnabled(List::Ptr args)
00067 {
00068     m_action->setEnabled( Variant::toBool(args->item(0)) );
00069     return 0;
00070 }
00071 
00072 Object::Ptr EventAction::activate(List::Ptr)
00073 {
00074     m_action->activate();
00075     return 0;
00076 }
00077 
KDE Home | KDE Accessibility Home | Description of Access Keys