List Info

Thread: listbox setSelection patch




listbox setSelection patch
country flaguser name
United States
2008-03-26 21:23:42
Hi,
I had to create a listbox with preselected items and wasn't
able to do it with 
any recent release of kommander so I made the simple
attached patch that 
modifies the behaviour of setSelection. Maybe it makes sense
to merge it 
upstream.

Cheers,
Silvan

-- 
mambaSoft
http://www.mambasoft.it

openmamba GNU/Linux development  http://www.openmamba.org


_______________________________________________
Kommander-devel mailing list
Kommander-develmail.kdewebdev.org
http://mail.kdewebdev.org/mailman/listinfo/kommander-d
evel

  
Re: listbox setSelection patch
country flaguser name
United States
2008-03-26 22:24:49
On Wednesday 26 March 2008 7:23:42 pm Silvan Calarco wrote:
> Hi,
> I had to create a listbox with preselected items and
wasn't able to do it
> with any recent release of kommander so I made the
simple attached patch
> that modifies the behaviour of setSelection. Maybe it
makes sense to merge
> it upstream.
>
> Cheers,
> Silvan

Interesting, but wouldn't it make a LOT more sense for an
add uniqe item 
entry? I'm open to developer suggestions for adapting this
into the KDE4 
version because it is a nice behavior, provided you're
expecting it. I'm 
tending to think it needs it's own specific function.

Thanks for the patch! I like seeing creative input. 

-- 
Eric Laffoon
Project Lead - kdewebdev module
_______________________________________________
Kommander-devel mailing list
Kommander-develmail.kdewebdev.org
http://mail.kdewebdev.org/mailman/listinfo/kommander-d
evel

Re: listbox setSelection patch
country flaguser name
United States
2008-03-27 09:07:31
Hi Eric,
well looking at the code the setSelection and setCurrentItem
call the same 
function (setCurrentItem):

    case DCOP::setSelection:
    {
      QListBoxItem* found = findItem(args[0],
Qt::ExactMatch);
      if (found)
        setCurrentItem(index(found));
      break;
    }

    case DCOP::setCurrentItem:
    {
      int index = args[0].toInt();
      if (index < (int)count())
        setCurrentItem(index);
      break;
    }

The only difference is in the argument (the index versus the
string). 
As the QT functions name suggests I thought it was more
clear that:

setCurrentItem calls QT's setCurrentItem
setSelection calls QT's setSelected

Furthermore the setCurrentItem listbox function just moves
the keyboard 
pointer to the item (the listed item is , but does not
select it, so 
it's "partially" selected as reported in this old
post:

http://mail.kdewebdev.org/pipermail/komm
ander/2006-September/001436.html
) so I think the current implementation is far as useful as
the setSelected 
function and it's different from user expectations. 
Finally adding a "setSelected" function would be
ok too, but I still would 
find incoherent the association betweek setSelection and
setCurrentItem.
Thank you for your interest in this issue.

Cheers,
Silvan

Alle giovedě 27 marzo 2008, Eric Laffoon ha scritto:
> On Wednesday 26 March 2008 7:23:42 pm Silvan Calarco
wrote:
> > Hi,
> > I had to create a listbox with preselected items
and wasn't able to do it
> > with any recent release of kommander so I made the
simple attached patch
> > that modifies the behaviour of setSelection. Maybe
it makes sense to
> > merge it upstream.
> >
> > Cheers,
> > Silvan
>
> Interesting, but wouldn't it make a LOT more sense for
an add uniqe item
> entry? I'm open to developer suggestions for adapting
this into the KDE4
> version because it is a nice behavior, provided you're
expecting it. I'm
> tending to think it needs it's own specific function.
>
> Thanks for the patch! I like seeing creative input.




-- 
mambaSoft
Via Barletta 90 - 10136 Torino
Tel: +39 011 5694078
E-mail: silvan.calarcomambasoft.it
Web: http://www.mambasoft.it

openmamba GNU/Linux development  http://www.openmamba.org

