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, Object::Ptr parent, KAction* action)
00029     : Event<EventAction>(name.isEmpty() ? action->name() : name, parent)
00030     , m_action(action)
00031 {
00032     addFunction("getText", &EventAction::getText);
00033     addFunction("setText", &EventAction::setText,
00034         Kross::Api::ArgumentList() << Kross::Api::Argument("Kross::Api::Variant::String"));
00035 
00036     addFunction("isEnabled", &EventAction::isEnabled);
00037     addFunction("setEnabled", &EventAction::setEnabled,
00038         Kross::Api::ArgumentList() << Kross::Api::Argument("Kross::Api::Variant::Bool"));
00039 
00040     addFunction("activate", &EventAction::activate);
00041 }
00042 
00043 EventAction::~EventAction()
00044 {
00045 }
00046 
00047 const QString EventAction::getClassName() const
00048 {
00049     return "Kross::Api::EventAction";
00050 }
00051 
00052 /*
00053 Object::Ptr EventAction::call(const QString& name, KSharedPtr<List> arguments)
00054 {
00055     kdDebug() << QString("=============> EventAction::call() name=%1 arguments=%2").arg(name).arg(arguments->toString()) << endl;
00056     //TODO
00057     return 0;
00058 }
00059 */
00060 
00061 Object::Ptr EventAction::getText(List::Ptr)
00062 {
00063     return new Variant(m_action->text(), "Kross::Api::EventAction::getText::String");
00064 }
00065 
00066 Object::Ptr EventAction::setText(List::Ptr args)
00067 {
00068     m_action->setText( Variant::toString(args->item(0)) );
00069     return 0;
00070 }
00071 
00072 Object::Ptr EventAction::isEnabled(List::Ptr)
00073 {
00074     return new Variant(m_action->isEnabled(), "Kross::Api::EventAction::isEnabled::Bool");
00075 }
00076 
00077 Object::Ptr EventAction::setEnabled(List::Ptr args)
00078 {
00079     m_action->setEnabled( Variant::toBool(args->item(0)) );
00080     return 0;
00081 }
00082 
00083 Object::Ptr EventAction::activate(List::Ptr)
00084 {
00085     m_action->activate();
00086     return 0;
00087 }
00088 
KDE Home | KDE Accessibility Home | Description of Access Keys