ApiCallDelegate::ApiCallDelegate(QWidget *parent)
: QStyledItemDelegate(parent),
m_stateEmblem(":/resources/dialog-information.png"),
- m_editEmblem(":/resources/document-edit.png")
+ m_editEmblem(":/resources/document-edit.png"),
+ m_errorEmblem(":/resources/script-error.png")
{
}
}
if (event->type() == ApiTraceEvent::Call) {
ApiTraceCall *call = static_cast<ApiTraceCall*>(event);
+ if (call->hasError()) {
+ QPixmap px = m_errorEmblem.pixmap(option.rect.height(),
+ option.rect.height());
+ painter->drawPixmap(option.rect.topLeft() + offset, px);
+ offset += QPoint(option.rect.height() + 5, 0);
+ }
if (call->edited()) {
QPixmap px = m_editEmblem.pixmap(option.rect.height(),
option.rect.height());
private:
QIcon m_stateEmblem;
QIcon m_editEmblem;
+ QIcon m_errorEmblem;
};
#endif
return m_saver->isRunning();
}
+void ApiTrace::callError(ApiTraceCall *call)
+{
+ emit changed(call);
+}
+
#include "apitrace.moc"
void callEdited(ApiTraceCall *call);
void callReverted(ApiTraceCall *call);
+ void callError(ApiTraceCall *call);
bool edited() const;
bool needsSaving() const;
#define QT_USE_FAST_OPERATOR_PLUS
#include <QStringBuilder>
+const char * const styleSheet =
+ ".call {\n"
+ " font-weight:bold;\n"
+ // text shadow looks great but doesn't work well in qtwebkit 4.7
+ " /*text-shadow: 0px 2px 3px #555;*/\n"
+ " font-size: 1.2em;\n"
+ "}\n"
+ ".arg-name {\n"
+ " border: 1px solid rgb(238,206,0);\n"
+ " border-radius: 4px;\n"
+ " background: yellow;\n"
+ " padding: 2px;\n"
+ " box-shadow: 0px 1px 3px dimgrey;\n"
+ " -webkit-transition: background 1s linear;\n"
+ "}\n"
+ ".arg-name:hover {\n"
+ " background: white;\n"
+ "}\n"
+ ".arg-value {\n"
+ " color: #0000ff;\n"
+ "}\n"
+ ".error {\n"
+ " margin: 10px;\n"
+ " padding: 0;\n"
+ " color: red;\n"
+ " background: #6fb2e5;\n"
+ " box-shadow: 0 1px 5px #0061aa, inset 0 10px 20px #b6f9ff;\n"
+ " -o-box-shadow: 0 1px 5px #0061aa, inset 0 10px 20px #b6f9ff;\n"
+ " -webkit-box-shadow: 0 1px 5px #0061aa, inset 0 10px 20px #b6f9ff;\n"
+ " -moz-box-shadow: 0 1px 5px #0061aa, inset 0 10px 20px #b6f9ff;\n"
+ "}\n";
+
ApiPointer::ApiPointer(unsigned long long val)
: m_value(val)
{
if (!m_richText.isEmpty())
return m_richText;
+ m_richText = QLatin1String("<div class=\"call\">");
+
if (m_helpUrl.isEmpty()) {
- m_richText = QString::fromLatin1(
- "%1) <span style=\"font-weight:bold\">%2</span>(")
- .arg(m_index)
- .arg(m_name);
+ m_richText += QString::fromLatin1(
+ "%1) <span class=\"callName\">%2</span>(")
+ .arg(m_index)
+ .arg(m_name);
} else {
- m_richText = QString::fromLatin1(
- "%1) <span style=\"font-weight:bold\"><a href=\"%2\">%3</a></span>(")
+ 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 += m_argNames[i] +
- QLatin1Literal(" = ") +
- QLatin1Literal("<span style=\"color:#0000ff\">") +
- apiVariantToString(argValues[i]) +
- QLatin1Literal("</span>");
+ m_richText +=
+ QLatin1String("<span class=\"arg-name\">") +
+ m_argNames[i] +
+ QLatin1String("</span>") +
+ QLatin1Literal(" = ") +
+ QLatin1Literal("<span class=\"arg-value\">") +
+ apiVariantToString(argValues[i]) +
+ QLatin1Literal("</span>");
if (i < m_argNames.count() - 1)
m_richText += QLatin1String(", ");
}
apiVariantToString(m_returnValue) +
QLatin1String("</span>");
}
+ m_richText += QLatin1String("</div>");
+
+ 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;
}
void ApiTraceCall::setEditedValues(const QVariantList &lst)
{
- ApiTrace *trace = 0;
- if (m_parentFrame)
- trace = m_parentFrame->parentTrace();
+ ApiTrace *trace = parentTrace();
m_editedValues = lst;
//lets regenerate data
return m_value;
}
+bool ApiTraceCall::hasError() const
+{
+ return !m_error.isEmpty();
+}
+
+QString ApiTraceCall::error() const
+{
+ return m_error;
+}
+
+void ApiTraceCall::setError(const QString &msg)
+{
+ if (m_error != msg) {
+ ApiTrace *trace = parentTrace();
+ m_error = msg;
+ if (trace)
+ trace->callError(this);
+ }
+}
+
+ApiTrace * ApiTraceCall::parentTrace() const
+{
+ if (m_parentFrame)
+ return m_parentFrame->parentTrace();
+ return NULL;
+}
+
ApiTraceFrame *parentFrame()const;
void setParentFrame(ApiTraceFrame *frame);
+ bool hasError() const;
+ QString error() const;
+ void setError(const QString &msg);
+
QVariantList originalValues() const;
bool edited() const;
QVariantList editedValues() const;
void revert();
+ ApiTrace *parentTrace() const;
+
QString toHtml() const;
QString filterText() const;
QStaticText staticText() const;
QVariantList m_editedValues;
+ QString m_error;
+
mutable QString m_richText;
mutable QString m_filterText;
mutable bool m_hasBinaryData;
{
ApiTrace *trace = call->parentFrame()->parentTrace();
- Q_ASSERT(trace);
- trace->save();
-
-#if 0
+#if 1
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->calls.indexOf(call);
QModelIndex index = createIndex(row, 0, call);
m_argsEditor = new ArgumentsEditor(this);
m_ui.detailsDock->hide();
+ m_ui.errorsDock->hide();
m_ui.vertexDataDock->hide();
m_ui.stateDock->hide();
setDockOptions(dockOptions() | QMainWindow::ForceTabbedDocks);
tabifyDockWidget(m_ui.stateDock, m_ui.vertexDataDock);
+ tabifyDockWidget(m_ui.detailsDock, m_ui.errorsDock);
m_ui.surfacesTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
void MainWindow::replayStateFound(const ApiTraceState &state)
{
m_stateEvent->setState(state);
+ if (m_stateEvent->type() == ApiTraceEvent::Call) {
+ ApiTraceCall *call = static_cast<ApiTraceCall*>(m_stateEvent);
+ call->setError(tr("Some wonky error."));
+ }
m_model->stateSetOnEvent(m_stateEvent);
if (m_selectedEvent == m_stateEvent) {
fillStateForFrame();
<file>resources/media-playback-start.png</file>
<file>resources/media-playback-stop.png</file>
<file>resources/media-record.png</file>
+ <file>resources/script-error.png</file>
<file>resources/glreference.tsv</file>
</qresource>
</RCC>
{
qputenv("TRACE_PATH", m_fileName.toLocal8Bit());
unsigned id = 0;
-
+ qDebug()<<"saver thread!";
Trace::Open();
for (int i = 0; i < m_calls.count(); ++i) {
ApiTraceCall *call = m_calls[i];
</layout>
</widget>
</widget>
+ <widget class="QDockWidget" name="errorsDock">
+ <property name="features">
+ <set>QDockWidget::AllDockWidgetFeatures</set>
+ </property>
+ <property name="windowTitle">
+ <string>Errors</string>
+ </property>
+ <attribute name="dockWidgetArea">
+ <number>8</number>
+ </attribute>
+ <widget class="QWidget" name="dockWidgetContents_4">
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <item>
+ <widget class="QTreeWidget" name="errorsTreeWidget">
+ <column>
+ <property name="text">
+ <string>Index</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Error</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
<action name="actionExit">
<property name="text">
<string>Exit</string>
</action>
<zorder>stateDock</zorder>
<zorder>vertexDataDock</zorder>
+ <zorder>errorsDock</zorder>
</widget>
<customwidgets>
<customwidget>