ApiCallDelegate::ApiCallDelegate(QWidget *parent)
: QStyledItemDelegate(parent),
- m_stateEmblem(":/resources/dialog-information.png")
+ m_stateEmblem(":/resources/dialog-information.png"),
+ m_editEmblem(":/resources/document-edit.png")
{
}
QStyle *style = QApplication::style();
style->drawControl(QStyle::CE_ItemViewItem, &option, painter, 0);
if (!event->state().isEmpty()) {
- QPixmap px = m_stateEmblem.pixmap(option.rect.height(), option.rect.height());
+ QPixmap px = m_stateEmblem.pixmap(option.rect.height(),
+ option.rect.height());
painter->drawPixmap(option.rect.topLeft(), px);
offset = QPoint(option.rect.height() + 5, 0);
}
+ if (event->type() == ApiTraceEvent::Call) {
+ ApiTraceCall *call = static_cast<ApiTraceCall*>(event);
+ if (call->edited()) {
+ QPixmap px = m_editEmblem.pixmap(option.rect.height(),
+ option.rect.height());
+ painter->drawPixmap(option.rect.topLeft() + offset, px);
+ offset += QPoint(option.rect.height() + 5, 0);
+ }
+ }
+
painter->drawStaticText(option.rect.topLeft() + offset, text);
} else {
QStyledItemDelegate::paint(painter, option, index);
private:
QIcon m_stateEmblem;
+ QIcon m_editEmblem;
};
#endif
this, SIGNAL(finishedLoadingTrace()));
m_saver = new SaverThread(this);
+ connect(m_saver, SIGNAL(traceSaved()),
+ this, SLOT(slotSaved()));
+ connect(m_saver, SIGNAL(traceSaved()),
+ this, SIGNAL(saved()));
}
ApiTrace::~ApiTrace()
if (!m_editedCalls.contains(call)) {
//lets generate a temp filename
QString tempPath = QDir::tempPath();
- //lets make sure it exists
m_tempFileName = QString::fromLatin1("%1/%2.edited")
.arg(tempPath)
.arg(m_fileName);
- m_needsSaving = true;
}
-
m_editedCalls.insert(call);
+ m_needsSaving = true;
emit changed(call);
}
{
QFileInfo fi(m_tempFileName);
QDir dir;
+ emit startedSaving();
dir.mkpath(fi.absolutePath());
+ m_saver->saveFile(m_tempFileName, m_calls);
+}
+
+void ApiTrace::slotSaved()
+{
m_needsSaving = false;
+}
- m_saver->saveFile(m_tempFileName, m_calls);
+bool ApiTrace::isSaving() const
+{
+ return m_saver->isRunning();
}
#include "apitrace.moc"
bool edited() const;
bool needsSaving() const;
+ bool isSaving() const;
+
public slots:
void setFileName(const QString &name);
void setFrameMarker(FrameMarker marker);
void invalidated();
void framesInvalidated();
void changed(ApiTraceCall *call);
- void traceSaved();
+ void startedSaving();
+ void saved();
void framesAdded(int oldCount, int numAdded);
void callsAdded(int oldCount, int numAdded);
private slots:
void addFrames(const QList<ApiTraceFrame*> &frames);
+ void slotSaved();
private:
void detectFrames();
private:
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(m_argValues[i]);
+ QString argText = apiVariantToString(argValues[i]);
//if arguments are really long (e.g. shader text), cut them
// and elide it
if (!m_staticText)
m_staticText = new QStaticText(richText);
+ else
+ m_staticText->setText(richText);
QTextOption opt;
opt.setWrapMode(QTextOption::NoWrap);
m_staticText->setTextOption(opt);
.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(m_argValues[i]) +
+ apiVariantToString(argValues[i]) +
QLatin1Literal("</span>");
if (i < m_argNames.count() - 1)
m_richText += QLatin1String(", ");
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(m_argValues[i]);
- if (m_argValues[i].type() == QVariant::ByteArray) {
+ apiVariantToString(argValues[i]);
+ if (argValues[i].type() == QVariant::ByteArray) {
m_hasBinaryData = true;
m_binaryDataIndex = i;
}
ApiTrace *trace = 0;
if (m_parentFrame)
trace = m_parentFrame->parentTrace();
+
m_editedValues = lst;
+ //lets regenerate data
+ m_richText = QString();
+ m_filterText = QString();
+ delete m_staticText;
+ m_staticText = 0;
if (trace) {
if (!lst.isEmpty()) {
void ApiTraceModel::callChanged(ApiTraceCall *call)
{
- qDebug()<<"Call changed = "<<call->edited();
ApiTrace *trace = call->parentFrame()->parentTrace();
+
+ Q_ASSERT(trace);
+ trace->save();
+
+#if 0
+ qDebug()<<"Call changed = "<<call->edited();
qDebug()<<"\ttrace edited = "<<trace->edited();
qDebug()<<"\ttrace file = "<<trace->fileName();
qDebug()<<"\ttrace needs saving = "<<trace->needsSaving();
- trace->save();
+#endif
+
+ ApiTraceFrame *frame = call->parentFrame();
+ int row = frame->calls.indexOf(call);
+ QModelIndex index = createIndex(row, 0, call);
+ emit dataChanged(index, index);
}
#include "apitracemodel.moc"
QVariant argValue = originalValues[i];
QVariant editorValue = valueForName(argName, argValue, &valChanged);
newValues.append(editorValue);
+#if 0
qDebug()<<"Arg = "<<argName;
qDebug()<<"\toriginal = "<<argValue;
qDebug()<<"\teditor = "<<editorValue;
qDebug()<<"\tchanged = "<<valChanged;
+#endif
if (valChanged)
changed = true;
}
void MainWindow::replayStart()
{
+ if (m_trace->isSaving()) {
+ QMessageBox::warning(
+ this,
+ tr("Trace Saving"),
+ tr("QApiTrace is currently saving the edited trace file. "
+ "Please wait until it finishes and try again."));
+ return;
+ }
QDialog dlg;
Ui_RetracerDialog dlgUi;
dlgUi.setupUi(&dlg);
tr("To inspect the state select an event in the event list."));
return;
}
+ if (m_trace->isSaving()) {
+ QMessageBox::warning(
+ this,
+ tr("Trace Saving"),
+ tr("QApiTrace is currently saving the edited trace file. "
+ "Please wait until it finishes and try again."));
+ return;
+ }
m_stateEvent = m_selectedEvent;
replayTrace(true);
}
this, SLOT(startedLoadingTrace()));
connect(m_trace, SIGNAL(finishedLoadingTrace()),
this, SLOT(finishedLoadingTrace()));
+ connect(m_trace, SIGNAL(startedSaving()),
+ this, SLOT(slotStartedSaving()));
+ connect(m_trace, SIGNAL(saved()),
+ this, SLOT(slotSaved()));
connect(m_retracer, SIGNAL(finished(const QString&)),
this, SLOT(replayFinished(const QString&)));
}
}
+void MainWindow::slotStartedSaving()
+{
+ m_progressBar->setValue(0);
+ statusBar()->showMessage(
+ tr("Saving to %1").arg(m_trace->fileName()));
+}
+
+void MainWindow::slotSaved()
+{
+ statusBar()->showMessage(
+ tr("Saved to %1").arg(m_trace->fileName()), 2000);
+ m_progressBar->hide();
+}
+
#include "mainwindow.moc"
void fillState(bool nonDefaults);
void customContextMenuRequested(QPoint pos);
void editCall();
+ void slotStartedSaving();
+ void slotSaved();
private:
void initObjects();
<file>resources/application-exit.png</file>
<file>resources/dialog-close.png</file>
<file>resources/dialog-information.png</file>
+ <file>resources/document-edit.png</file>
<file>resources/document-new.png</file>
<file>resources/document-open.png</file>
<file>resources/edit-undo.png</file>
}
Trace::Close();
- emit traceSaved(m_fileName);
+ emit traceSaved();
}
#include "saverthread.moc"
const QList<ApiTraceCall*> &calls);
signals:
- void traceSaved(const QString &fileName);
+ void traceSaved();
protected:
virtual void run();