Factor a loop into findByFileName().
[kdbg.git] / kdbg / winstack.h
blob60fa55d0d5bb2abcf6c91b2089e6ac761ab1d3da
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 WINSTACK_H
8 #define WINSTACK_H
10 #include <qptrlist.h>
11 #include <qdialog.h>
12 #include <qlineedit.h>
13 #include <qlayout.h>
14 #include <qcheckbox.h>
15 #include <qpushbutton.h>
16 #include <qtooltip.h>
17 #include <ktabwidget.h>
18 #include "valarray.h"
20 // forward declarations
21 class KDebugger;
22 class WinStack;
23 class SourceWindow;
24 class DisassembledCode;
25 struct DbgAddr;
27 class FindDialog : public QDialog
29 Q_OBJECT
30 public:
31 FindDialog();
32 ~FindDialog();
34 bool caseSensitive() const { return m_caseCheck.isChecked(); }
35 QString searchText() const { return m_searchText.text(); }
36 virtual void done(int result);
38 QLineEdit m_searchText;
39 QCheckBox m_caseCheck;
40 QPushButton m_buttonForward;
41 QPushButton m_buttonBackward;
42 QPushButton m_buttonClose;
44 signals:
45 void closed();
47 protected:
48 virtual void closeEvent(QCloseEvent* ev);
49 QVBoxLayout m_layout;
50 QHBoxLayout m_buttons;
54 class ValueTip : public QToolTip
56 public:
57 ValueTip(WinStack* parent);
58 virtual ~ValueTip() {} // Qt3's QToolTip lacks virtual dtor!
59 virtual void maybeTip(const QPoint& p);
60 void tip(const QRect& r, const QString& s) { QToolTip::tip(r, s); }
64 class WinStack : public KTabWidget
66 Q_OBJECT
67 public:
68 WinStack(QWidget* parent, const char* name);
69 virtual ~WinStack();
71 /**
72 * Slot activate also looks in this directory when the specified file is
73 * a relative path.
75 void setExtraDirectory(const QString& dir) { m_lastOpenDir = dir; }
76 void activateFile(const QString& fileName);
77 bool activeLine(QString& filename, int& lineNo);
78 bool activeLine(QString& filename, int& lineNo, DbgAddr& address);
79 void maybeTip(const QPoint& p);
80 bool hasWindows() const { return m_fileList.size() > 0; }
81 QString activeFileName() const;
82 SourceWindow* activeWindow() const;
84 virtual QSize sizeHint() const;
86 signals:
87 void fileChanged();
88 void toggleBreak(const QString&, int, const DbgAddr&, bool);
89 void enadisBreak(const QString&, int, const DbgAddr&);
90 void newFileLoaded();
91 void initiateValuePopup(const QString&);
92 void disassemble(const QString&, int);
93 void setTabWidth(int numChars);
94 void moveProgramCounter(const QString&, int, const DbgAddr&);
96 public slots:
97 virtual void slotFindForward();
98 virtual void slotFindBackward();
99 virtual void activate(const QString& filename, int lineNo, const DbgAddr& address);
100 void updatePC(const QString& filename, int lineNo, const DbgAddr& address, int frameNo);
101 void reloadAllFiles();
102 void updateLineItems(const KDebugger* deb);
103 void slotSetTabWidth(int numChars);
105 void slotFileReload();
106 void slotViewFind();
107 void slotBrkptSet();
108 void slotBrkptSetTemp();
109 void slotBrkptEnable();
110 void slotMoveProgramCounter();
112 // Displays the value tip at m_tipLocation
113 void slotShowValueTip(const QString& tipText);
115 // Shows the disassembled code at the location given by file and lineNo
116 void slotDisassembled(const QString& fileName, int lineNo,
117 const QList<DisassembledCode>& disass);
119 // Updates line items after expanding/collapsing disassembled code
120 void slotExpandCollapse(int lineNo);
122 protected:
123 bool activatePath(QString pathname, int lineNo, const DbgAddr& address);
124 virtual bool activateWindow(SourceWindow* fw, int lineNo, const DbgAddr& address); /* -1 doesnt change line */
125 virtual void contextMenuEvent(QContextMenuEvent* e);
126 void setPC(bool set, const QString& fileName, int lineNo,
127 const DbgAddr& address, int frameNo);
128 SourceWindow* findByFileName(const QString& fileName) const;
129 ValArray<SourceWindow*> m_fileList;
130 QString m_lastOpenDir; /* where user opened last file */
132 // program counter
133 QString m_pcFile;
134 int m_pcLine; /* -1 if no PC */
135 QString m_pcAddress; /* exact address of PC */
136 int m_pcFrame;
138 ValueTip m_valueTip;
139 QRect m_tipLocation; /* where tip should appear */
141 int m_tabWidth; /* number of chars */
143 public:
144 // find dialog
145 FindDialog m_findDlg;
148 #endif // WINSTACK_H