Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Public Slots | Public Member Functions | List of all members
LuaDebuggerWatchController Class Reference

Watch panel: column layout, expand/collapse tracking + lazy fill, runtime expansion-state map, and context menu. Inline edits to top-level rows enter via commitWatchRootSpec, which the delegate calls through the commit callback set in attach. More...

#include <lua_debugger_watch.h>

Inheritance diagram for LuaDebuggerWatchController:

Public Slots

void onExpanded (const QModelIndex &index)
 Records the expansion of the item at index in the runtime expansion map.
 
void onCollapsed (const QModelIndex &index)
 Records the collapse of the item at index in the runtime expansion map.
 
void showContextMenu (const QPoint &pos)
 Displays the watch row context menu at the given viewport position.
 

Public Member Functions

 LuaDebuggerWatchController (LuaDebuggerDialog *host)
 Constructs the watch controller bound to the given dialog host.
 
void attach (QTreeView *tree, QStandardItemModel *model)
 Bind the tree + model and wire all watch-internal signals (typed LuaDbgWatchTreeWidget gestures, expand/collapse, context menu, inline-edit delegate, and the model/selection signals that drive the header buttons attached via attachHeaderButtons). Cross-panel concerns (variables ↔ watch sync) stay with the dialog.
 
void attachHeaderButtons (QToolButton *remove, QToolButton *removeAll)
 Bind the section-header strip. Click signals are wired here; enable/disable state tracks the model and selection. Safe to call before or after attach.
 
void configureColumns () const
 Configures column widths, resize modes, and visibility for the watch tree.
 
void pruneExpansionMap ()
 Drop expansion-map entries for watch specs no longer in the tree.
 
void restoreExpansionState ()
 Re-expand persisted subpaths after refilling roots from settings.
 
QStringList expandedSubpathsForSpec (const QString &rootSpec) const
 Look up expanded descendant keys for rootSpec (may be empty).
 
void refillChildren (QStandardItem *item)
 Re-query and replace all children of item. Used by the lazy-expand path and by refreshBranch after pause / step.
 
void refreshDisplay ()
 Refresh value/type (and expansion affordances) for all watch roots, recursing into already-expanded branches. Safe to call when no watches exist or when the debugger is not paused (rows fall back to a muted placeholder).
 
void refreshBranch (QStandardItem *item)
 Re-evaluate one expanded branch depth-first; preserves the controller-tracked expansion state of nested rows. No-op when item is null or its branch is collapsed.
 
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, then dispatches to the matching LuaDebuggerWatchRowPresenter apply* method (the presenter owns cell text / icons / tooltips / change-highlight stamping).
 
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 "pending new" row. Otherwise the spec must be a Variables-style path (see wslua_debugger_watch_spec_uses_path_resolution). Duplicates of an existing spec just scroll to the existing row.
 
void commitWatchRootSpec (QStandardItem *item, const QString &text)
 Apply the user's edit of a top-level watch row's expression.
 
void deleteRows (const QList< QStandardItem * > &items)
 Delete the given top-level watch rows from the tree. Children, non-top-level rows and stale pointers are silently ignored. Drops change-highlight baselines for the now-orphaned specs.
 
void removeAllTopLevelItems ()
 Confirm with the user, then remove every top-level row.
 
void copyValueForItem (QStandardItem *item, const QModelIndex &ix)
 Copy the (untruncated when paused) value of item to the clipboard; shared between the row context menu and the keyboard shortcut.
 
void duplicateRootItem (QStandardItem *item)
 Duplicate top-level watch row item below itself.
 
QList< QStandardItem * > selectedRootItemsForRemove () const
 Top-level watch rows in the current selection (column 0) only; used by the section header Remove control. No currentIndex fallback, so the button does not act on a non-selected row.
 
void serializeTo (QVariantMap &settingsMap)
 Snapshot the live watch tree as a flat array of canonical spec strings into settingsMap (at the Watches key). Per-row expansion, editor origin, and other runtime state are tracked in QStandardItem data roles only and are not persisted. Also prunes the runtime expansion map to specs that survive in the tree.
 
