[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    [Fwd: qlistview bug]
From:       "Ming Poon" <mingp () corel ! com>
Date:       1999-08-10 18:50:58
[Download RAW message or body]

FYI ...

-------- Original Message --------
Subject: qlistview bug
Date: Tue, 10 Aug 1999 14:39:29 -0400
From: "Brian Rolfe" <brianr@corel.com>
To: qtbugs@troll.no
CC: Ming Poon <mingp@corel.com>, Brian Jones <brianj@corel.com>

I found another QListView bug.  It has to to with the automatic focus of
items when you type characters.
It happens in Qt 1.44, 2.0.1

When you start to type characters in a QListView, it starts at the
currentItem() and starts to look down the list and will restart at the
top on this condition:        <this is in CListView::keyPressEvent()>

                if (input.length() > 1 && d->currentPrefixTime.msecsTo(
now ) > 1500 )
                {
                    input.truncate( 0 );
                    keyItem = d->r;
                }

The problem is if you start your app and make a selection in the middle
of the list somewhere and then proceed to press chars that *would* cause
the focus to move to items above your current selection, it won't work.
Reason being, the data has not been set up  (input.length() == 0;
d->currentPrefixTime == undefined),
so it will never get into this if, and restart the search at the top.
The only way to get it to work is to type characters of items below your
current selection, to get the input saved and the timer going.  Then you
can proceed to move the focus around properly.

The easiest solution is to have:

     static bool bFirst = true;
     if (bFirst || (input.length() > 1 &&
d->currentPrefixTime.msecsTo(now) > 1500))
     {
          if (bFirst)
          {
              bFirst = false;
          }
          input.truncate(0);
          keyItem = d->r;
     }

This will cause it to restart at the top of the list and the data will
get set up.

OR:  You could setup the data in CListView's constructor:
            set  d->currentPrefixTime  to current time
            && set  input  to something with length 1    (like  " ")

--Brian R

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic