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

void QAbstractSpinBox::contextMenuEvent ( QContextMenuEvent event  )  [protected, virtual, inherited]

Reimplemented from QWidget.

Definition at line 1120 of file qabstractspinbox.cpp.

References QContextMenuEvent::globalPos(), QWidget::height(), QWidget::mapToGlobal(), QContextMenuEvent::pos(), QWidget::pos, QAction::setEnabled(), QAbstractSpinBox::stepBy(), QAbstractSpinBox::stepEnabled(), QWidget::width(), and QPoint::x().

{
#ifdef QT_NO_CONTEXTMENU
    Q_UNUSED(event);
#else
    Q_D(QAbstractSpinBox);

    d->reset();
    QPointer<QMenu> menu = d->edit->createStandardContextMenu();
    menu->addSeparator();
    const uint se = stepEnabled();
    QAction *up = menu->addAction(tr("&Step up"));
    up->setEnabled(se & StepUpEnabled);
    QAction *down = menu->addAction(tr("Step &down"));
    down->setEnabled(se & StepDownEnabled);

    const QPointer<QAbstractSpinBox> that = this;
    const QPoint pos = (event->reason() == QContextMenuEvent::Mouse)
        ? event->globalPos() : mapToGlobal(QPoint(event->pos().x(), 0)) + QPoint(width() / 2, height() / 2);
    const QAction *action = menu->exec(pos);
    delete static_cast<QMenu *>(menu);
    if (that) {
        if (action == up) {
            stepBy(1);
        } else if (action == down) {
            stepBy(-1);
        }
    }
    event->accept();
#endif // QT_NO_CONTEXTMENU
}


Generated by  Doxygen 1.6.0   Back to index