]> git.cworth.org Git - apitrace/commitdiff
Lots of various cosmetic changes to the call editing.
authorZack Rusin <zack@kde.org>
Mon, 18 Apr 2011 05:05:50 +0000 (01:05 -0400)
committerZack Rusin <zack@kde.org>
Mon, 18 Apr 2011 05:05:50 +0000 (01:05 -0400)
13 files changed:
gui/apicalldelegate.cpp
gui/apicalldelegate.h
gui/apitrace.cpp
gui/apitrace.h
gui/apitracecall.cpp
gui/apitracemodel.cpp
gui/argumentseditor.cpp
gui/mainwindow.cpp
gui/mainwindow.h
gui/qapitrace.qrc
gui/resources/document-edit.png [new file with mode: 0644]
gui/saverthread.cpp
gui/saverthread.h

index 4eb542be2171bce1c410da3397fb8eb7592356c1..c2a1b23f54f47172fcc59885989011b2c68c7d58 100644 (file)
@@ -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<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);
index 525ab8320ad6be475f1d1967b2197a43e6926dcb..55cd13ef2b13b7fd2617f55899d27956b2541391 100644 (file)
@@ -17,6 +17,7 @@ public:
 
 private:
     QIcon m_stateEmblem;
+    QIcon m_editEmblem;
 };
 
 #endif
index e98eeff04f278118c73af45ee88c5273edda2e78..4ce4cd423f64873c87abb4477855ec86419c0dcd 100644 (file)
@@ -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"
index 54fc1f2713786b4fb2a503b47cdb8d29c78f199f..32e24084b26802545fb1dbe800d788239df5231f 100644 (file)
@@ -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<ApiTraceFrame*> &frames);
+    void slotSaved();
 private:
     void detectFrames();
 private:
index c9e61e2cb8c8e499dbd35de9a49849005b783518..fa709c9acfacef9fe479f347c0acadf8c53af124 100644 (file)
@@ -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(
         "<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
@@ -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("<span style=\"color:#0000ff\">") +
-                      apiVariantToString(m_argValues[i]) +
+                      apiVariantToString(argValues[i]) +
                       QLatin1Literal("</span>");
         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()) {
index 0e623c0cab1027e64ac2b51f30cad668bb4d2456..a39a92935dfba6812ab5f13512dce25535b53f1e 100644 (file)
@@ -280,12 +280,22 @@ QModelIndex ApiTraceModel::indexForCall(ApiTraceCall *call) const
 
 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"
index 125e12d9f788c8c4dcdb7d8bf39925297ab16e73..04a195249682ac20d542b81b1b35e92f94c5d6ce 100644 (file)
@@ -339,10 +339,12 @@ void ArgumentsEditor::accept()
         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;
     }
index 4edf1faf1b8f3425221bf345b5c29e881d4744bf..f9e15f825502330bc14f430e8fad915e82e4fcb2 100644 (file)
@@ -140,6 +140,14 @@ void MainWindow::callItemSelected(const QModelIndex &index)
 
 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);
@@ -278,6 +286,14 @@ void MainWindow::lookupState()
             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);
 }
@@ -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"
index e723cdd128b77adb1c5471fb832b98858708214e..07a1e912798767bcef9bb73519a7eb475d33a412 100644 (file)
@@ -60,6 +60,8 @@ private slots:
     void fillState(bool nonDefaults);
     void customContextMenuRequested(QPoint pos);
     void editCall();
+    void slotStartedSaving();
+    void slotSaved();
 
 private:
     void initObjects();
index 610eebeb3faff4bd3aa5a8449c589a132be23365..6f6597fef7b4809c9396d17214c8ddfb30b3a13b 100644 (file)
@@ -3,6 +3,7 @@
     <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>
diff --git a/gui/resources/document-edit.png b/gui/resources/document-edit.png
new file mode 100644 (file)
index 0000000..c5883ac
Binary files /dev/null and b/gui/resources/document-edit.png differ
index 5e80244ed789198dc97be5304592804a3ca10f30..db0aa532a1ac636377ab36e167cf235a4f6f5df8 100644 (file)
@@ -253,7 +253,7 @@ void SaverThread::run()
     }
     Trace::Close();
 
-    emit traceSaved(m_fileName);
+    emit traceSaved();
 }
 
 #include "saverthread.moc"
index d39d51b8760034c059b774d5cec8ab725f97b0ef..5bea5b7581fc8d07a3857da494ddeaa74e7dea08 100644 (file)
@@ -20,7 +20,7 @@ public slots:
                   const QList<ApiTraceCall*> &calls);
 
 signals:
-    void traceSaved(const QString &fileName);
+    void traceSaved();
 
 protected:
     virtual void run();