From: Zack Rusin Date: Mon, 18 Apr 2011 05:05:50 +0000 (-0400) Subject: Lots of various cosmetic changes to the call editing. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=9af5bffdcf8a6294235a97e8b9714abbea74ea92;p=apitrace Lots of various cosmetic changes to the call editing. --- diff --git a/gui/apicalldelegate.cpp b/gui/apicalldelegate.cpp index 4eb542b..c2a1b23 100644 --- a/gui/apicalldelegate.cpp +++ b/gui/apicalldelegate.cpp @@ -11,7 +11,8 @@ ApiCallDelegate::ApiCallDelegate(QWidget *parent) : QStyledItemDelegate(parent), - m_stateEmblem(":/resources/dialog-information.png") + m_stateEmblem(":/resources/dialog-information.png"), + m_editEmblem(":/resources/document-edit.png") { } @@ -32,10 +33,21 @@ void ApiCallDelegate::paint(QPainter *painter, 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(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); diff --git a/gui/apicalldelegate.h b/gui/apicalldelegate.h index 525ab83..55cd13e 100644 --- a/gui/apicalldelegate.h +++ b/gui/apicalldelegate.h @@ -17,6 +17,7 @@ public: private: QIcon m_stateEmblem; + QIcon m_editEmblem; }; #endif diff --git a/gui/apitrace.cpp b/gui/apitrace.cpp index e98eeff..4ce4cd4 100644 --- a/gui/apitrace.cpp +++ b/gui/apitrace.cpp @@ -18,6 +18,10 @@ ApiTrace::ApiTrace() 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() @@ -207,14 +211,12 @@ void ApiTrace::callEdited(ApiTraceCall *call) 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); } @@ -243,10 +245,19 @@ void ApiTrace::save() { 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" diff --git a/gui/apitrace.h b/gui/apitrace.h index 54fc1f2..32e2408 100644 --- a/gui/apitrace.h +++ b/gui/apitrace.h @@ -49,6 +49,8 @@ public: bool edited() const; bool needsSaving() const; + bool isSaving() const; + public slots: void setFileName(const QString &name); void setFrameMarker(FrameMarker marker); @@ -60,13 +62,15 @@ signals: 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 &frames); + void slotSaved(); private: void detectFrames(); private: diff --git a/gui/apitracecall.cpp b/gui/apitracecall.cpp index c9e61e2..fa709c9 100644 --- a/gui/apitracecall.cpp +++ b/gui/apitracecall.cpp @@ -265,11 +265,13 @@ QStaticText ApiTraceCall::staticText() const if (m_staticText && !m_staticText->text().isEmpty()) return *m_staticText; + QVariantList argValues = arguments(); + QString richText = QString::fromLatin1( "%1(").arg(m_name); for (int i = 0; i < m_argNames.count(); ++i) { richText += QLatin1String(""); - 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 @@ -299,6 +301,8 @@ QStaticText ApiTraceCall::staticText() const if (!m_staticText) m_staticText = new QStaticText(richText); + else + m_staticText->setText(richText); QTextOption opt; opt.setWrapMode(QTextOption::NoWrap); m_staticText->setTextOption(opt); @@ -325,11 +329,12 @@ QString ApiTraceCall::toHtml() const .arg(m_name); } + QVariantList argValues = arguments(); for (int i = 0; i < m_argNames.count(); ++i) { m_richText += m_argNames[i] + QLatin1Literal(" = ") + QLatin1Literal("") + - apiVariantToString(m_argValues[i]) + + apiVariantToString(argValues[i]) + QLatin1Literal(""); if (i < m_argNames.count() - 1) m_richText += QLatin1String(", "); @@ -352,12 +357,13 @@ 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(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; } @@ -675,7 +681,13 @@ void ApiTraceCall::setEditedValues(const QVariantList &lst) 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()) { diff --git a/gui/apitracemodel.cpp b/gui/apitracemodel.cpp index 0e623c0..a39a929 100644 --- a/gui/apitracemodel.cpp +++ b/gui/apitracemodel.cpp @@ -280,12 +280,22 @@ QModelIndex ApiTraceModel::indexForCall(ApiTraceCall *call) const void ApiTraceModel::callChanged(ApiTraceCall *call) { - qDebug()<<"Call changed = "<edited(); ApiTrace *trace = call->parentFrame()->parentTrace(); + + Q_ASSERT(trace); + trace->save(); + +#if 0 + qDebug()<<"Call changed = "<edited(); qDebug()<<"\ttrace edited = "<edited(); qDebug()<<"\ttrace file = "<fileName(); qDebug()<<"\ttrace needs saving = "<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" diff --git a/gui/argumentseditor.cpp b/gui/argumentseditor.cpp index 125e12d..04a1952 100644 --- a/gui/argumentseditor.cpp +++ b/gui/argumentseditor.cpp @@ -339,10 +339,12 @@ void ArgumentsEditor::accept() QVariant argValue = originalValues[i]; QVariant editorValue = valueForName(argName, argValue, &valChanged); newValues.append(editorValue); +#if 0 qDebug()<<"Arg = "<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); } @@ -623,6 +639,10 @@ void MainWindow::initConnections() 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&))); @@ -900,4 +920,18 @@ void MainWindow::editCall() } } +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" diff --git a/gui/mainwindow.h b/gui/mainwindow.h index e723cdd..07a1e91 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -60,6 +60,8 @@ private slots: void fillState(bool nonDefaults); void customContextMenuRequested(QPoint pos); void editCall(); + void slotStartedSaving(); + void slotSaved(); private: void initObjects(); diff --git a/gui/qapitrace.qrc b/gui/qapitrace.qrc index 610eebe..6f6597f 100644 --- a/gui/qapitrace.qrc +++ b/gui/qapitrace.qrc @@ -3,6 +3,7 @@ resources/application-exit.png resources/dialog-close.png resources/dialog-information.png + resources/document-edit.png resources/document-new.png resources/document-open.png resources/edit-undo.png diff --git a/gui/resources/document-edit.png b/gui/resources/document-edit.png new file mode 100644 index 0000000..c5883ac Binary files /dev/null and b/gui/resources/document-edit.png differ diff --git a/gui/saverthread.cpp b/gui/saverthread.cpp index 5e80244..db0aa53 100644 --- a/gui/saverthread.cpp +++ b/gui/saverthread.cpp @@ -253,7 +253,7 @@ void SaverThread::run() } Trace::Close(); - emit traceSaved(m_fileName); + emit traceSaved(); } #include "saverthread.moc" diff --git a/gui/saverthread.h b/gui/saverthread.h index d39d51b..5bea5b7 100644 --- a/gui/saverthread.h +++ b/gui/saverthread.h @@ -20,7 +20,7 @@ public slots: const QList &calls); signals: - void traceSaved(const QString &fileName); + void traceSaved(); protected: virtual void run();