Refine "View Code" command.
[kdbg.git] / kdbg / mainwndbase.h
blob36b1c6d7ff3c52293010e046699c12e4cdf61a62
1 /*
2 * Copyright Johannes Sixt
3 * This file is licensed under the GNU General Public License Version 2.
4 * See the file COPYING in the toplevel directory of the source directory.
5 */
7 #ifndef MAINWNDBASE_H
8 #define MAINWNDBASE_H
10 #include <qlineedit.h>
11 #include <qlayout.h>
12 #include <qpushbutton.h>
13 #include <qcstring.h>
14 #include "exprwnd.h"
15 #include "sys/types.h" /* pid_t */
17 // forward declarations
18 class KDebugger;
19 class TTYWindow;
20 class UpdateUI;
21 class KToolBar;
22 class KStatusBar;
23 class KProcess;
24 class DebuggerDriver;
26 class WatchWindow : public QWidget
28 Q_OBJECT
29 public:
30 WatchWindow(QWidget* parent, const char* name, WFlags f = 0);
31 ~WatchWindow();
32 ExprWnd* watchVariables() { return &m_watchVariables; }
33 QString watchText() const { return m_watchEdit.text(); }
34 int columnWidth(int i) const { return m_watchVariables.columnWidth(i); }
35 void setColumnWidth(int i, int w) { m_watchVariables.setColumnWidth(i, w); }
37 protected:
38 QLineEdit m_watchEdit;
39 QPushButton m_watchAdd;
40 QPushButton m_watchDelete;
41 ExprWnd m_watchVariables;
42 QVBoxLayout m_watchV;
43 QHBoxLayout m_watchH;
45 virtual bool eventFilter(QObject* ob, QEvent* ev);
46 virtual void dragEnterEvent(QDragEnterEvent* event);
47 virtual void dropEvent(QDropEvent* event);
49 signals:
50 void addWatch();
51 void deleteWatch();
52 void textDropped(const QString& text);
54 protected slots:
55 void slotWatchHighlighted();
59 class DebuggerMainWndBase
61 public:
62 DebuggerMainWndBase();
63 virtual ~DebuggerMainWndBase();
65 /**
66 * Sets the command to invoke the terminal that displays the program
67 * output. If cmd is the empty string, the default is substituted.
69 void setTerminalCmd(const QString& cmd);
70 /**
71 * Sets the command to invoke the debugger.
73 void setDebuggerCmdStr(const QString& cmd);
74 /**
75 * Specifies the file where to write the transcript.
77 void setTranscript(const QString& name);
78 /**
79 * Starts to debug the specified program using the specified language
80 * driver.
82 bool debugProgram(const QString& executable, QString lang, QWidget* parent);
83 /**
84 * Specifies the process to attach to after the program is loaded.
86 void setAttachPid(const QString& pid);
88 // the following are needed to handle program arguments
89 void setCoreFile(const QString& corefile);
90 void setRemoteDevice(const QString &remoteDevice);
91 void overrideProgramArguments(const QString& args);
92 /** helper around KFileDialog */
93 static QString myGetFileName(QString caption,
94 QString dir, QString filter,
95 QWidget* parent);
96 /** invokes the global options dialog */
97 virtual void doGlobalOptions(QWidget* parent);
99 protected:
100 // settings
101 virtual void saveSettings(KConfig*);
102 virtual void restoreSettings(KConfig*);
104 // override must return the integrated output window
105 virtual TTYWindow* ttyWindow() = 0;
107 // statusbar texts
108 QString m_statusActive;
110 // output window
111 QString m_outputTermCmdStr;
112 QString m_outputTermKeepScript;
113 KProcess* m_outputTermProc;
114 int m_ttyLevel;
115 virtual QString createOutputWindow(); /* returns terminal name */
116 void shutdownTermWindow();
118 QString m_lastDirectory; /* the dir of the most recently opened file */
120 QString m_transcriptFile; /* where gdb dialog is logged */
122 bool m_popForeground; /* whether main wnd raises when prog stops */
123 int m_backTimeout; /* when wnd goes back */
124 int m_tabWidth; /* tab width in characters (can be 0) */
125 QString m_sourceFilter;
126 QString m_headerFilter;
128 // the debugger proper
129 QString m_debuggerCmdStr;
130 KDebugger* m_debugger;
131 void setupDebugger(QWidget* parent,
132 ExprWnd* localVars,
133 ExprWnd* watchVars,
134 QListBox* backtrace);
135 DebuggerDriver* driverFromLang(QString lang);
137 * This function derives a driver name from the contents of the named
138 * file.
140 QString driverNameFromFile(const QString& exe);
142 public:
144 * Important! The following functions must be overridden in derived
145 * classes and be declared as slots! Note: These must not be declared
146 * virtual here since Qt signal mechanism fails miserably (because this
147 * class will not be the left-most base class!).
149 void newStatusMsg(KStatusBar* statusbar);
150 void slotDebuggerStarting();
153 #endif // MAINWNDBASE_H