Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
Sonde::anonymous_namespace{introspectiontools.cpp}::TreePrinter Class Reference

Prints an object tree as indented describe() lines, with the object_tree tool's limits and filters. More...

Classes

struct  HiddenNote
 One hidden subtree in the note. More...

Public Member Functions

 TreePrinter (const QJsonObject &args)
 Reads the depth, maxNodes, visibleOnly and className arguments.
void visit (QObject *o, int depth, int indent)
 Prints o and its descendants.
QString text () const
 The printed tree, with notes about truncation and hidden objects.

Private Member Functions

void noteHidden (QObject *o)
 Records hidden subtree o for the note, with what it holds, e.g.
bool addLine (const QObject *o, int indent)
 Appends the line for o.

Private Attributes

int m_maxDepth
 Deepest level printed.
int m_maxNodes
 Most lines printed.
QString m_className
 Only print objects of this class or inheriting it (empty: all).
bool m_visibleOnly
 Skip hidden subtrees.
QStringList m_lines
 Output so far.
QSet< QObject * > m_seen
 Visited objects (guards against cycles in custom trees).
QList< HiddenNote > m_hidden
 The hidden subtrees left out, those with actions first.
bool m_truncated = false
 Whether m_maxNodes was reached.

Static Private Attributes

static constexpr qsizetype kHiddenListed = 8
 Hidden subtrees named in the note; the rest are counted.
static constexpr int kMaxCounted = 10000
 Most objects counted inside one hidden subtree.

Detailed Description

Prints an object tree as indented describe() lines, with the object_tree tool's limits and filters.

Constructor & Destructor Documentation

◆ TreePrinter()

Sonde::anonymous_namespace{introspectiontools.cpp}::TreePrinter::TreePrinter ( const QJsonObject & args)
inlineexplicit

Reads the depth, maxNodes, visibleOnly and className arguments.

A className search looks in hidden subtrees too unless visibleOnly is given: a closed menu is hidden, but its actions are what such a search is usually for.

Member Function Documentation

◆ addLine()

bool Sonde::anonymous_namespace{introspectiontools.cpp}::TreePrinter::addLine ( const QObject * o,
int indent )
inlineprivate

Appends the line for o.

Returns
False once the line limit is reached.

◆ noteHidden()

void Sonde::anonymous_namespace{introspectiontools.cpp}::TreePrinter::noteHidden ( QObject * o)
inlineprivate

Records hidden subtree o for the note, with what it holds, e.g.

@0x.. QMenu title="&File" (hidden): 3 objects, 3 QAction.


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