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 <gerald@wireshark.org>
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
59{
60constexpr int Active = 0;
61constexpr int Hits = 1;
62constexpr int Line = 2;
63constexpr int Location = 3;
64constexpr int Count = 4;
65} // namespace BreakpointColumn
66
67/* ===== breakpoint_modes ===== */
68
83{
84
88enum class Mode : int
89{
90 Expression = 0,
91 HitCount = 1,
92 LogMessage = 2,
93};
94
100{
101 Mode mode;
102 const char *label;
103 const char *placeholder;
104 const char *valueTooltip;
105};
106
108constexpr int kModeCount = 3;
109
112
114QString translatedLabel(const ModeSpec &spec);
115
120const char *draftPropertyName(Mode m);
121
125QComboBox *editorHitModeCombo(QWidget *editor);
126
130QToolButton *editorPauseToggle(QWidget *editor);
131
142void applyEditorMode(QWidget *editor, int modeIndex);
143
156QIcon makePauseIcon(const QPalette &palette);
157
160QString pauseToggleStyleSheet();
161
162} // namespace LuaDbgBreakpointModes
163
164/* ===== breakpoint_inline_editor ===== */
165
194class BreakpointInlineLineEdit : public QLineEdit
195{
196 public:
201 explicit BreakpointInlineLineEdit(QWidget *parent = nullptr);
202
206 void setEmbeddedWidgets(QComboBox *modeCombo, QComboBox *hitModeCombo, QToolButton *pauseButton);
207
219 void relayout();
220
221 protected:
226 void resizeEvent(QResizeEvent *e) override;
231 void showEvent(QShowEvent *e) override;
236 void paintEvent(QPaintEvent *e) override;
237
238 private:
239 QComboBox *modeCombo_ = nullptr;
240 QComboBox *hitModeCombo_ = nullptr;
241 QToolButton *pauseButton_ = nullptr;
242};
243
244/* ===== breakpoint_delegate ===== */
245
256class LuaDbgBreakpointConditionDelegate : public QStyledItemDelegate
257{
258public:
265
274 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
275 const QModelIndex &index) const override;
276
283 void setEditorData(QWidget *editor, const QModelIndex &index) const override;
284
292 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
293
301 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
302 const QModelIndex &index) const override;
303
311 QSize sizeHint(const QStyleOptionViewItem &option,
312 const QModelIndex &index) const override;
313
314protected:
322 bool eventFilter(QObject *watched, QEvent *event) override;
323
324private:
330 int preferredEditorHeight() const;
331
333 mutable int cachedPreferredHeight_ = 0;
334};
335
336/* ===== breakpoints_controller ===== */
337
349{
350 Q_OBJECT
351
352 public:
358
364 void attach(QTreeView *tree, QStandardItemModel *model);
365
377 void attachHeaderButtons(QToolButton *breakOnError, QToolButton *toggleAll, QToolButton *remove,
378 QToolButton *removeAll, QToolButton *edit, QAction *removeAllAction);
379
383 void configureColumns() const;
384
386 void startInlineEdit(int row);
387
396 void serializeTo(QVariantMap &settingsMap) const;
397
406 void restoreFrom(const QVariantMap &settingsMap);
407
409 void refreshFromEngine();
410
412 void clearAll();
413
424 void toggleAtLine(const QString &file, qint32 line);
425
435 void toggleOnCodeViewLine(LuaDebuggerCodeView *codeView, qint32 line);
436
450 void shiftToggleAtLine(const QString &file, qint32 line);
451
467 void setActiveFromUser(const QString &file, qint32 line, bool active);
468
477 void removeAtLine(const QString &file, qint32 line);
478
488 void moveAtLine(const QString &file, qint32 fromLine, qint32 toLine);
489
491 void toggleAllActive();
492
495
497 bool removeRows(const QList<int> &rows);
498
500 bool removeSelected();
501
502 public slots:
508 void onItemDoubleClicked(const QModelIndex &index);
509
514 void showContextMenu(const QPoint &pos);
519 void onItemChanged(QStandardItem *item);
526 void onModelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
533 void showGutterMenu(const QString &filename, qint32 line, const QPoint &globalPos);
534
535 private:
537 void refreshAllOpenTabMarkers() const;
542 void refreshOpenTabMarkers(const QSet<QString> &files) const;
543
544 LuaDebuggerDialog *host_ = nullptr;
545 QTreeView *tree_ = nullptr;
546 QStandardItemModel *model_ = nullptr;
547
548 QToolButton *breakOnErrorButton_ = nullptr;
549 QToolButton *toggleAllButton_ = nullptr;
550 QToolButton *removeButton_ = nullptr;
551 QToolButton *removeAllButton_ = nullptr;
552 QToolButton *editButton_ = nullptr;
553 QAction *removeAllAction_ = nullptr;
554
561 QIcon headerIconCache_[3];
562 QString headerIconCacheKey_;
563
569 bool tabsPrimed_ = false;
570
578 bool suppressItemChanged_ = false;
579};
580
581#endif
Inline editor for the Breakpoints "Location" column.
Definition lua_debugger_breakpoints.h:195
void relayout()
Definition lua_debugger_breakpoints.cpp:396
void resizeEvent(QResizeEvent *e) override
Handle resize events.
Definition lua_debugger_breakpoints.cpp:503
void showEvent(QShowEvent *e) override
Handle show events.
Definition lua_debugger_breakpoints.cpp:509
void setEmbeddedWidgets(QComboBox *modeCombo, QComboBox *hitModeCombo, QToolButton *pauseButton)
Definition lua_debugger_breakpoints.cpp:387
void paintEvent(QPaintEvent *e) override
Handle paint events.
Definition lua_debugger_breakpoints.cpp:520
Item delegate for the Breakpoints list Location column (condition / hit count / log message inline ed...
Definition lua_debugger_breakpoints.h:257
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Position and size the editor to fill the cell rectangle.
Definition lua_debugger_breakpoints.cpp:1049
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Create a QLineEdit editor for a breakpoint condition cell.
Definition lua_debugger_breakpoints.cpp:578
bool eventFilter(QObject *watched, QEvent *event) override
Filter key events on the editor to control commit and cancel.
Definition lua_debugger_breakpoints.cpp:1083
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Write the edited condition expression back to the model.
Definition lua_debugger_breakpoints.cpp:981
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
Return the preferred size for a condition cell.
Definition lua_debugger_breakpoints.cpp:1067
void setEditorData(QWidget *editor, const QModelIndex &index) const override
Populate the editor with the cell's current condition string.
Definition lua_debugger_breakpoints.cpp:910
Owns the breakpoints panel: tree wiring, model rebuild from the engine, inline edit dispatch,...
Definition lua_debugger_breakpoints.h:349
void startInlineEdit(int row)
Focus column 2 and open the delegate editor when editable.
Definition lua_debugger_breakpoints.cpp:1345
void configureColumns() const
Configure the columns in the breakpoints tree.
Definition lua_debugger_breakpoints.cpp:1301
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:2282
void onItemDoubleClicked(const QModelIndex &index)
Double-click on a breakpoint row to edit its condition.
Definition lua_debugger_breakpoints.cpp:1365
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:2312
bool removeRows(const QList< int > &rows)
Remove the breakpoints in the given (deduped) model rows.
Definition lua_debugger_breakpoints.cpp:2047
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:2251
bool removeSelected()
Remove every selected breakpoint row.
Definition lua_debugger_breakpoints.cpp:2091
void updateHeaderButtonState()
Refresh header dot icon + button enable states.
Definition lua_debugger_breakpoints.cpp:2149
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:2532
void toggleAllActive()
Activate-all / deactivate-all toggle (header).
Definition lua_debugger_breakpoints.cpp:2113
void moveAtLine(const QString &file, qint32 fromLine, qint32 toLine)
Move a breakpoint in file from fromLine to toLine, preserving metadata. No-op if either line is inval...
Definition lua_debugger_breakpoints.cpp:2341
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:2479
void showContextMenu(const QPoint &pos)
Show context menu for a right-click in the breakpoint tree.
Definition lua_debugger_breakpoints.cpp:1389
void refreshFromEngine()
Rebuild tree rows from the engine; refreshes header chrome.
Definition lua_debugger_breakpoints.cpp:1556
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:2328
void onItemChanged(QStandardItem *item)
Active-checkbox toggle from the model.
Definition lua_debugger_breakpoints.cpp:1814
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:1970
void attachHeaderButtons(QToolButton *breakOnError, 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:1228
void clearAll()
Confirm-and-clear all breakpoints (header / shortcut).
Definition lua_debugger_breakpoints.cpp:1533
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:1849
void attach(QTreeView *tree, QStandardItemModel *model)
Bind the tree + model and wire their signals.
Definition lua_debugger_breakpoints.cpp:1205
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:2273
Editable code editor supporting gutter breakpoints and highlighting.
Definition lua_debugger_code_editor.h:136
Top-level dialog hosting the Lua debugger UI components.
Definition lua_debugger_dialog.h:189
Column indices for the Breakpoints tree model.
Definition lua_debugger_breakpoints.h:59
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
Mode
Selects the operational mode of a conditional breakpoint or debug action.
Definition lua_debugger_breakpoints.h:89
QString translatedLabel(const ModeSpec &spec)
Definition lua_debugger_breakpoints.cpp:136
constexpr int kModeCount
Definition lua_debugger_breakpoints.h:108
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:100