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

void QAbstractItemView::mouseReleaseEvent ( QMouseEvent event  )  [protected, virtual, inherited]

This function is called with the given event when a mouse button is released while the cursor is inside the widget. It will emit the clicked() signal if an item was being pressed.

Reimplemented from QAbstractScrollArea.

Reimplemented in QHeaderView, QListView, and QTreeView.

Definition at line 1409 of file qabstractitemview.cpp.

References QAbstractItemView::activated(), QAbstractItemView::clicked(), QAbstractItemView::edit(), QAbstractItemView::indexAt(), QPersistentModelIndex::isValid(), QWidget::pos, QAbstractItemView::selectionCommand(), QAbstractItemView::setState(), QAbstractItemView::state(), QWidget::style(), and QAbstractItemView::visualRect().

Referenced by QTreeView::mouseReleaseEvent(), and QListView::mouseReleaseEvent().

{
    Q_D(QAbstractItemView);

    QPoint pos = event->pos();
    QPersistentModelIndex index = indexAt(pos);

    if (state() == EditingState) {
        if (d->isIndexValid(index) && d->sendDelegateEvent(index, event))
            d->viewport->update(visualRect(index));
        return;
    }

    setState(NoState);

    bool click = (index == d->pressedIndex && index.isValid());
    EditTrigger trigger = (click
                           && (event->button() & Qt::LeftButton)
                           && d->pressedAlreadySelected
                          ? SelectedClicked : NoEditTriggers);
    bool edited = edit(index, trigger, event);

    if (!edited && d->selectionModel)
        d->selectionModel->select(index, selectionCommand(index, event));

    if (click) {
        emit clicked(index);
        if (edited)
            return;
        if (style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this))
            emit activated(index);
    }
}


Generated by  Doxygen 1.6.0   Back to index