コード例 #1
0
void QScriptDebuggerCodeWidget::setCurrentScript(qint64 scriptId)
{
    Q_D(QScriptDebuggerCodeWidget);
    if (scriptId == -1) {
        // ### show "native script"
        return;
    }
    QScriptDebuggerCodeViewInterface *view = d->viewHash.value(scriptId);
    if (!view) {
        Q_ASSERT(d->scriptsModel != 0);
        QScriptScriptData data = d->scriptsModel->scriptData(scriptId);
        if (!data.isValid())
            return;
        view = new QScriptDebuggerCodeView(); // ### use factory, so user can provide his own view
        view->setBaseLineNumber(data.baseLineNumber());
        view->setText(data.contents());
        view->setExecutableLineNumbers(d->scriptsModel->executableLineNumbers(scriptId));

        QObject::connect(view, SIGNAL(breakpointToggleRequest(int,bool)),
                         this, SLOT(_q_onBreakpointToggleRequest(int,bool)));

        QObject::connect(view, SIGNAL(breakpointEnableRequest(int,bool)),
                         this, SLOT(_q_onBreakpointEnableRequest(int,bool)));

        QObject::connect(view, SIGNAL(toolTipRequest(const QPoint &,int,const QStringList &)),
                         this, SLOT(_q_onToolTipRequest(const QPoint &,int,const QStringList &)));

        d->viewStack->addWidget(view);
        d->viewHash.insert(scriptId, view);
    }
コード例 #2
0
static QScriptValue scriptDataToScriptValue(QScriptEngine *eng, const QScriptScriptData &in)
{
    QScriptValue out = eng->newObject();
    out.setProperty(QString::fromLatin1("contents"), QScriptValue(eng, in.contents()));
    out.setProperty(QString::fromLatin1("fileName"), QScriptValue(eng, in.fileName()));
    out.setProperty(QString::fromLatin1("baseLineNumber"), QScriptValue(eng, in.baseLineNumber()));
    return out;
}