void restoreFrom (const QVariantMap &settingsMap)
 Replace the watch tree with the contents of Watches in settingsMap. Empty / container-typed entries are dropped; scalar values are kept as expression watches even if they are not valid Lua (the next refresh will surface the error). Wipes all watch baselines (variables baselines are kept) so the first refresh starts clean.
 
void scheduleDeferredPlaceholder ()
 Schedule a deferred "Watch column shows —" placeholder paint after a step resume.
 
void invalidatePlaceholder ()
 Cancel the deferred placeholder by bumping the epoch. Call from handlePause() so the imminent refresh wins over a pending post-resume placeholder.
 

Detailed Description

Watch panel: column layout, expand/collapse tracking + lazy fill, runtime expansion-state map, and context menu. Inline edits to top-level rows enter via commitWatchRootSpec, which the delegate calls through the commit callback set in attach.

Constructor & Destructor Documentation

◆ LuaDebuggerWatchController()

LuaDebuggerWatchController::LuaDebuggerWatchController ( LuaDebuggerDialog host)
explicit

Constructs the watch controller bound to the given dialog host.

Parameters
hostThe parent debugger dialog that owns this controller.

Member Function Documentation

◆ applyItemState()

void LuaDebuggerWatchController::applyItemState ( QStandardItem *  item,
bool  liveContext,
const QString &  muted 
)

Apply the per-row presentation for item given the current liveness context. Reads the row state, then dispatches to the matching LuaDebuggerWatchRowPresenter apply* method (the presenter owns cell text / icons / tooltips / change-highlight stamping).

Parameters
itemThe item to update.
liveContextTrue if the debugger is currently paused and values are available.
mutedPlaceholder string to display when values are unavailable.

◆ attach()

void LuaDebuggerWatchController::attach ( QTreeView *  tree,
QStandardItemModel *  model 
)

Bind the tree + model and wire all watch-internal signals (typed LuaDbgWatchTreeWidget gestures, expand/collapse, context menu, inline-edit delegate, and the model/selection signals that drive the header buttons attached via attachHeaderButtons). Cross-panel concerns (variables ↔ watch sync) stay with the dialog.

Parameters
treeThe tree view to bind.
modelThe standard item model backing the tree.

◆ attachHeaderButtons()

void LuaDebuggerWatchController::attachHeaderButtons ( QToolButton *  remove,
QToolButton *  removeAll 
)

Bind the section-header strip. Click signals are wired here; enable/disable state tracks the model and selection. Safe to call before or after attach.

Parameters
removeThe Remove Selected button.
removeAllThe Remove All button.

◆ commitWatchRootSpec()

void LuaDebuggerWatchController::commitWatchRootSpec ( QStandardItem *  item,
const QString &  text 
)

Apply the user's edit of a top-level watch row's expression.

   Empty text removes the row (or discards a pending-new row); too-long
   text shows a warning and is rejected; otherwise the spec is committed,
   change-highlight baselines for the old and new specs are dropped, and
   the row is refreshed. Bound to the inline-editor delegate via the
   commit callback set in @ref attach.
Parameters
itemThe top-level item being edited.
textThe new expression text entered by the user.

◆ copyValueForItem()

void LuaDebuggerWatchController::copyValueForItem ( QStandardItem *  item,
const QModelIndex &  ix 
)

Copy the (untruncated when paused) value of item to the clipboard; shared between the row context menu and the keyboard shortcut.

Parameters
itemThe item whose value is to be copied.
ixThe model index of the item.

◆ deleteRows()

void LuaDebuggerWatchController::deleteRows ( const QList< QStandardItem * > &  items)

Delete the given top-level watch rows from the tree. Children, non-top-level rows and stale pointers are silently ignored. Drops change-highlight baselines for the now-orphaned specs.

Parameters
itemsThe list of top-level items to delete.

◆ duplicateRootItem()

void LuaDebuggerWatchController::duplicateRootItem ( QStandardItem *  item)

Duplicate top-level watch row item below itself.

