summaryrefslogtreecommitdiffstats
path: root/languages/cpp/debugger/debuggertracingdialog.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch)
treeacaf47eb0fa12142d3896416a69e74cbf5a72242 /languages/cpp/debugger/debuggertracingdialog.cpp
downloadtdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz
tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip
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
Diffstat (limited to 'languages/cpp/debugger/debuggertracingdialog.cpp')
-rw-r--r--languages/cpp/debugger/debuggertracingdialog.cpp104
1 files changed, 104 insertions, 0 deletions
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 <qbutton.h>
+#include <qlabel.h>
+#include <qcheckbox.h>
+#include <klineedit.h>
+#include <keditlistbox.h>
+#include <kmessagebox.h>
+
+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,
+ "<b>Not enough format specifiers</b>"
+ "<p>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();
+ }
+ }
+
+}