当前位置: 首页>>代码示例>>C++>>正文


C++ ApiTraceEvent类代码示例

本文整理汇总了C++中ApiTraceEvent的典型用法代码示例。如果您正苦于以下问题:C++ ApiTraceEvent类的具体用法?C++ ApiTraceEvent怎么用?C++ ApiTraceEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ApiTraceEvent类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QModelIndex

QModelIndex ApiTraceModel::index(int row, int column,
                                 const QModelIndex &parent) const
{
    if ((parent.isValid() && parent.column() != 0) || column != 0)
        return QModelIndex();

    //qDebug()<<"At row = "<<row<<", column = "<<column<<", parent "<<parent;
    ApiTraceEvent *parentEvent = item(parent);
    if (parentEvent) {
        ApiTraceEvent *event = parentEvent->eventAtRow(row);
        if (event) {
            Q_ASSERT(event->type() == ApiTraceEvent::Call);
            return createIndex(row, column, event);
        } else {
            return QModelIndex();
        }
    } else {
        ApiTraceFrame *frame = m_trace->frameAt(row);
        if (frame)
            return createIndex(row, column, frame);
        else
            return QModelIndex();
    }
    return QModelIndex();
}
开发者ID:Acidburn0zzz,项目名称:apitrace,代码行数:25,代码来源:apitracemodel.cpp

示例2: QModelIndex

QModelIndex ApiTraceModel::index(int row, int column,
                                 const QModelIndex &parent) const
{
    if (parent.isValid() && parent.column() != 0)
        return QModelIndex();

    ApiTraceEvent *event = item(parent);
    if (event) {
        if (event->type() != ApiTraceEvent::Frame) {
            qDebug()<<"got a valid parent but it's not a frame "<<event->type();
            return QModelIndex();
        }
        ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
        ApiTraceCall *call = frame->calls.value(row);
        if (call)
            return createIndex(row, column, call);
        else
            return QModelIndex();
    } else {
        ApiTraceFrame *frame = m_trace->frameAt(row);
        if (frame)
            return createIndex(row, column, frame);
        else
            return QModelIndex();
    }
    return QModelIndex();
}
开发者ID:bgirard,项目名称:apitrace,代码行数:27,代码来源:apitracemodel.cpp

示例3: tr

void MainWindow::callItemSelected(const QModelIndex &index)
{
    ApiTraceEvent *event =
        index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();

    if (event && event->type() == ApiTraceEvent::Call) {
        ApiTraceCall *call = static_cast<ApiTraceCall*>(event);
        m_ui.detailsDock->setWindowTitle(
            tr("Details View. Frame %1, Call %2")
            .arg(call->parentFrame() ? call->parentFrame()->number : 0)
            .arg(call->index()));
        m_ui.detailsWebView->setHtml(call->toHtml());
        m_ui.detailsDock->show();
        m_ui.callView->scrollTo(index);
        if (call->hasBinaryData()) {
            QByteArray data =
                call->arguments()[call->binaryDataIndex()].toByteArray();
            m_vdataInterpreter->setData(data);

            QVector<QVariant> args = call->arguments();
            for (int i = 0; i < call->argNames().count(); ++i) {
                QString name = call->argNames()[i];
                if (name == QLatin1String("stride")) {
                    int stride = args[i].toInt();
                    m_ui.vertexStrideSB->setValue(stride);
                } else if (name == QLatin1String("size")) {
                    int components = args[i].toInt();
                    m_ui.vertexComponentsSB->setValue(components);
                } else if (name == QLatin1String("type")) {
                    QString val = args[i].toString();
                    int textIndex = m_ui.vertexTypeCB->findText(val);
                    if (textIndex >= 0) {
                        m_ui.vertexTypeCB->setCurrentIndex(textIndex);
                    }
                }
            }
        }
        m_ui.backtraceBrowser->setText(call->backtrace());
        m_ui.backtraceDock->setVisible(!call->backtrace().isNull());
        m_ui.vertexDataDock->setVisible(call->hasBinaryData());
        m_selectedEvent = call;
    } else {
        if (event && event->type() == ApiTraceEvent::Frame) {
            m_selectedEvent = static_cast<ApiTraceFrame*>(event);
        } else {
            m_selectedEvent = 0;
        }
        m_ui.detailsDock->hide();
        m_ui.backtraceDock->hide();
        m_ui.vertexDataDock->hide();
    }
    if (m_selectedEvent && m_selectedEvent->hasState()) {
        fillStateForFrame();
    } else {
        m_ui.stateDock->hide();
    }
}
开发者ID:Acidburn0zzz,项目名称:apitrace,代码行数:57,代码来源:mainwindow.cpp

示例4: QVariant

QVariant ApiTraceModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid())
        return QVariant();

    if (index.column() != 0)
        return QVariant();

    ApiTraceEvent *itm = item(index);
    if (!itm) {
        return QVariant();
    }

    switch (role) {
    case Qt::DisplayRole:
        return itm->staticText().text();
    case Qt::DecorationRole:
        return QImage();
    case Qt::ToolTipRole: {
        const QString stateText = tr("State info available.");
        if (itm->type() == ApiTraceEvent::Call) {
            ApiTraceCall *call = static_cast<ApiTraceCall*>(itm);
            if (call->state().isEmpty())
                return QString::fromLatin1("%1)&nbsp;<b>%2</b>")
                    .arg(call->index())
                    .arg(call->name());
            else
                return QString::fromLatin1("%1)&nbsp;<b>%2</b><br/>%3")
                    .arg(call->index())
                    .arg(call->name())
                    .arg(stateText);
        } else {
            ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(itm);
            QString text = QObject::tr("%1)&nbsp;Frame&nbsp;")
                           .arg(frame->number);
            int binaryDataSize = frame->binaryDataSize() / 1024;
            if (frame->state().isEmpty())
                return QObject::tr(
                    "<b>%1&nbsp;</b>(binary&nbsp;data&nbsp;size&nbsp;=&nbsp;%2kB)")
                    .arg(text)
                    .arg(binaryDataSize);
            else
                return QObject::tr(
                    "<b>%1&nbsp;(binary&nbsp;data&nbsp;size&nbsp;=&nbsp;%2kB)</b>"
                    "<br/>%3")
                    .arg(text)
                    .arg(binaryDataSize)
                    .arg(stateText);
        }
    }
    case ApiTraceModel::EventRole:
        return QVariant::fromValue(itm);
    }

    return QVariant();
}
开发者ID:mariuz,项目名称:apitrace,代码行数:56,代码来源:apitracemodel.cpp

