Logo Search packages:      
Sourcecode: qt4-x11 version File versions

void QListView::dragMoveEvent ( QDragMoveEvent e  )  [protected, virtual, inherited]

Reimplemented from QAbstractItemView.

Definition at line 857 of file qlistview.cpp.

References QDragMoveEvent::accept(), QAbstractItemView::dragMoveEvent(), QDragMoveEvent::ignore(), QListView::indexAt(), QModelIndex::isValid(), QDropEvent::pos(), QDropEvent::source(), QAbstractItemView::startAutoScroll(), and QRect::translated().

{
    Q_D(QListView);
    if (e->source() == this && d->movement != Static) {
        // the ignore by default
        e->ignore();
        if (d->canDecode(e)) {
            // get old dragged items rect
            QRect itemsRect = d->itemsRect(d->draggedItems);
            d->setDirtyRegion(itemsRect.translated(d->draggedItemsDelta()));
            // update position
            d->draggedItemsPos = e->pos();
            // get new items rect
            d->setDirtyRegion(itemsRect.translated(d->draggedItemsDelta()));
            // set the item under the cursor to current
            QModelIndex index = indexAt(e->pos());
            // check if we allow drops here
            if (e->source() == this && d->draggedItems.contains(index))
                e->accept(); // allow changing item position
            else if (d->model->flags(index) & Qt::ItemIsDropEnabled)
                e->accept(); // allow dropping on dropenabled items
            else if (!index.isValid())
                e->accept(); // allow dropping in empty areas
        }
        // do autoscrolling
        if (d->shouldAutoScroll(e->pos()))
            startAutoScroll();
    } else { // not internal
        QAbstractItemView::dragMoveEvent(e);
    }
}


Generated by  Doxygen 1.6.0   Back to index