]> git.cworth.org Git - apitrace/blobdiff - gui/apitrace.cpp
Better naming for bitmask signature.
[apitrace] / gui / apitrace.cpp
index e98eeff04f278118c73af45ee88c5273edda2e78..376b73fe3cce24e85af08613e0759aaa6059600c 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()
@@ -102,7 +106,7 @@ int ApiTrace::numCallsInFrame(int idx) const
 {
     const ApiTraceFrame *frame = frameAt(idx);
     if (frame)
-        return frame->calls.count();
+        return frame->numChildren();
     else
         return 0;
 }
@@ -118,6 +122,9 @@ void ApiTrace::setFileName(const QString &name)
         }
         m_frames.clear();
         m_calls.clear();
+        m_errors.clear();
+        m_editedCalls.clear();
+        m_needsSaving = false;
         emit invalidated();
 
         m_loader->loadFile(m_fileName);
@@ -139,17 +146,20 @@ void ApiTrace::addFrames(const QList<ApiTraceFrame*> &frames)
 {
     int currentFrames = m_frames.count();
     int numNewFrames = frames.count();
+
+    emit beginAddingFrames(currentFrames, numNewFrames);
+
     m_frames += frames;
 
     int currentCalls = m_calls.count();
     int numNewCalls = 0;
     foreach(ApiTraceFrame *frame, frames) {
         frame->setParentTrace(this);
-        numNewCalls += frame->calls.count();
-        m_calls += frame->calls;
+        numNewCalls += frame->numChildren();
+        m_calls += frame->calls();
     }
 
-    emit framesAdded(currentFrames, numNewFrames);
+    emit endAddingFrames();
     emit callsAdded(currentCalls, numNewCalls);
 }
 
@@ -158,6 +168,8 @@ void ApiTrace::detectFrames()
     if (m_calls.isEmpty())
         return;
 
+    emit beginAddingFrames(0, m_frames.count());
+
     ApiTraceFrame *currentFrame = 0;
     foreach(ApiTraceCall *apiCall, m_calls) {
         if (!currentFrame) {
@@ -166,7 +178,7 @@ void ApiTrace::detectFrames()
             currentFrame->number = m_frames.count();
         }
         apiCall->setParentFrame(currentFrame);
-        currentFrame->calls.append(apiCall);
+        currentFrame->addCall(apiCall);
         if (ApiTrace::isCallAFrameMarker(apiCall,
                                          m_frameMarker)) {
             m_frames.append(currentFrame);
@@ -180,7 +192,7 @@ void ApiTrace::detectFrames()
         m_frames.append(currentFrame);
         currentFrame = 0;
     }
-    emit framesAdded(0, m_frames.count());
+    emit endAddingFrames();
 }
 
 ApiTraceCall * ApiTrace::callWithIndex(int idx) const
@@ -207,14 +219,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 +253,36 @@ 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();
+}
+
+void ApiTrace::callError(ApiTraceCall *call)
+{
+    Q_ASSERT(call);
+
+    if (call->hasError())
+        m_errors.insert(call);
+    else
+        m_errors.remove(call);
+
+    emit changed(call);
+}
+
+bool ApiTrace::hasErrors() const
+{
+    return !m_errors.isEmpty();
 }
 
 #include "apitrace.moc"