示例5: item

int ApiTraceModel::rowCount(const QModelIndex &parent) const
{
    if (!parent.isValid())
        return m_trace->numFrames();

    ApiTraceEvent *event = item(parent);
    if (!event)
        return 0;

    return event->numChildren();
}
开发者ID:Acidburn0zzz,项目名称:apitrace,代码行数:11,代码来源:apitracemodel.cpp

示例6: item

bool ApiTraceModel::hasChildren(const QModelIndex &parent) const
{
    if (parent.isValid()) {
        ApiTraceEvent *event = item(parent);
        if (event && event->type() == ApiTraceEvent::Frame) {
            ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
            return !frame->calls.isEmpty();
        } else
            return false;
    } else {
        return (rowCount() > 0);
    }
}
开发者ID:bgirard,项目名称:apitrace,代码行数:13,代码来源:apitracemodel.cpp

示例7: item

void ApiTraceModel::fetchMore(const QModelIndex &parent)
{
    if (parent.isValid()) {
        ApiTraceEvent *event = item(parent);
        if (event && event->type() == ApiTraceEvent::Frame) {
            ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);

            Q_ASSERT(!frame->isLoaded());
            m_loadingFrames.insert(frame);

            m_trace->loadFrame(frame);
        }
    }
}
开发者ID:ShuangxueBai,项目名称:apitrace,代码行数:14,代码来源:apitracemodel.cpp

示例8: callItemSelected

void MainWindow::customContextMenuRequested(QPoint pos)
{
    QModelIndex index = m_ui.callView->indexAt(pos);

    callItemSelected(index);
    if (!index.isValid()) {
        return;
    }

    ApiTraceEvent *event =
        index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
    if (!event) {
        return;
    }

    QMenu menu;
    menu.addAction(QIcon(":/resources/media-record.png"),
                   tr("Lookup state"), this, SLOT(lookupState()));
    if (event->type() == ApiTraceEvent::Call) {
        menu.addAction(tr("Edit"), this, SLOT(editCall()));
    }

    menu.exec(QCursor::pos());
}
开发者ID:Acidburn0zzz,项目名称:apitrace,代码行数:24,代码来源:mainwindow.cpp

示例9: QVariant

QVariant ApiTraceModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid())
        return QVariant();

    if (index.column() != 0)
        return QVariant();

    ApiTraceEvent *itm = item(index);
    if (!itm) {
        return QVariant();
    }

    switch (role) {
    case Qt::DisplayRole:
        return itm->staticText().text();
    case Qt::DecorationRole:
        return QImage();
    case Qt::ToolTipRole: {
        const QString stateText = tr("State info available.");
        if (itm->type() == ApiTraceEvent::Call) {
            ApiTraceCall *call = static_cast<ApiTraceCall*>(itm);
            if (!call->hasState())
                return QString::fromLatin1("%1)&nbsp;<b>%2</b>")
                    .arg(call->index())
                    .arg(call->name());
            else
                return QString::fromLatin1("%1)&nbsp;<b>%2</b><br/>%3")
                    .arg(call->index())
                    .arg(call->name())
                    .arg(stateText);
        } else {
            const char *htmlTempl =
                    "<div>\n"
                    "<div>\n"
                    "%1"
                    "<span style=\"font-weight:bold; font-size:large; vertical-align:center; padding-bottom: 30px \">\n"
                    "Frame %2</span>\n"
                    "</div>\n"
                    "<div >%3 calls%4</div>\n"
                    "</div>\n";


            ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(itm);
            QString thumbStr, sizeStr;

            if (frame->hasState()) {
                static const char *imgTempl =
                        "<img style=\"float:left;\" "
                        "src=\"data:image/png;base64,%1\"/>\n";
                static const char *sizeTempl =
                        ", %1kb";

                ApiFramebuffer fbo = frame->state()->colorBuffer();
                QImage thumb = fbo.thumb();
                if (!thumb.isNull()) {
                    QByteArray ba;
                    QBuffer buffer(&ba);
                    buffer.open(QIODevice::WriteOnly);
                    thumb.save(&buffer, "PNG");
                    thumbStr = tr(imgTempl).arg(
                                QString(buffer.data().toBase64()));
                }

                int binaryDataSize = frame->binaryDataSize() / 1024;
                if (binaryDataSize > 0) {
                    sizeStr = tr(sizeTempl).arg(binaryDataSize);
                }
            }

            int numCalls = frame->isLoaded()
                    ? frame->numTotalCalls()
                    : frame->numChildrenToLoad();

            return tr(htmlTempl)
                    .arg(thumbStr)
                    .arg(frame->number)
                    .arg(numCalls)
                    .arg(sizeStr);
        }
    }
    case ApiTraceModel::EventRole:
        return QVariant::fromValue(itm);
    }

    return QVariant();
}
开发者ID:Acidburn0zzz,项目名称:apitrace,代码行数:87,代码来源:apitracemodel.cpp


注:本文中的ApiTraceEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。