Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
lua_debugger_breakpoints.h
Go to the documentation of this file.
1/* lua_debugger_breakpoints.h
2 *
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <[email protected]>
5 * Copyright 1998 Gerald Combs
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
9
16#ifndef LUA_DEBUGGER_BREAKPOINTS_H
17#define LUA_DEBUGGER_BREAKPOINTS_H
18
19#include <QIcon>
20#include <QLineEdit>
21#include <QList>
22#include <QObject>
23#include <QSet>
24#include <QString>
25#include <QStyledItemDelegate>
26#include <QVariantMap>
27#include <QVector>
28
29#include "lua_debugger_utils.h"
30
33class QAbstractItemModel;
34class QAction;
35class QComboBox;
36class QEvent;
37class QModelIndex;
38class QObject;
39class QPalette;
40class QPaintEvent;
41class QPoint;
42class QResizeEvent;
43class QShowEvent;
44class QStandardItem;
45class QStandardItemModel;
46class QStyleOptionViewItem;
47class QToolButton;
48class QTreeView;
49class QWidget;
50
53{
54constexpr int Active = 0;
55constexpr int Line = 1;
56constexpr int Location = 2;
57constexpr int Count = 3;
58} // namespace BreakpointColumn
59
60/* ===== breakpoint_modes ===== */
61
76{
77
78enum class Mode : int
79{
80 Expression = 0,
81 HitCount = 1,
82 LogMessage = 2,
83};
84
90{
91 Mode mode;
92 const char *label;
93 const char *placeholder;
94 const char *valueTooltip;
95};
96
98constexpr int kModeCount = 3;
99
102
104QString translatedLabel(const ModeSpec &spec);
105
110const char *draftPropertyName(Mode m);
111
115QComboBox *editorHitModeCombo(QWidget *editor);
116
120QToolButton *editorPauseToggle(QWidget *editor);
121
132void applyEditorMode(QWidget *editor, int modeIndex);
133
146QIcon makePauseIcon(const QPalette &palette);
147
150QString pauseToggleStyleSheet();
151
152} // namespace LuaDbgBreakpointModes
153
154/* ===== breakpoint_inline_editor ===== */
155
184class BreakpointInlineLineEdit : public QLineEdit
185{
186 public:
187 explicit BreakpointInlineLineEdit(QWidget *parent = nullptr);
188
192 void setEmbeddedWidgets(QComboBox *modeCombo, QComboBox *hitModeCombo, QToolButton *pauseButton);
193
205 void relayout();
206
207 protected:
208 void resizeEvent(QResizeEvent *e) override;
209 void showEvent(QShowEvent *e) override;
210 void paintEvent(QPaintEvent *e) override;
211
212 private:
213 QComboBox *modeCombo_ = nullptr;
214 QComboBox *hitModeCombo_ = nullptr;
215 QToolButton *pauseButton_ = nullptr;
216};
217
218/* ===== breakpoint_delegate ===== */
219
230class LuaDbgBreakpointConditionDelegate : public QStyledItemDelegate
231{
232 public:
234
235 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
236 const QModelIndex &index) const override;
237 void setEditorData(QWidget *editor, const QModelIndex &index) const override;
238 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
239 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
240 const QModelIndex &index) const override;
241 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
242
243 protected:
244 bool eventFilter(QObject *watched, QEvent *event) override;
245
246 private:
248 int preferredEditorHeight() const;
249 mutable int cachedPreferredHeight_ = 0;
250};
251
252/* ===== breakpoints_controller ===== */
253
265{
266 Q_OBJECT
267
268 public:
270
272 void attach(QTreeView *tree, QStandardItemModel *model);
273
276 void attachHeaderButtons(QToolButton *toggleAll, QToolButton *remove, QToolButton *removeAll, QToolButton *edit,
277 QAction *removeAllAction);
278
279 void configureColumns() const;
280
282 void startInlineEdit(int row);
283
288 void serializeTo(QVariantMap &settingsMap) const;
289
293 void restoreFrom(const QVariantMap &settingsMap);
294
296 void refreshFromEngine();
297
299 void clearAll();
300
311 void toggleAtLine(const QString &file, qint32 line);
312
319 void toggleOnCodeViewLine(LuaDebuggerCodeView *codeView, qint32 line);
320
331 void shiftToggleAtLine(const QString &file, qint32 line);
332
344 void setActiveFromUser(const QString &file, qint32 line, bool active);
345
351 void removeAtLine(const QString &file, qint32 line);
352
354 void toggleAllActive();
355
358
360 bool removeRows(const QList<int> &rows);
361
363 bool removeSelected();
364
365 public slots:
366 void onItemDoubleClicked(const QModelIndex &index);
367 void showContextMenu(const QPoint &pos);
369 void onItemChanged(QStandardItem *item);
371 void onModelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
373 void showGutterMenu(const QString &filename, qint32 line, const QPoint &globalPos);
374
375 private:
377 void refreshAllOpenTabMarkers() const;
379 void refreshOpenTabMarkers(const QSet<QString> &files) const;
380
381 LuaDebuggerDialog *host_ = nullptr;
382 QTreeView *tree_ = nullptr;
383 QStandardItemModel *model_ = nullptr;
384
385 QToolButton *toggleAllButton_ = nullptr;
386 QToolButton *removeButton_ = nullptr;
387 QToolButton *removeAllButton_ = nullptr;
388 QToolButton *editButton_ = nullptr;
389 QAction *removeAllAction_ = nullptr;
390
397 QIcon headerIconCache_[3];
398 QString headerIconCacheKey_;
399
405 bool tabsPrimed_ = false;
406
414 bool suppressItemChanged_ = false;
415};
416
417#endif
Inline editor for the Breakpoints "Location" column.
Definition lua_debugger_breakpoints.h:185
void relayout()
Definition lua_debugger_breakpoints.cpp:349
void setEmbeddedWidgets(QComboBox *modeCombo, QComboBox *hitModeCombo, QToolButton *pauseButton)
Definition lua_debugger_breakpoints.cpp:340
Item delegate for the Breakpoints list Location column (condition / hit count / log message inline ed...
Definition lua_debugger_breakpoints.h:231
Owns the breakpoints panel: tree wiring, model rebuild from the engine, inline edit dispatch,...
Definition lua_debugger_breakpoints.h:265
void startInlineEdit(int row)
Focus column 2 and open the delegate editor when editable.
Definition lua_debugger_breakpoints.cpp:1262
void shiftToggleAtLine(const QString &file, qint32 line)
Pre-arm a breakpoint at file:@p line — the Shift+click gutter gesture. If absent, creates the breakpo...
Definition lua_debugger_breakpoints.cpp:2199
void attachHeaderButtons(QToolButton *toggleAll, QToolButton *remove, QToolButton *removeAll, QToolButton *edit, QAction *removeAllAction)
Bind the section-header strip and its shortcut action. Wires button clicks; safe to call before or af...
Definition lua_debugger_breakpoints.cpp:1181
void setActiveFromUser(const QString &file, qint32 line, bool active)
Set the active flag of an existing breakpoint at file:@p line. Used by the gutter context menu's Enab...
Definition lua_debugger_breakpoints.cpp:2229
bool removeRows(const QList< int > &rows)
Remove the breakpoints in the given (deduped) model rows.
Definition lua_debugger_breakpoints.cpp:1964
void toggleAtLine(const QString &file, qint32 line)
Add the breakpoint at file:@p line if absent, otherwise remove it. Drives F9 in the editor,...
Definition lua_debugger_breakpoints.cpp:2168
bool removeSelected()
Remove every selected breakpoint row.
Definition lua_debugger_breakpoints.cpp:2008
void updateHeaderButtonState()
Refresh header dot icon + button enable states.
Definition lua_debugger_breakpoints.cpp:2066
void restoreFrom(const QVariantMap &settingsMap)
Apply the Breakpoints array from settingsMap to the engine. Missing keys fall back to the engine's de...
Definition lua_debugger_breakpoints.cpp:2354
void toggleAllActive()
Activate-all / deactivate-all toggle (header).
Definition lua_debugger_breakpoints.cpp:2030
void serializeTo(QVariantMap &settingsMap) const
Snapshot the engine breakpoint list (file/line/active + condition / hit-count / log-message) into set...
Definition lua_debugger_breakpoints.cpp:2302
void refreshFromEngine()
Rebuild tree rows from the engine; refreshes header chrome.
Definition lua_debugger_breakpoints.cpp:1473
void removeAtLine(const QString &file, qint32 line)
Remove the breakpoint at file:@p line and refresh chrome. Drives the gutter context menu's Remove act...
Definition lua_debugger_breakpoints.cpp:2245
void onItemChanged(QStandardItem *item)
Active-checkbox toggle from the model.
Definition lua_debugger_breakpoints.cpp:1729
void showGutterMenu(const QString &filename, qint32 line, const QPoint &globalPos)
Show Edit/Disable/Remove popup for a click in an editor gutter.
Definition lua_debugger_breakpoints.cpp:1887
void clearAll()
Confirm-and-clear all breakpoints (header / shortcut).
Definition lua_debugger_breakpoints.cpp:1450
void onModelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
Role-based dispatch for delegate-driven inline edits.
Definition lua_debugger_breakpoints.cpp:1766
void attach(QTreeView *tree, QStandardItemModel *model)
Bind the tree + model and wire their signals.
Definition lua_debugger_breakpoints.cpp:1158
void toggleOnCodeViewLine(LuaDebuggerCodeView *codeView, qint32 line)
Convenience overload that resolves the file path from a LuaDebuggerCodeView. Silently ignores null vi...
Definition lua_debugger_breakpoints.cpp:2190
Editable code editor supporting gutter breakpoints and highlighting.
Definition lua_debugger_code_editor.h:127
Top-level dialog hosting the Lua debugger UI components.
Definition lua_debugger_dialog.h:165
Column indices for the Breakpoints tree model.
Definition lua_debugger_breakpoints.h:53
Inline editor mode metadata for the Breakpoints "Location" column.
Definition lua_debugger_breakpoints.cpp:91
QIcon makePauseIcon(const QPalette &palette)
Definition lua_debugger_breakpoints.cpp:256
QString translatedLabel(const ModeSpec &spec)
Definition lua_debugger_breakpoints.cpp:136
constexpr int kModeCount
Definition lua_debugger_breakpoints.h:98
QToolButton * editorPauseToggle(QWidget *editor)
Definition lua_debugger_breakpoints.cpp:164
QString pauseToggleStyleSheet()
Definition lua_debugger_breakpoints.cpp:316
const ModeSpec kBreakpointEditModes[kModeCount]
Definition lua_debugger_breakpoints.cpp:93
const char * draftPropertyName(Mode m)
Definition lua_debugger_breakpoints.cpp:141
QComboBox * editorHitModeCombo(QWidget *editor)
Definition lua_debugger_breakpoints.cpp:155
void applyEditorMode(QWidget *editor, int modeIndex)
Definition lua_debugger_breakpoints.cpp:173
Definition lua_debugger_breakpoints.h:90