aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/objects/KvsObject_checkBox.cpp
diff options
context:
space:
mode:
authorGravatar Szymon Tomasz Stefanek2011-01-01 20:19:56 +0000
committerGravatar Szymon Tomasz Stefanek2011-01-01 20:19:56 +0000
commitc601b5a27f74b16158adafe429faefbe573e64a2 (patch)
treea3cde3206a45628f8ac86e8dfbdab70b20c3a831 /src/modules/objects/KvsObject_checkBox.cpp
parentprobable compilation fix for rijndaled/crypto++ (diff)
downloadKVIrc-c601b5a27f74b16158adafe429faefbe573e64a2.tar.gz
KVIrc-c601b5a27f74b16158adafe429faefbe573e64a2.tar.bz2
KVIrc-c601b5a27f74b16158adafe429faefbe573e64a2.zip
The big rename for modules. Still some details remaining.
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5284 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/objects/KvsObject_checkBox.cpp')
-rw-r--r--src/modules/objects/KvsObject_checkBox.cpp136
1 files changed, 136 insertions, 0 deletions
diff --git a/src/modules/objects/KvsObject_checkBox.cpp b/src/modules/objects/KvsObject_checkBox.cpp
new file mode 100644
index 000000000..53f11fda7
--- /dev/null
+++ b/src/modules/objects/KvsObject_checkBox.cpp
@@ -0,0 +1,136 @@
+//=============================================================================
+//
+// File : KvsObject_checkBox.cpp
+// Creation date : Wed 13 Sep 2000 02:42:05 CEST by Krzysztof Godlewski
+//
+// This file is part of the KVIrc irc client distribution
+// Copyright (C) 2000 Krzysztof Godlewski
+// Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+
+
+#include "KviError.h"
+#include "kvi_debug.h"
+#include "KviLocale.h"
+#include "KvsObject_checkBox.h"
+
+#include <QCheckBox>
+
+/*
+ @doc: checkbox
+ @title:
+ checkbox class
+ @type:
+ class
+ @short:
+ Check box with a text description
+ @inherits:
+ [class]object[/class]
+ [class]button[/class]
+ @description:
+ This widget provides a check box - it is a kind of a toggle
+ button. It can have two states: on (checked) and off
+ (unchecked).
+ @functions:
+ !fn: <bool> $isChecked()
+ Returns '1' if the check box is checked, '0' otherwise.[br]
+ See also [classfnc]$setChecked[/classfnc]().
+ !fn: $setChecked([<bChecked:bool>])
+ Sets the check box 'checked state' to <bool>.
+ See also [classfnc]$isChecked[/classfnc]().
+ !fn: $setText([<text:string>])
+ Sets the label text associated with the checkbox to <text>.[br]
+ !fn: $toggleEvent(<bToggled:bool>)
+ Called by KVIrc when the checkbox state is toggled.
+ The default implementation emits the toggled(<bool>) signal.
+*/
+
+//---------------------------------------------------------------------------------
+
+KVSO_BEGIN_REGISTERCLASS(KvsObject_checkBox,"checkbox","button")
+ KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_checkBox,setChecked)
+ KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_checkBox,isChecked)
+ KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_checkBox,toggleEvent)
+KVSO_END_REGISTERCLASS(KvsObject_checkBox)
+
+KVSO_BEGIN_CONSTRUCTOR(KvsObject_checkBox,KvsObject_button)
+
+KVSO_END_CONSTRUCTOR(KvsObject_checkBox)
+
+
+KVSO_BEGIN_DESTRUCTOR(KvsObject_checkBox)
+
+KVSO_END_CONSTRUCTOR(KvsObject_checkBox)
+
+bool KvsObject_checkBox::init(KviKvsRunTimeContext *,KviKvsVariantList *)
+{
+ QCheckBox * cb = new QCheckBox(parentScriptWidget());
+ cb->setObjectName(getName().toUtf8().data());
+ setObject(cb, true);
+ connect(cb,SIGNAL(toggled(bool)),this,SLOT(toggled(bool)));
+ connect(widget(),SIGNAL(clicked()),this,SLOT(slotClicked()));
+ return true;
+}
+
+KVSO_CLASS_FUNCTION(checkBox,isChecked)
+{
+ CHECK_INTERNAL_POINTER(widget())
+ c->returnValue()->setBoolean(((QCheckBox *)widget())->isChecked());
+ return true;
+}
+
+KVSO_CLASS_FUNCTION(checkBox,setChecked)
+{
+ CHECK_INTERNAL_POINTER(widget())
+ bool bChecked;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("bChecked",KVS_PT_BOOL,KVS_PF_OPTIONAL,bChecked)
+ KVSO_PARAMETERS_END(c)
+ ((QCheckBox *)widget())->setChecked(bChecked);
+ return true;
+}
+
+KVSO_CLASS_FUNCTION(checkBox,setText)
+{
+ CHECK_INTERNAL_POINTER(widget())
+ QString szText;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("<text>",KVS_PT_STRING,0,szText)
+ KVSO_PARAMETERS_END(c)
+ ((QCheckBox *)widget())->setText(szText);
+ return true;
+}
+
+KVSO_CLASS_FUNCTION(checkBox,toggleEvent)
+{
+ emitSignal("toggled",c,c->params());
+ return true;
+}
+
+//slots
+void KvsObject_checkBox::toggled(bool b)
+{
+ KviKvsVariantList params(new KviKvsVariant(b));
+ callFunction(this,"toggleEvent",&params);
+}
+
+
+#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES
+#include "m_KvsObject_checkBox.moc"
+#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES
+