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) <b>%2</b>")
+ .arg(call->index())
+ .arg(call->name());
+ else
+ return QString::fromLatin1("%1) <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) Frame ")
+ .arg(frame->number);
+ int binaryDataSize = frame->binaryDataSize() / 1024;
+ if (!frame->hasState())
+ return QObject::tr(
+ "<b>%1 </b>(binary data size = %2kB)")
+ .arg(text)
+ .arg(binaryDataSize);
+ else
+ return QObject::tr(
+ "<b>%1 (binary data size = %2kB)</b>"
+ "<br/>%3")
+ .arg(text)
+ .arg(binaryDataSize)
+ .arg(stateText);
+ }
+ }
case ApiTraceModel::EventRole:
return QVariant::fromValue(itm);
}
QModelIndex ApiTraceModel::index(int row, int column,
const QModelIndex &parent) const
{
- if (parent.isValid() && parent.column() != 0)
+ if ((parent.isValid() && parent.column() != 0) || column != 0)
return QModelIndex();
ApiTraceEvent *event = item(parent);
return QModelIndex();
}
ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
- ApiTraceCall *call = frame->calls.value(row);
+ ApiTraceCall *call = frame->call(row);
if (call)
return createIndex(row, column, call);
else
ApiTraceEvent *event = item(parent);
if (event && event->type() == ApiTraceEvent::Frame) {
ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
- return !frame->calls.isEmpty();
+ return !frame->isEmpty();
} else
return false;
} else {
ApiTraceEvent *event = item(index);
if (event && event->type() == ApiTraceEvent::Call) {
ApiTraceCall *call = static_cast<ApiTraceCall*>(event);
- Q_ASSERT(call->parentFrame);
- return createIndex(call->parentFrame->number,
- 0, call->parentFrame);
+ Q_ASSERT(call->parentFrame());
+ return createIndex(call->parentFrame()->number,
+ 0, call->parentFrame());
}
return QModelIndex();
}
ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
if (frame)
- return frame->calls.count();
+ return frame->numChildren();
return 0;
}
if (m_trace)
disconnect(m_trace);
m_trace = trace;
+ connect(m_trace, SIGNAL(invalidated()),
+ this, SLOT(invalidateFrames()));
connect(m_trace, SIGNAL(framesInvalidated()),
this, SLOT(invalidateFrames()));
- connect(m_trace, SIGNAL(framesAdded(int, int)),
- this, SLOT(appendFrames(int, int)));
+ connect(m_trace, SIGNAL(beginAddingFrames(int, int)),
+ this, SLOT(beginAddingFrames(int, int)));
+ connect(m_trace, SIGNAL(endAddingFrames()),
+ this, SLOT(endAddingFrames()));
+ connect(m_trace, SIGNAL(changed(ApiTraceCall*)),
+ this, SLOT(callChanged(ApiTraceCall*)));
}
const ApiTrace * ApiTraceModel::apiTrace() const
endResetModel();
}
-void ApiTraceModel::appendFrames(int oldCount, int numAdded)
+void ApiTraceModel::beginAddingFrames(int oldCount, int numAdded)
{
beginInsertRows(QModelIndex(), oldCount,
oldCount + numAdded - 1);
- endInsertRows();
}
ApiTraceEvent * ApiTraceModel::item(const QModelIndex &index) const
if (event->type() == ApiTraceEvent::Call) {
ApiTraceCall *call = static_cast<ApiTraceCall*>(event);
- ApiTraceFrame *frame = call->parentFrame;
- int row = frame->calls.indexOf(call);
+ ApiTraceFrame *frame = call->parentFrame();
+ int row = frame->callIndex(call);
QModelIndex index = createIndex(row, 0, call);
emit dataChanged(index, index);
} else if (event->type() == ApiTraceEvent::Frame) {
}
}
+QModelIndex ApiTraceModel::callIndex(int callNum) const
+{
+ ApiTraceCall *call = m_trace->callWithIndex(callNum);
+ return indexForCall(call);
+}
+
+QModelIndex ApiTraceModel::indexForCall(ApiTraceCall *call) const
+{
+ if (!call) {
+ return QModelIndex();
+ }
+
+ ApiTraceFrame *frame = call->parentFrame();
+ Q_ASSERT(frame);
+
+ int row = frame->callIndex(call);
+ if (row < 0) {
+ qDebug() << "Couldn't find call num "<<call->index()<<" inside parent!";
+ return QModelIndex();
+ }
+ return createIndex(row, 0, call);
+}
+
+void ApiTraceModel::callChanged(ApiTraceCall *call)
+{
+ ApiTrace *trace = call->parentFrame()->parentTrace();
+
+#if 0
+ qDebug()<<"Call changed = "<<call->edited();
+ qDebug()<<"\ttrace edited = "<<trace->edited();
+ qDebug()<<"\ttrace file = "<<trace->fileName();
+ qDebug()<<"\ttrace needs saving = "<<trace->needsSaving();
+#endif
+
+ Q_ASSERT(trace);
+ if (trace->needsSaving())
+ trace->save();
+
+ ApiTraceFrame *frame = call->parentFrame();
+ int row = frame->callIndex(call);
+ QModelIndex index = createIndex(row, 0, call);
+ emit dataChanged(index, index);
+}
+
+void ApiTraceModel::endAddingFrames()
+{
+ endInsertRows();
+}
+
#include "apitracemodel.moc"