16#ifndef LUA_DEBUGGER_WATCH_H
17#define LUA_DEBUGGER_WATCH_H
23#include <QStandardItemModel>
26#include <QStyledItemDelegate>
42class QStandardItemModel;
49constexpr int Spec = 0;
50constexpr int Value = 1;
51constexpr int Count = 2;
64 using QStandardItemModel::QStandardItemModel;
76 bool dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
77 const QModelIndex &parent)
override;
131 void startDrag(Qt::DropActions supportedActions)
override;
143 void dropEvent(QDropEvent *event)
override;
174 using QStyledItemDelegate::QStyledItemDelegate;
183 QWidget *
createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index)
const override;
195 using QStyledItemDelegate::QStyledItemDelegate;
203 void paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index)
const override;
212 QWidget *
createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index)
const override;
228 using CommitFn = std::function<void(QStandardItem *item,
const QString &text)>;
245 QWidget *
createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index)
const override;
252 void setEditorData(QWidget *editor,
const QModelIndex &index)
const override;
260 void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index)
const override;
299 void applyEmpty(QStandardItem *item,
const QString &muted,
const QString &watchTipExtra);
302 void applyNoLiveContext(QStandardItem *item,
const QString &muted,
const QString &watchTipExtra);
305 void applyError(QStandardItem *item,
const QString &errStr,
const QString &watchTipExtra);
308 void applySuccess(QStandardItem *item,
const QString &spec,
const char *val,
const char *typ,
bool can_expand,
309 const QString &watchTipExtra,
int stackLevel,
bool changeHighlightAllowed);
312 void applyExpression(QStandardItem *item,
const QString &spec,
const char *val,
const char *typ,
bool can_expand,
313 const QString &watchTipExtra,
int stackLevel,
bool changeHighlightAllowed);
316 QTreeView *tree_ =
nullptr;
317 QStandardItemModel *model_ =
nullptr;
349 void attach(QTreeView *tree, QStandardItemModel *model);
413 void applyItemState(QStandardItem *item,
bool liveContext,
const QString &muted);
424 void insertNewRow(
const QString &initialSpec = QString(),
bool openEditor =
true);
445 void deleteRows(
const QList<QStandardItem *> &items);
541 void fillPathChildren(QStandardItem *parent,
const QString &path);
551 void fillExprChildren(QStandardItem *parent,
const QString &rootSpec,
const QString &subpath);
556 void updateHeaderButtonState();
562 QTreeView *tree_ =
nullptr;
565 QStandardItemModel *model_ =
nullptr;
568 QToolButton *removeButton_ =
nullptr;
571 QToolButton *removeAllButton_ =
nullptr;
582 QHash<QString, LuaDbgTreeSectionExpansionState> expansion_;
590 qint32 placeholderEpoch_ = 0;
Variables tree: block inline editors on all columns.
Definition lua_debugger_watch.h:169
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Blocks editor creation by returning a null pointer.
Definition lua_debugger_watch.cpp:296
Model that routes drops to column 0 for watch reordering.
Definition lua_debugger_watch.h:60
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Handles a drop event, forcing the target column to 0 to preserve watch item order.
Definition lua_debugger_watch.cpp:82
Root watch cell: inline line edit for the expression column.
Definition lua_debugger_watch.h:219
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Creates the inline line editor for the cell.
Definition lua_debugger_watch.cpp:332
std::function< void(QStandardItem *item, const QString &text)> CommitFn
Callback invoked from setModelData when the user finishes editing a top-level watch row's expression....
Definition lua_debugger_watch.h:228
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Saves the editor's data back to the model.
Definition lua_debugger_watch.cpp:370
void setEditorData(QWidget *editor, const QModelIndex &index) const override
Sets the data to be displayed and edited in the editor.
Definition lua_debugger_watch.cpp:350
Value column: elide middle; no editor.
Definition lua_debugger_watch.h:190
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Blocks editor creation by returning a null pointer.
Definition lua_debugger_watch.cpp:318
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Custom paint method to elide text in the middle.
Definition lua_debugger_watch.cpp:305
"Value changed since last pause" highlighter for the Watch and Variables trees.
Definition lua_debugger_utils.h:989
Top-level dialog hosting the Lua debugger UI components.
Definition lua_debugger_dialog.h:189
Owns the dialog's font story end-to-end.
Definition lua_debugger_code_editor.h:414
Watch panel: column layout, expand/collapse tracking + lazy fill, runtime expansion-state map,...
Definition lua_debugger_watch.h:330
void invalidatePlaceholder()
Cancel the deferred placeholder by bumping the epoch. Call from handlePause() so the imminent refresh...
Definition lua_debugger_watch.cpp:1737
void restoreFrom(const QVariantMap &settingsMap)
Replace the watch tree with the contents of Watches in settingsMap. Empty / container-typed entries a...
Definition lua_debugger_watch.cpp:1698
void insertNewRow(const QString &initialSpec=QString(), bool openEditor=true)
Insert a top-level watch row; optionally open the inline editor. An empty initialSpec creates a "pend...
Definition lua_debugger_watch.cpp:1256
void copyValueForItem(QStandardItem *item, const QModelIndex &ix)
Copy the (untruncated when paused) value of item to the clipboard; shared between the row context men...
Definition lua_debugger_watch.cpp:1162
void applyItemState(QStandardItem *item, bool liveContext, const QString &muted)
Apply the per-row presentation for item given the current liveness context. Reads the row state,...
Definition lua_debugger_watch.cpp:1602
void onCollapsed(const QModelIndex &index)
Records the collapse of the item at index in the runtime expansion map.
Definition lua_debugger_watch.cpp:950
void scheduleDeferredPlaceholder()
Schedule a deferred "Watch column shows —" placeholder paint after a step resume.
Definition lua_debugger_watch.cpp:1742
void refillChildren(QStandardItem *item)
Re-query and replace all children of item. Used by the lazy-expand path and by refreshBranch after pa...
Definition lua_debugger_watch.cpp:833
void removeAllTopLevelItems()
Confirm with the user, then remove every top-level row.
Definition lua_debugger_watch.cpp:1124
void refreshDisplay()
Refresh value/type (and expansion affordances) for all watch roots, recursing into already-expanded b...
Definition lua_debugger_watch.cpp:1562
void onExpanded(const QModelIndex &index)
Records the expansion of the item at index in the runtime expansion map.
Definition lua_debugger_watch.cpp:905
void showContextMenu(const QPoint &pos)
Displays the watch row context menu at the given viewport position.
Definition lua_debugger_watch.cpp:973
void restoreExpansionState()
Re-expand persisted subpaths after refilling roots from settings.
Definition lua_debugger_watch.cpp:874
void attachHeaderButtons(QToolButton *remove, QToolButton *removeAll)
Bind the section-header strip. Click signals are wired here; enable/disable state tracks the model an...
Definition lua_debugger_watch.cpp:742
QList< QStandardItem * > selectedRootItemsForRemove() const
Top-level watch rows in the current selection (column 0) only; used by the section header Remove cont...
Definition lua_debugger_watch.cpp:1069
QStringList expandedSubpathsForSpec(const QString &rootSpec) const
Look up expanded descendant keys for rootSpec (may be empty).
Definition lua_debugger_watch.cpp:794
void pruneExpansionMap()
Drop expansion-map entries for watch specs no longer in the tree.
Definition lua_debugger_watch.cpp:799
void deleteRows(const QList< QStandardItem * > &items)
Delete the given top-level watch rows from the tree. Children, non-top-level rows and stale pointers ...
Definition lua_debugger_watch.cpp:1092
void configureColumns() const
Configures column widths, resize modes, and visibility for the watch tree.
Definition lua_debugger_watch.cpp:780
void commitWatchRootSpec(QStandardItem *item, const QString &text)
Apply the user's edit of a top-level watch row's expression.
Definition lua_debugger_watch.cpp:1316
void serializeTo(QVariantMap &settingsMap)
Snapshot the live watch tree as a flat array of canonical spec strings into settingsMap (at the Watch...
Definition lua_debugger_watch.cpp:1664
void attach(QTreeView *tree, QStandardItemModel *model)
Bind the tree + model and wire all watch-internal signals (typed LuaDbgWatchTreeWidget gestures,...
Definition lua_debugger_watch.cpp:684
void refreshBranch(QStandardItem *item)
Re-evaluate one expanded branch depth-first; preserves the controller-tracked expansion state of nest...
Definition lua_debugger_watch.cpp:1582
void duplicateRootItem(QStandardItem *item)
Duplicate top-level watch row item below itself.
Definition lua_debugger_watch.cpp:1216
Per-row presentation for top-level Watch rows.
Definition lua_debugger_watch.h:283
void applyNoLiveContext(QStandardItem *item, const QString &muted, const QString &watchTipExtra)
Live context unavailable (debugger not paused).
Definition lua_debugger_watch.cpp:417
void applyExpression(QStandardItem *item, const QString &spec, const char *val, const char *typ, bool can_expand, const QString &watchTipExtra, int stackLevel, bool changeHighlightAllowed)
Expression-style watch root with a successful read.
Definition lua_debugger_watch.cpp:551
void applyError(QStandardItem *item, const QString &errStr, const QString &watchTipExtra)
Watch evaluation failed (path not found, expr error, etc.).
Definition lua_debugger_watch.cpp:458
void applySuccess(QStandardItem *item, const QString &spec, const char *val, const char *typ, bool can_expand, const QString &watchTipExtra, int stackLevel, bool changeHighlightAllowed)
Path-style watch root with a successful read.
Definition lua_debugger_watch.cpp:500
void applyEmpty(QStandardItem *item, const QString &muted, const QString &watchTipExtra)
Empty top-level row (no spec yet).
Definition lua_debugger_watch.cpp:394
Column indices for the Watch tree model.
Definition lua_debugger_watch.h:48