Parameters
itemThe top-level item to duplicate.

◆ expandedSubpathsForSpec()

QStringList LuaDebuggerWatchController::expandedSubpathsForSpec ( const QString &  rootSpec) const

Look up expanded descendant keys for rootSpec (may be empty).

Parameters
rootSpecThe canonical spec string of the root watch row to query.
Returns
List of expanded subpath strings under the given root spec.

◆ insertNewRow()

void LuaDebuggerWatchController::insertNewRow ( const QString &  initialSpec = QString(),
bool  openEditor = true 
)

Insert a top-level watch row; optionally open the inline editor. An empty initialSpec creates a "pending new" row. Otherwise the spec must be a Variables-style path (see wslua_debugger_watch_spec_uses_path_resolution). Duplicates of an existing spec just scroll to the existing row.

Parameters
initialSpecThe expression or path to watch, or empty to create a pending row.
openEditorIf true, immediately opens the inline editor on the new row.

◆ onCollapsed

void LuaDebuggerWatchController::onCollapsed ( const QModelIndex &  index)
slot

Records the collapse of the item at index in the runtime expansion map.

Parameters
indexThe model index of the item that was collapsed.

◆ onExpanded

void LuaDebuggerWatchController::onExpanded ( const QModelIndex &  index)
slot

Records the expansion of the item at index in the runtime expansion map.

Parameters
indexThe model index of the item that was expanded.

◆ refillChildren()

void LuaDebuggerWatchController::refillChildren ( QStandardItem *  item)

Re-query and replace all children of item. Used by the lazy-expand path and by refreshBranch after pause / step.

Parameters
itemThe parent item whose children are to be refilled.

◆ refreshBranch()

void LuaDebuggerWatchController::refreshBranch ( QStandardItem *  item)

Re-evaluate one expanded branch depth-first; preserves the controller-tracked expansion state of nested rows. No-op when item is null or its branch is collapsed.

Parameters
itemThe root item of the branch to refresh.

◆ restoreFrom()

void LuaDebuggerWatchController::restoreFrom ( const QVariantMap &  settingsMap)

Replace the watch tree with the contents of Watches in settingsMap. Empty / container-typed entries are dropped; scalar values are kept as expression watches even if they are not valid Lua (the next refresh will surface the error). Wipes all watch baselines (variables baselines are kept) so the first refresh starts clean.

Parameters
settingsMapThe map containing previously serialized watch specs.

◆ scheduleDeferredPlaceholder()

void LuaDebuggerWatchController::scheduleDeferredPlaceholder ( )

Schedule a deferred "Watch column shows —" placeholder paint after a step resume.

Bumps an internal epoch and posts a single-shot timer; if a new pause arrives within WATCH_PLACEHOLDER_DEFER_MS, the next call to invalidatePlaceholder bumps the epoch again and the still-pending timer becomes a no-op. Without this defer step a typical fast single-step produces a visible value→—→value blink in every Watch row even when the value did not change.

◆ selectedRootItemsForRemove()

QList< QStandardItem * > LuaDebuggerWatchController::selectedRootItemsForRemove ( ) const

Top-level watch rows in the current selection (column 0) only; used by the section header Remove control. No currentIndex fallback, so the button does not act on a non-selected row.

Returns
List of selected top-level items eligible for removal.

◆ serializeTo()

void LuaDebuggerWatchController::serializeTo ( QVariantMap &  settingsMap)

Snapshot the live watch tree as a flat array of canonical spec strings into settingsMap (at the Watches key). Per-row expansion, editor origin, and other runtime state are tracked in QStandardItem data roles only and are not persisted. Also prunes the runtime expansion map to specs that survive in the tree.

Parameters
settingsMapThe map to write the serialized watch specs into.

◆ showContextMenu

void LuaDebuggerWatchController::showContextMenu ( const QPoint &  pos)
slot

Displays the watch row context menu at the given viewport position.

Parameters
posThe position (in tree viewport coordinates) at which to show the menu.

The documentation for this class was generated from the following files: