summaryrefslogtreecommitdiffstats
path: root/languages/cpp/debugger/gdbbreakpointwidget.h
blob: c0728deca1464520c776a5eff869ec3cc65b2e92 (plain)
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
/***************************************************************************
    begin                : Tue May 13 2003
    copyright            : (C) 2003 by John Birch
    email                : jbb@kdevelop.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef _GDBBreakpointWidget_H_
#define _GDBBreakpointWidget_H_

#include <tqhbox.h>
#include <tqpopupmenu.h>
#include <tqtable.h>
#include <tqguardedptr.h>
#include <tqvaluevector.h>

#include "mi/gdbmi.h"
#include "gdbcontroller.h"

class TQDomElement;
class TQToolButton;
class TQLabel;
class KURL;

/***************************************************************************/
/***************************************************************************/
/***************************************************************************/

namespace GDBDebugger
{
class Breakpoint;
class BreakpointTableRow;
class GDBTable;
class GDBController;

class GDBBreakpointWidget : public QHBox
{
    Q_OBJECT

public:
    GDBBreakpointWidget( GDBController* controller,
                         TQWidget* parent=0, const char* name=0 );
    virtual ~GDBBreakpointWidget();

    void reset();

    void savePartialProjectSession(TQDomElement* el);
    void restorePartialProjectSession(const TQDomElement* el);

    bool hasWatchpointForAddress(unsigned long long address) const;


public slots:
    // Connected to from the editor widget:
    void slotToggleBreakpoint(const TQString &filename, int lineNum);
    void slotToggleBreakpointEnabled(const TQString &fileName, int lineNum);

    // Connected to from the variable widget:
    void slotToggleWatchpoint(const TQString &varName);

    void slotBreakpointSet(Breakpoint*);

    void slotRefreshBP(const KURL &filename);

    void slotBreakpointHit(int id);

    
protected:
    virtual void focusInEvent(TQFocusEvent *e);


    friend class BreakpointActionCell; // for access to slotNewValue
private slots:
    void slotRemoveBreakpoint();
    void slotRemoveAllBreakpoints();
    void slotEditBreakpoint(const TQString &fileName, int lineNum);
    void slotEditBreakpoint();
    void slotAddBlankBreakpoint(int idx);
    void slotRowDoubleClicked(int row, int col, int button, const TQPoint & mousePos);
    void slotContextMenuShow( int row, int col, const TQPoint &mousePos );
    void slotContextMenuSelect( int item );
    void slotEditRow(int row, int col, const TQPoint & mousePos);
    void slotNewValue(int row, int col);
    void editTracing(TQTableItem* item);
    void slotBreakpointModified(Breakpoint*);

    void slotEvent(GDBController::event_t);
    void slotWatchpointHit(int id,
                           const TQString& oldValue,
                           const TQString& newValue);

signals:
    void publishBPState(const Breakpoint& brkpt);
    void refreshBPState(const Breakpoint& brkpt);
    void gotoSourcePosition(const TQString &fileName, int lineNum);
    // Emitted when output from yet another passed tracepoint is available.
    void tracingOutput(const char*);

private:
    BreakpointTableRow* find(Breakpoint *bp);
    BreakpointTableRow* findId(int id);
    BreakpointTableRow* findKey(int BPKey);

    void setActive();
    BreakpointTableRow* addBreakpoint(Breakpoint *bp);
    void removeBreakpoint(BreakpointTableRow* btr);

    void sendToGdb(Breakpoint &);

    void handleBreakpointList(const GDBMI::ResultRecord&);
    void handleTracingPrintf(const TQValueVector<TQString>& s);

private:
    GDBController*  controller_;

    GDBTable*       m_table;
    TQPopupMenu*     m_ctxMenu;
};

class BreakpointTableRow;

/** Custom table cell class for cells that require complex editing.
    When current, the cell shows a "..." on the right. When clicked,
    the 'edit' signal is emitted that can be be used to pop-up
    a dialog box. 

    When editing is done, the receiver of 'edit' should change the
    value in the table, and then call the 'updateValue' method.    
 */
class ComplexEditCell : public TQObject, public QTableItem
{
    Q_OBJECT
public:

    ComplexEditCell(TQTable* table);

    /** Called by Qt when the current cell should become editable.
        In our case, when the item becomes current. Creates a widget
        that will be shown in the cell and should be able to edit cell
        content. In our case -- text plus "..." button that invokes 
        action dialog.        
    */
    TQWidget* createEditor() const;    

    void updateValue();

private slots:

    /** Called when the "..." button is clicked. */
    void slotEdit();

signals:
    void edit(TQTableItem*);

private:
    mutable TQGuardedPtr<TQLabel> label_;
};


/***************************************************************************/
/***************************************************************************/
/***************************************************************************/

}

#endif