Ejemplo n.º 1
0
QString ApiTraceCall::filterText() const
{
    if (!m_filterText.isEmpty())
        return m_filterText;

    m_filterText = name;
    m_filterText += QLatin1String("(");
    for (int i = 0; i < argNames.count(); ++i) {
        m_filterText += argNames[i];
        m_filterText += QString::fromLatin1(" = ");

        if (argValues[i].type() == QVariant::ByteArray) {
            m_hasBinaryData = true;
            m_binaryDataIndex = i;
        }
        m_filterText += apiVariantToString(argValues[i]);
        if (i < argNames.count() - 1)
            m_filterText += QString::fromLatin1(", ");
    }
    m_filterText += QLatin1String(")");

    if (returnValue.isValid()) {
        m_filterText += QLatin1String(" = ");
        m_filterText += apiVariantToString(returnValue);
    }
    return m_filterText;
}
Ejemplo n.º 2
0
QStaticText ApiTraceCall::staticText() const
{
    if (m_staticText && !m_staticText->text().isEmpty())
        return *m_staticText;

    QVariantList argValues = arguments();

    QString richText = QString::fromLatin1(
        "<span style=\"font-weight:bold\">%1</span>(").arg(m_name);
    for (int i = 0; i < m_argNames.count(); ++i) {
        richText += QLatin1String("<span style=\"color:#0000ff\">");
        QString argText = apiVariantToString(argValues[i]);

        //if arguments are really long (e.g. shader text), cut them
        // and elide it
        if (argText.length() > 40) {
            QString shortened = argText.mid(0, 40);
            shortened[argText.length() - 5] = '.';
            shortened[argText.length() - 4] = '.';
            shortened[argText.length() - 3] = '.';
            shortened[argText.length() - 2] = argText[argText.length() - 2];
            shortened[argText.length() - 1] = argText[argText.length() - 1];
            richText += shortened;
        } else {
            richText += argText;
        }
        richText += QLatin1String("</span>");
        if (i < m_argNames.count() - 1)
            richText += QLatin1String(", ");
    }
    richText += QLatin1String(")");
    if (m_returnValue.isValid()) {
        richText +=
            QLatin1Literal(" = ") %
            QLatin1Literal("<span style=\"color:#0000ff\">") %
            apiVariantToString(m_returnValue) %
            QLatin1Literal("</span>");
    }

    if (!m_staticText)
        m_staticText = new QStaticText(richText);
    else
        m_staticText->setText(richText);
    QTextOption opt;
    opt.setWrapMode(QTextOption::NoWrap);
    m_staticText->setTextOption(opt);
    m_staticText->prepare();

    return *m_staticText;
}
Ejemplo n.º 3
0
QString ApiArray::toString(bool multiLine) const
{
    QString str;
    str += QLatin1String("[");
    for(int i = 0; i < m_array.count(); ++i) {
        const QVariant &var = m_array[i];
        str += apiVariantToString(var, multiLine);
        if (i < m_array.count() - 1)
            str += QLatin1String(", ");
    }
    str += QLatin1String("]");

    return str;
}
Ejemplo n.º 4
0
QString ApiTraceCall::filterText() const
{
    if (!m_filterText.isEmpty())
        return m_filterText;

    QVariantList argValues = arguments();
    m_filterText = m_name + QLatin1Literal("(");
    for (int i = 0; i < m_argNames.count(); ++i) {
        m_filterText += m_argNames[i] +
                        QLatin1Literal(" = ") +
                        apiVariantToString(argValues[i]);
        if (i < m_argNames.count() - 1)
            m_filterText += QLatin1String(", ");
    }
    m_filterText += QLatin1String(")");

    if (m_returnValue.isValid()) {
        m_filterText += QLatin1Literal(" = ") +
                        apiVariantToString(m_returnValue);
    }
    m_filterText.squeeze();
    return m_filterText;
}
Ejemplo n.º 5
0
QString ApiTraceCall::toHtml() const
{
    if (!m_richText.isEmpty())
        return m_richText;

    if (helpUrl.isEmpty()) {
        m_richText = QString::fromLatin1(
            "%1) <span style=\"font-weight:bold\">%2</span>(")
                     .arg(index)
                     .arg(name);
    } else {
        m_richText = QString::fromLatin1(
            "%1) <span style=\"font-weight:bold\"><a href=\"%2\">%3</a></span>(")
                      .arg(index)
                      .arg(helpUrl.toString())
                      .arg(name);
    }

    for (int i = 0; i < argNames.count(); ++i) {
        m_richText += argNames[i];
        m_richText += QString::fromLatin1(" = ");
        m_richText += QLatin1String("<span style=\"color:#0000ff\">");
        m_richText += apiVariantToString(argValues[i]);
        m_richText += QLatin1String("</span>");
        if (i < argNames.count() - 1)
            m_richText += QString::fromLatin1(", ");
    }
    m_richText += QLatin1String(")");

    if (returnValue.isValid()) {
        m_richText += QLatin1String(" = ");
        m_richText += QLatin1String("<span style=\"color:#0000ff\">");
        m_richText += apiVariantToString(returnValue);
        m_richText += QLatin1String("</span>");
    }
    return m_richText;
}
Ejemplo n.º 6
0
QString ApiStruct::toString(bool multiLine) const
{
    QString str;

    str += QLatin1String("{");
    for (unsigned i = 0; i < m_members.count(); ++i) {
        str += m_sig.memberNames[i] %
               QLatin1Literal(" = ") %
               apiVariantToString(m_members[i], multiLine);
        if (i < m_members.count() - 1)
            str += QLatin1String(", ");
    }
    str += QLatin1String("}");

    return str;
}
Ejemplo n.º 7
0
QString ApiStruct::toString() const
{
    QString str;

    str += QLatin1String("{");
    for (unsigned i = 0; i < m_members.count(); ++i) {
        str += m_sig.memberNames[i];
        str += QLatin1String(" = ");
        str += apiVariantToString(m_members[i]);
        if (i < m_members.count() - 1)
            str += QLatin1String(", ");
    }
    str += QLatin1String("}");

    return str;
}
Ejemplo n.º 8
0
QString ApiTraceCall::toHtml() const
{
    if (!m_richText.isEmpty())
        return m_richText;

    m_richText = QLatin1String("<div class=\"call\">");

    if (m_helpUrl.isEmpty()) {
        m_richText += QString::fromLatin1(
            "%1) <span class=\"callName\">%2</span>(")
                      .arg(m_index)
                      .arg(m_name);
    } else {
        m_richText += QString::fromLatin1(
            "%1) <span class=\"callName\"><a href=\"%2\">%3</a></span>(")
                      .arg(m_index)
                      .arg(m_helpUrl.toString())
                      .arg(m_name);
    }

    QVariantList argValues = arguments();
    for (int i = 0; i < m_argNames.count(); ++i) {
        m_richText +=
            QLatin1String("<span class=\"arg-name\">") +
            m_argNames[i] +
            QLatin1String("</span>") +
            QLatin1Literal(" = ") +
            QLatin1Literal("<span class=\"arg-value\">") +
            apiVariantToString(argValues[i], true) +
            QLatin1Literal("</span>");
        if (i < m_argNames.count() - 1)
            m_richText += QLatin1String(", ");
    }
    m_richText += QLatin1String(")");

    if (m_returnValue.isValid()) {
        m_richText +=
            QLatin1String(" = ") +
            QLatin1String("<span style=\"color:#0000ff\">") +
            apiVariantToString(m_returnValue, true) +
            QLatin1String("</span>");
    }
    m_richText += QLatin1String("</div>");

    if (hasError()) {
        QString errorStr =
            QString::fromLatin1(
                "<div class=\"error\">%1</div>")
            .arg(m_error);
        m_richText += errorStr;
    }

    m_richText =
        QString::fromLatin1(
            "<html><head><style type=\"text/css\" media=\"all\">"
            "%1</style></head><body>%2</body></html>")
        .arg(styleSheet)
        .arg(m_richText);
    m_richText.squeeze();

    //qDebug()<<m_richText;
    return m_richText;
}