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

List:       kde-devel
Subject:    Re: Moving a QListViewItem
From:       Peter Putzer <pputzer () edu ! uni-klu ! ac ! at>
Date:       2000-06-02 8:45:36
[Download RAW message or body]

On Fri, 2 Jun 2000, Reginald Stadlbauer wrote:

> On Fri, 02 Jun 2000, Charles wrote:
> > On Thu, 01 Jun 2000, you wrote:
> > > On Fri, 02 Jun 2000, Charles wrote:
> > > > Does anyone have an idea on how to move a QListViewItem safely?
> > > >
> > > > Just copying the strings in a QListViewItem makes it impossible to
> > > > handle if the item has an image, or someone has created their own
> > > > QListViewItem (class MyItem : public QListViewItem).  I need a generic
> > > > way of doing this?
> > > >
> > > > See if you can finish this function :)
> > >
> > > /* Insert documentation here, what is this method meant to do?  */
> > >
> > > > void KListView::moveItem(QListViewItem *item, QListViewItem *after)
> > > > {
> > >
> > > // insert sanity checks
> > >       if (item->parent())
> > >          item->parent()->takeItem( item )
> > >      else
> > >          takeItem( item );
> > >
> > >      if (after)
> > >          after->insertItem( item );
> > >      else
> > >          insertItem( item );
> > >
> > > > }
> >
> > The issue with this is that "after" is the item that you insert it after,
> > not under.
> 
> Then you can do it with using soring for that or moving the contents (string 
> + pixmap). 

Yes but that only works for "plain" QListViewItems, not for any fancy
custom items, so I guess it's rather useless.

I was annoyed by QListView's inability to move items when I made my
generic DND-capable listview for KSysV (kdeadmin/ksysv/kndraglist.{h,cpp}
and kdeadmin/ksysv/ksvdraglist.{h,cpp}), but I'm now convinced that
overriding QListViewItem::key is the correct solution for most
situations.

Although a moveToJustBelow (QListViewItem*) - or something similar - would
be nice, too.

bye,
Peter

 
>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

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

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