int QScriptDebuggerCodeViewInterface::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: breakpointToggleRequest((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 1: breakpointEnableRequest((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 2: toolTipRequest((*reinterpret_cast< const QPoint(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< const QStringList(*)>(_a[3]))); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
Exemple #2
0
void QScriptEdit::extraAreaMouseEvent(QMouseEvent *e)
{
    QTextCursor cursor = cursorForPosition(QPoint(0, e->pos().y()));
    cursor.setPosition(cursor.block().position());

    QFontMetrics fm(font());
    int markWidth = fm.lineSpacing();

    if (e->type() == QEvent::MouseMove && e->buttons() == 0) { // mouse tracking
        bool hand = (e->pos().x() <= markWidth);
        int lineNumber = cursor.blockNumber() + m_baseLineNumber;
        hand = hand && isExecutableLine(lineNumber);
#ifndef QT_NO_CURSOR
        if (hand != (m_extraArea->cursor().shape() == Qt::PointingHandCursor))
            m_extraArea->setCursor(hand ? Qt::PointingHandCursor : Qt::ArrowCursor);
#endif
    }

    if (e->type() == QEvent::MouseButtonPress) {
        if (e->button() == Qt::LeftButton) {
            int lineNumber = cursor.blockNumber() + m_baseLineNumber;
            bool executable = isExecutableLine(lineNumber);
            if ((e->pos().x() <= markWidth) && executable)
                m_extraAreaToggleBlockNumber = cursor.blockNumber();
            else
                m_extraAreaToggleBlockNumber = -1;
        }
    } else if (e->type() == QEvent::MouseButtonRelease) {
        if (e->button() == Qt::LeftButton) {
            if ((m_extraAreaToggleBlockNumber != -1) && (e->pos().x() <= markWidth)) {
                int lineNumber = m_extraAreaToggleBlockNumber + m_baseLineNumber;
                bool on = !m_breakpoints.contains(lineNumber);
                emit breakpointToggleRequest(lineNumber, on);
            }
        } else if (e->button() == Qt::RightButton) {
            int lineNumber = cursor.blockNumber() + m_baseLineNumber;
            if (!isExecutableLine(lineNumber))
                return;
            bool has = m_breakpoints.contains(lineNumber);
            QMenu *popup = new QMenu();
            QAction *toggleAct = new QAction(tr("Toggle Breakpoint"), popup);
            popup->addAction(toggleAct);
            QAction *disableAct = new QAction(tr("Disable Breakpoint"), popup);
            QAction *enableAct = new QAction(tr("Enable Breakpoint"), popup);
            QWidget *conditionWidget = new QWidget();
            {
                QHBoxLayout *hbox = new QHBoxLayout(conditionWidget);
                hbox->addWidget(new QLabel(tr("Breakpoint Condition:")));
                hbox->addWidget(new QLineEdit());
            }
//            QWidgetAction *conditionAct = new QWidgetAction(popup);
//            conditionAct->setDefaultWidget(conditionWidget);
            if (has) {
                popup->addSeparator();
                popup->addAction(m_breakpoints[lineNumber].enabled ? disableAct : enableAct);
//                popup->addAction(conditionAct);
            }
            QAction *ret = popup->exec(e->globalPos());
            if (ret) {
                if (ret == toggleAct) {
                    emit breakpointToggleRequest(lineNumber, !has);
                } else if (ret == disableAct) {
                    emit breakpointEnableRequest(lineNumber, false);
                } else if (ret == enableAct) {
                    emit breakpointEnableRequest(lineNumber, true);
                }// else if (ret == conditionAct) {
                //}
            }
            popup->deleteLater();
        }
    }
}