_______________________________________________
Kommander-devel mailing list
Kommander-develmail.kdewebdev.org
http://mail.kdewebdev.org/mailman/listinfo/kommander-d
evel

Re: listbox setSelection patch
country flaguser name
United States
2008-03-27 14:09:19
Hi Silvan,

On Thursday 27 March 2008 7:07:31 am Silvan Calarco wrote:
> Hi Eric,
> well looking at the code the setSelection and
setCurrentItem call the same
> function (setCurrentItem):
>
>     case DCOP::setSelection:
>     {
>       QListBoxItem* found = findItem(args[0],
Qt::ExactMatch);
>       if (found)
>         setCurrentItem(index(found));
>       break;
>     }
>
>     case DCOP::setCurrentItem:
>     {
>       int index = args[0].toInt();
>       if (index < (int)count())
>         setCurrentItem(index);
>       break;
>     }
>
> The only difference is in the argument (the index
versus the string).
> As the QT functions name suggests I thought it was more
clear that:
>
> setCurrentItem calls QT's setCurrentItem
> setSelection calls QT's setSelected
>
> Furthermore the setCurrentItem listbox function just
moves the keyboard
> pointer to the item (the listed item is , but does not
select it, so
> it's "partially" selected as reported in this
old post:
>
> http://mail.kdewebdev.org/pipermail/komm
ander/2006-September/001436.html
> ) so I think the current implementation is far as
useful as the setSelected
> function and it's different from user expectations.
> Finally adding a "setSelected" function would
be ok too, but I still would
> find incoherent the association betweek setSelection
and setCurrentItem.
> Thank you for your interest in this issue.
>
> Cheers,
> Silvan

Well since you put it that way it does seem a little broken.
I am probably 
responsible as I remember vaguely Michal asking about this
years ago. As a 
heavy Kommander user (or is that ham-fisted?) I find I need
to access either 
the index or selected text of a dialog at different times
for the same 
purpose. Also I have signals and slots set up to do things
with them 
that "come undone" for instance on initialization,
so I need to call them. 
Not the same, but I probably should look at the docs and
ponder. Of course 
the problem is that what we end up with is either allowing
diverse behaviors 
the become confusing or forcing some people to accept
something they don't 
want. One inherent truth is that Kommander is a little
different than regular 
programming, so every issue needs to be looked at without
preconceptions for 
find the best solution. From what you say something needs to
be done... the 
question is what. I also added functionality recently to
this widget and in 
the interest of fair play I'm posting the diff here if you
are interested.

Here's the inpetus for this patch. I created a data table
where the table 
widget has a data value showing in a column. When a user
clicks in that 
column a created combo appears. This combo is fed by
complimentary arrays (a 
good reason to make another patch) and feeds the database
key value to a 
hidden column using signals and slots and a created script.
Clicking outside 
the cell causes the widget to disappear and the selected
text to be written 
to the cell, thus destroying the widget until it is
recreated.

The problems arose using keyboard entry. AFAIK there is no
way to tab to a 
ComboBox and manually change it's selection. So I created a
Kommander 
function to popup the list which you can call. Maybe I
should have added a 
gotFocus slot. It's easy to detect in the table anyway.

Focus events can be easily added as they are inherited from
QWidget
===textedit.h
signals:
  void lostFocus();
  void gotFocus();
===textedit.cpp
void TextEdit::focusOutEvent( QFocusEvent * e)
{
  QTextEdit::focusOutEvent(e);
  emit lostFocus();
}

void TextEdit::focusInEvent( QFocusEvent * e)
{
  QTextEdit::focusInEvent(e);
  emit gotFocus();
}

I think I should insure focus events for all widgets  in
KDE4.
-- 
Eric Laffoon
Project Lead - kdewebdev module

_______________________________________________
Kommander-devel mailing list
Kommander-develmail.kdewebdev.org
http://mail.kdewebdev.org/mailman/listinfo/kommander-d
evel

  
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )