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

List:       kde-devel
Subject:    [Fwd: QListView column resizing wrong - part II]
From:       "Ming Poon" <mingp () corel ! com>
Date:       1999-07-30 14:08:53
[Download RAW message or body]

FYI ...

-------- Original Message --------
Subject: QListView column resizing wrong - part II
Date: Fri, 30 Jul 1999 09:55:36 -0400
From: "Brian Rolfe" <brianr@corel.com>
To: qt-bugs@troll.no
CC: Ming Poon <mingp@corel.com>, Brian Jones <brianj@corel.com>
References: <3794CE4C.79C8FFC9@corel.com>

I just recently compiled a small test program using Qt 2.0 and only a
QListView.
I added two columns with a bunch of text to the list.

Note:  this bug is caused by the same problem listed below.

Size the two columns to different sizes.  Now change the size of the
first column by
dragging the middle slider, should work fine.
Now swap the positions of the two columns and again resize the first
column (middle
slider).
This problem wasn't seen in Qt 1.44 because the whole widget was
redrawn, but now that
you have "flicker free" resizing, the bug shows up.

As I said below, the problem originates in QHeader with the get/set
column sizes not
agreeing (read below).

Thanks
--Brian

Brian Rolfe wrote:

>         In QListView (Qt 1.44), when using the automatic column resizing when
> entering data, the columns are resized wrong if you move the headers.
>
>         Step one:       Add some data to a multi column list
>         Step two:       Move the columns around with the mouse
>         Step three:     Add some more data that has smaller entries (text width)
>
> Result:         The columns are resized improperly.
>
> What's happening is the code checks the width of the new data entered,
> and if larger, it resizes it to that size.  But if the call to
> columnWidth() returns the width from the wrong column, say a small
> column, then the new data entered will seem larger so it will go on to
> resize it to that size.  Problem being, it's now resized it to the new
> data which might be smaller than the data already in that column.
>
> Cause:
>         QListView is calling methods to get/set the column sizes in QHeader.
>         This is the code:
>
> int QHeader::cellSize( int i ) const
> {
>         int s = pSize( i );
> return s;
> }
>
> int QHeader::pSize( int i ) const
> {
>         return data->sizes[mapToLogical(i)];
> }
>
> void QHeader::setCellSize( int i, int s )
> {
>         data->sizes[i] = s;
> }
>
> As you can see, the "cellSize()", which calls "pSize()" calls
> "mapToLogical()" while the "setCellSize()" does not.
> This is the root of the problem.....but it can be fixed in QListView
>
> QListView code:
>
> int QListView::columnWidth( int c ) const
> {
>         return d->h->cellSize(c);
> }
>
> void QListView::setColumnWidth( int column, int w )
> {
>         ASSERT( column < d->h->count() );
>         if ( d->h->cellSize( column ) != w )
>         {
>                 d->h->setCellSize( column, w );
>                 d->h->update(); // ##### paul, QHeader::setCellSize should do this.
>         }
> }
>
> To fix, the columnWidth() method call mapToActual() to reverse the
> mapToLogical() call in QHeader.  Then make setColumnWidth() call
> columnWidth() to get the width.
>
> P.S.:  I briefly looked at Qt 2.0 and it's looks pretty much the same
> there.
>
> --Brian R

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

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