aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/objects/class_listbox.cpp
diff options
context:
space:
mode:
authorGravatar Noldor2007-01-01 19:50:17 +0000
committerGravatar Noldor2007-01-01 19:50:17 +0000
commitb7bada5b68c7ac4740f519b5c3d5a9b6f2d97841 (patch)
tree65cafd8794aeb5d329da095c8a5ccd31a851b04e /src/modules/objects/class_listbox.cpp
parent*AUTOMATICALLY* updated KVI_SOURCES_DATE variable (diff)
downloadKVIrc-b7bada5b68c7ac4740f519b5c3d5a9b6f2d97841.tar.gz
KVIrc-b7bada5b68c7ac4740f519b5c3d5a9b6f2d97841.tar.bz2
KVIrc-b7bada5b68c7ac4740f519b5c3d5a9b6f2d97841.zip
wip on dynamic tool tips in objects module(still incomplete, bugged and undocumented :D)
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@86 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/objects/class_listbox.cpp')
-rw-r--r--src/modules/objects/class_listbox.cpp49
1 files changed, 48 insertions, 1 deletions
diff --git a/src/modules/objects/class_listbox.cpp b/src/modules/objects/class_listbox.cpp
index 077114e9e..cbfe3bc83 100644
--- a/src/modules/objects/class_listbox.cpp
+++ b/src/modules/objects/class_listbox.cpp
@@ -2,7 +2,7 @@
// File : class_listbox.cpp
// Creation date : Sat Oct 2 03:40:28 CET 2004 by Szymon Stefanek
//
-// This file is part of the KVirc irc client distribution
+// This file is part of the KVirc irc client distribution
// Copyright (C) 2004 Szymon Stefanek (pragma at kvirc dot net)
//
// This program is FREE software. You can redistribute it and/or
@@ -113,6 +113,8 @@ KVSO_BEGIN_REGISTERCLASS(KviKvsObject_listbox,"listbox","widget")
KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"currentText", functioncurrentText)
KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"currentItem", functioncurrentItem)
KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"textAt", functiontextAt);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"itemAt", functionitemAt);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"itemRect", functionitemRect);
KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"setCurrentItem", functionsetCurrentItem);
@@ -121,6 +123,7 @@ KVSO_BEGIN_REGISTERCLASS(KviKvsObject_listbox,"listbox","widget")
KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"setSelected",functionsetSelected);
KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"isSelected",functionisSelected);
KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"currentItemChangeEvent",functioncurrentItemChangeEvent);
+ KVSO_REGISTER_HANDLER(KviKvsObject_listbox,"currentnItemEvent",functiononItemEvent);
KVSO_REGISTER_STANDARD_NOTHINGRETURN_HANDLER(KviKvsObject_listbox,"selectionChangeEvent")
@@ -142,6 +145,9 @@ bool KviKvsObject_listbox::init(KviKvsRunTimeContext * pContext,KviKvsVariantLis
b->setSelectionMode(QListBox::Single);
connect(b,SIGNAL(selectionChanged()),this,SLOT(selectionChanged()));
connect(b,SIGNAL(currentChanged(QListBoxItem *)),this,SLOT(currentItemChanged(QListBoxItem *)));
+
+ connect(b,SIGNAL(onItem(QListBoxItem *)),this,SLOT(onItem(QListBoxItem *)));
+
setObject(b,true);;
return true;
}
@@ -302,6 +308,17 @@ bool KviKvsObject_listbox::functionsetSelected(KviKvsObjectFunctionCall *c)
if(widget()) ((QListBox *)widget())->setSelected(uIndex,bSel);
return true;
}
+bool KviKvsObject_listbox::functionitemAt(KviKvsObjectFunctionCall *c)
+{
+ kvs_uint_t uX,uY;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("uX",KVS_PT_UNSIGNEDINTEGER,0,uX)
+ KVSO_PARAMETER("uY",KVS_PT_UNSIGNEDINTEGER,0,uY)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ c->returnValue()->setInteger(((QListBox *)widget())->index(((QListBox *)widget())->itemAt(QPoint(uX,uY))));
+ return true;
+}
bool KviKvsObject_listbox::functioncurrentItemChangeEvent(KviKvsObjectFunctionCall *c)
{
@@ -326,8 +343,38 @@ void KviKvsObject_listbox::currentItemChanged(QListBoxItem *item)
}
}
+bool KviKvsObject_listbox::functiononItemEvent(KviKvsObjectFunctionCall *c)
+{
+ emitSignal("onItem",c,c->params());
+ return true;
+}
+void KviKvsObject_listbox::onItem(QListBoxItem *item)
+{
+ KviKvsVariantList params(new KviKvsVariant(item->text()));
+ callFunction(this,"onItemEvent",0,&params);
+}
+
+
+bool KviKvsObject_listbox::functionitemRect(KviKvsObjectFunctionCall *c)
+{
+kvs_uint_t uIndex;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("uIndex",KVS_PT_UNSIGNEDINTEGER,0,uIndex)
+ KVSO_PARAMETERS_END(c)
+ if(widget())
+ {
+ QRect rect=((QListBox *)widget())->itemRect(((QListBox *)widget())->item(uIndex));
+ KviKvsArray * a = new KviKvsArray();
+ a->set(0,new KviKvsVariant((kvs_int_t)rect.left()));
+ a->set(1,new KviKvsVariant((kvs_int_t)rect.top()));
+ a->set(2,new KviKvsVariant((kvs_int_t)rect.bottom()));
+ a->set(3,new KviKvsVariant((kvs_int_t)rect.right()));
+ c->returnValue()->setArray(a);
+ }
+ return true;
+}