1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
/***************************************************************************
debuggerui.cpp
------------------------
begin : 2004-04-04
copyright : (C) 2004 Thiago Silva
***************************************************************************/
/****************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "debuggerui.h"
#include <kiconloader.h>
#include <kdockwidget.h>
#include <klocale.h>
#include <kdebug.h>
#include <tqstring.h>
#include <khtmlview.h>
#include <kmditoolviewaccessor.h>
#include <kstatusbar.h>
#include "variableslistview.h"
#include "debuggerbreakpointview.h"
#include "backtracelistview.h"
#include "debuggervariable.h"
#include "quantacommon.h"
#include "quanta.h"
#include "resource.h"
#include "whtmlpart.h"
DebuggerUI::DebuggerUI(TQObject *parent, const char *name)
: TQObject(parent, name), m_variablesListView(0)
{
// Variable watch tree
m_variablesListView = new VariablesListView(quantaApp->getMainDockWidget(), "debuggerVariables");
m_variablesListView->setIcon(SmallIcon("math_brace"));
m_variablesListView->setCaption(i18n("Variables"));
m_variableListViewTVA = quantaApp->addToolWindow(m_variablesListView, quantaApp->prevDockPosition(m_variablesListView, KDockWidget::DockLeft), quantaApp->getMainDockWidget());
// Breakpointlist
m_debuggerBreakpointView = new DebuggerBreakpointView(quantaApp->getMainDockWidget(), "debuggerBreakpoints");
m_debuggerBreakpointView->setIcon(SmallIcon("debug_breakpoint"));
m_debuggerBreakpointView->setCaption(i18n("Breakpoints"));
m_debuggerBreakpointViewTVA = quantaApp->addToolWindow(m_debuggerBreakpointView, quantaApp->prevDockPosition(m_debuggerBreakpointView, KDockWidget::DockBottom), quantaApp->getMainDockWidget());
// Backtrace
m_backtraceListview = new BacktraceListview(quantaApp->getMainDockWidget(), "debuggerBacktrace");
m_backtraceListview->setIcon(SmallIcon("player_playlist"));
m_backtraceListview->setCaption(i18n("Backtrace"));
m_backtraceListviewTVA = quantaApp->addToolWindow(m_backtraceListview, quantaApp->prevDockPosition(m_backtraceListview, KDockWidget::DockBottom), quantaApp->getMainDockWidget());
// Debug HTML preview
m_preview = new WHTMLPart(quantaApp, "debug_output", true);
//m_preview->view()->resize(0, 0);
m_preview->view()->setIcon(UserIcon("debug_run"));
m_preview->view()->setCaption(i18n("Debug Output"));
m_previewTVA = quantaApp->addToolWindow(m_preview->view(), quantaApp->prevDockPosition(m_preview->view(), KDockWidget::DockBottom), quantaApp->getMainDockWidget());
connect(m_preview, TQT_SIGNAL(openFile(const KURL&, const TQString&, bool)), quantaApp, TQT_SLOT(slotFileOpen(const KURL&, const TQString&, bool)));
// Show debugger toolbar
quantaApp->toolBar("debugger_toolbar")->show();
connect(m_variablesListView, TQT_SIGNAL(removeVariable(DebuggerVariable* )), parent, TQT_SLOT(slotRemoveVariable(DebuggerVariable* )));
connect(m_debuggerBreakpointView, TQT_SIGNAL(removeBreakpoint(DebuggerBreakpoint* )), parent, TQT_SLOT(slotRemoveBreakpoint(DebuggerBreakpoint* )));
showMenu();
}
DebuggerUI::~DebuggerUI()
{
hideMenu();
quantaApp->toolBar("debugger_toolbar")->hide();
// Remove Variable tree
quantaApp->deleteToolWindow(m_variableListViewTVA);
m_variableListViewTVA = 0L;
// Remove breakpointlist
quantaApp->deleteToolWindow(m_debuggerBreakpointViewTVA);
m_debuggerBreakpointViewTVA = 0L;
// Remove backtrace
quantaApp->deleteToolWindow(m_backtraceListviewTVA);
m_backtraceListviewTVA = 0L;
// Remove output
quantaApp->deleteToolWindow(m_previewTVA);
m_previewTVA = 0L;
}
void DebuggerUI::showMenu()
{
TQPopupMenu* debuggerMenu = (TQPopupMenu*)(quantaApp->guiFactory())->container("debugger_menu", quantaApp);
if(debuggerMenu)
{
KMenuBar *mb = quantaApp->menuBar();
mb->activateItemAt(-1); //needed as insertItem might crash if a menu is activated
m_debuggerMenuID = mb->insertItem(i18n("Deb&ug"), debuggerMenu, -1, 5);
}
else
m_debuggerMenuID = 0;
// tqStatus indicator
quantaApp->statusBar()->insertFixedItem(i18n("Debugger Inactive"), IDS_STATUS_DEBUGGER);
}
void DebuggerUI::hideMenu()
{
if(m_debuggerMenuID != 0)
{
KMenuBar *mb = quantaApp->menuBar();
mb->activateItemAt(-1); //needed as removeItem might crash if a menu is activated
mb->removeItem(m_debuggerMenuID);
}
m_debuggerMenuID = 0;
// tqStatus indicator
quantaApp->statusBar()->removeItem(IDS_STATUS_DEBUGGER);
}
void DebuggerUI::addVariable(DebuggerVariable* var)
{
m_variablesListView->addVariable(var);
}
void DebuggerUI::showBreakpoint(const DebuggerBreakpoint &bp)
{
m_debuggerBreakpointView->showBreakpoint(bp);
}
void DebuggerUI::deleteBreakpoint(const DebuggerBreakpoint &bp)
{
m_debuggerBreakpointView->deleteBreakpoint(bp);
}
void DebuggerUI::sendRequest(const KURL &url)
{
m_preview->openURL(url);
}
void DebuggerUI::slottqStatus( DebuggertqStatus status )
{
switch(status)
{
case NoSession:
quantaApp->statusBar()->changeItem(i18n("No session"), IDS_STATUS_DEBUGGER);
break;
case AwaitingConnection:
quantaApp->statusBar()->changeItem(i18n("Waiting"), IDS_STATUS_DEBUGGER);
break;
case Connected:
quantaApp->statusBar()->changeItem(i18n("Connected"), IDS_STATUS_DEBUGGER);
break;
case Paused:
quantaApp->statusBar()->changeItem(i18n("Paused"), IDS_STATUS_DEBUGGER);
break;
case Running:
quantaApp->statusBar()->changeItem(i18n("Running"), IDS_STATUS_DEBUGGER);
break;
case Tracing:
quantaApp->statusBar()->changeItem(i18n("Tracing"), IDS_STATUS_DEBUGGER);
break;
case HaltedOnError:
quantaApp->statusBar()->changeItem(i18n("On error"), IDS_STATUS_DEBUGGER);
break;
case HaltedOnBreakpoint:
quantaApp->statusBar()->changeItem(i18n("On breakpoint"), IDS_STATUS_DEBUGGER);
break;
default:
quantaApp->statusBar()->changeItem("", IDS_STATUS_DEBUGGER);
}
}
void DebuggerUI::backtraceClear( )
{
if(m_backtraceListview)
m_backtraceListview->clear();
}
void DebuggerUI::backtraceShow( long level, BacktraceType type, const TQString & filename, long line, const TQString & func )
{
if(m_backtraceListview)
m_backtraceListview->backtraceShow(level, type, filename, line, func);
}
#include "debuggerui.moc"
|