aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Noldor732016-04-24 08:37:05 +0200
committerGravatar Noldor732016-04-24 08:37:05 +0200
commitc9c241d28fa173316d64adf7024494da34336f16 (patch)
treef94a662146e9fffc9ed146803dd87a28660e5350
parentCode fix/enhancements in KVS class tablewidget (diff)
downloadKVIrc-c9c241d28fa173316d64adf7024494da34336f16.tar.gz
KVIrc-c9c241d28fa173316d64adf7024494da34336f16.tar.bz2
KVIrc-c9c241d28fa173316d64adf7024494da34336f16.zip
Fix setCompleter function in KVS class lineedit
-rw-r--r--src/modules/objects/KvsObject_lineEdit.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/modules/objects/KvsObject_lineEdit.cpp b/src/modules/objects/KvsObject_lineEdit.cpp
index f6ccd00c3..20a480389 100644
--- a/src/modules/objects/KvsObject_lineEdit.cpp
+++ b/src/modules/objects/KvsObject_lineEdit.cpp
@@ -168,7 +168,7 @@ static const int mode_cod[] = {
Called when the lineedit lost focus.
!fn: $textChangedEvent(<new text:string>)
This event is called when the text changed, In $0 there is the new text.
- !fn: $setCompleter(<completion_mode:string>,<items:stringlist>)
+ !!fn: $setCompleter(<completion_mode:string>,<completition_list:array>)
Provides completions based on an stringlist.
Valid completion_mode are:
PopupCompletion: Current completions are displayed in a popup below the lineedit.
@@ -451,20 +451,38 @@ KVSO_CLASS_FUNCTION(lineEdit,setInputMask)
KVSO_CLASS_FUNCTION(lineEdit,setCompleter)
{
CHECK_INTERNAL_POINTER(widget())
- QStringList szCompletionList;
+ KviKvsArray *a;
QString szMode;
KVSO_PARAMETERS_BEGIN(c)
KVSO_PARAMETER("mode",KVS_PT_STRING,KVS_PF_OPTIONAL,szMode)
- KVSO_PARAMETER("completion_list",KVS_PT_STRINGLIST,0,szCompletionList)
+ KVSO_PARAMETER("completion_list",KVS_PT_ARRAY,0,a)
KVSO_PARAMETERS_END(c)
if(m_pCompleter)
delete m_pCompleter;
+ QStringList szCompletionList;
+ if(a)
+ {
+ kvs_int_t uIdx = 0;
+ kvs_int_t uSize = a->size();
+ while(uIdx < uSize)
+ {
+ KviKvsVariant * v = a->at(uIdx);
+ if(v)
+ {
+ QString tmp;
+ v->asString(tmp);
+ szCompletionList.append(tmp);
+ }
+ else szCompletionList.append("");
+ uIdx++;
+ }
+ }
m_pCompleter=new QCompleter(szCompletionList);
QCompleter::CompletionMode mode=QCompleter::PopupCompletion;
if(KviQString::equalCI(szMode,"InlineCompletion")) mode=QCompleter::InlineCompletion;
else if(KviQString::equalCI(szMode,"UnfilteredPopupCompletion")) mode=QCompleter::UnfilteredPopupCompletion;
else if(!KviQString::equalCI(szMode,"PopupCompletion"))
- c->warning(__tr2qs_ctx("Unknown '%Q' completion mode, switching to default PopupCompletion","objects"),&szMode);
+ c->warning(__tr2qs_ctx("Unkonwn '%Q' completition mode, switching to default popupCompletition","objects"),&szMode);
m_pCompleter->setCompletionMode(mode);
((QLineEdit *)widget())->setCompleter(m_pCompleter);
return true;