From 114a878c64ce6f8223cfd22d76a20eb16d177e5e Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- languages/cpp/debugger/debuggertracingdialog.cpp | 104 +++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 languages/cpp/debugger/debuggertracingdialog.cpp (limited to 'languages/cpp/debugger/debuggertracingdialog.cpp') diff --git a/languages/cpp/debugger/debuggertracingdialog.cpp b/languages/cpp/debugger/debuggertracingdialog.cpp new file mode 100644 index 00000000..217f0b88 --- /dev/null +++ b/languages/cpp/debugger/debuggertracingdialog.cpp @@ -0,0 +1,104 @@ + +#include "debuggertracingdialog.h" +#include "breakpoint.h" + +#include +#include +#include +#include +#include +#include + +namespace GDBDebugger +{ + + DebuggerTracingDialog + ::DebuggerTracingDialog(Breakpoint* bp, + QWidget* parent, const char* name) + : DebuggerTracingDialogBase(parent, name), bp_(bp) + { + expressions->setButtons(KEditListBox::Add | KEditListBox::Remove); + + connect(enable, SIGNAL(stateChanged(int)), + this, SLOT(enableOrDisable(int))); + + connect(enableCustomFormat, SIGNAL(stateChanged(int)), + this, SLOT(enableOrDisableCustomFormat(int))); + + enable->setChecked(bp_->tracingEnabled()); + expressions->setItems(bp_->tracedExpressions()); + enableCustomFormat->setChecked(bp_->traceFormatStringEnabled()); + customFormat->setText(bp_->traceFormatString()); + + enableOrDisable(enable->state()); + } + + void DebuggerTracingDialog::enableOrDisable(int state) + { + bool enable = (state == QButton::On); + + expressionsLabel->setEnabled(enable); + expressions->setEnabled(enable); + enableCustomFormat->setEnabled(enable); + customFormat->setEnabled(enable && enableCustomFormat->isOn()); + } + + void DebuggerTracingDialog::enableOrDisableCustomFormat(int state) + { + customFormat->setEnabled(state == QButton::On); + } + + void DebuggerTracingDialog::accept() + { + // Check that if we use format string, + // the number of expression is not larget than the number of + // format specifiers + bool ok = true; + + if (enableCustomFormat->isOn()) + { + QString s = customFormat->text(); + unsigned percent_count = 0; + for (unsigned i = 0; i < s.length(); ++i) + if (s[i] == '%') + { + if (i+1 < s.length()) + { + if (s[i+1] != '%') + { + ++percent_count; + } + else + { + // Double % + ++i; + } + } + } + + if (percent_count < expressions->items().count()) + { + ok = false; + + KMessageBox::error( + this, + "Not enough format specifiers" + "

The number of format specifiers in the custom format " + "string is less then the number of expressions. Either remove " + "some expressions or edit the format string.", + "Not enough format specifiers"); + } + + } + + if (ok) + { + bp_->setTracingEnabled(enable->isOn()); + bp_->setTracedExpressions(expressions->items()); + bp_->setTraceFormatStringEnabled(enableCustomFormat->isOn()); + bp_->setTraceFormatString(customFormat->text()); + DebuggerTracingDialogBase::accept(); + } + } + +} -- cgit v1.2.1