X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=gui%2Fapitrace.cpp;h=376b73fe3cce24e85af08613e0759aaa6059600c;hb=fcfbf176900a32e0926450a2f1e5faa7f272823b;hp=e98eeff04f278118c73af45ee88c5273edda2e78;hpb=d809a061b7980ab874e83fd14d5b43b170dbecb1;p=apitrace diff --git a/gui/apitrace.cpp b/gui/apitrace.cpp index e98eeff..376b73f 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() @@ -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 &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"