void ListBoxDnd::updateLine( const QPoint & dragPos ) { QListBox * src = (QListBox *) this->src; QListBoxItem *item = itemAt( dragPos ); int ypos = item ? ( src->itemRect( item ).bottom() - ( line->height() / 2 ) ) : ( src->itemRect( ((QListBox *)src)->firstItem() ).top() ); line->resize( src->viewport()->width(), line->height() ); line->move( 0, ypos ); }
QListBoxItem * ListBoxDnd::itemAt( QPoint pos ) { QListBox * src = (QListBox *) this->src; QListBoxItem * result = src->itemAt( pos ); QListBoxItem * last = src->item( src->count() - 1 ); int i = src->index( result ); if ( result && ( pos.y() < (src->itemRect(result).top() + src->itemHeight(i)/2) ) ) result = result->prev(); else if ( !result && pos.y() > src->itemRect( last ).bottom() ) result = last; return result; }