Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
objecttree.h File Reference

Sonde::ObjectTree: the application's object tree, object specs and QVariant/JSON conversion. More...

#include <sonde/expected.h>
#include <sonde/types.h>
#include <QtCore/QObject>
#include <QtCore/QVariant>

Go to the source code of this file.

Namespaces

namespace  Sonde
 Embeddable Model Context Protocol server for Qt applications.
namespace  Sonde::ObjectTree
 Process-wide view of the application's object tree, used by the introspection tools and by tools that target objects (clicks, screenshots).

Typedefs

using Sonde::ObjectTree::RootsProvider = std::function<QObjectList()>
 Returns additional root objects.
using Sonde::ObjectTree::ChildrenProvider = std::function<std::optional<QObjectList>(QObject *)>
 Returns the children of an object, or std::nullopt to fall through to the next provider and finally QObject::children().
using Sonde::ObjectTree::InspectProvider = std::function<QStringList(const QObject *)>
 Returns extra "name: value" lines object_inspect shows for an object (e.g.

Functions

void Sonde::ObjectTree::addRootsProvider (const QString &key, RootsProvider provider)
 Registers (or, for an existing key, replaces) a roots provider.
void Sonde::ObjectTree::addChildrenProvider (const QString &key, ChildrenProvider provider)
 Registers (or, for an existing key, replaces) a children provider.
void Sonde::ObjectTree::addInspectProvider (const QString &key, InspectProvider provider)
 Registers (or, for an existing key, replaces) an inspect provider.
QStringList Sonde::ObjectTree::inspectLines (const QObject *object)
 The extra lines every inspect provider gives for object.
QObjectList Sonde::ObjectTree::roots ()
 All roots, without duplicates; always includes the application object.
QObjectList Sonde::ObjectTree::children (QObject *object)
 The children of object according to the providers.
QString Sonde::ObjectTree::idFor (const QObject *object)
 The id of object ("@0x..."), accepted by find().
Expected< QObject * > Sonde::ObjectTree::find (const QString &spec)
 Resolves an object spec (see the namespace documentation).
bool Sonde::ObjectTree::contains (const QObject *object)
 Whether object is reachable from the roots (and therefore safe to use).
bool Sonde::ObjectTree::isOfClass (const QObject *object, QStringView className)
 Whether object is of class className or inherits it.
QString Sonde::ObjectTree::describe (const QObject *object)
 One-line summary: @id Class#name text="..." (hidden) (disabled).
QString Sonde::ObjectTree::describeBrief (const QObject *object)
 Short summary that doesn't change with the object's state: @id Class#name.
QJsonValue Sonde::ObjectTree::variantToJson (const QVariant &value)
 Converts a QVariant to JSON.
Expected< QVariant > Sonde::ObjectTree::jsonToVariant (const QJsonValue &json, QMetaType type)
 Converts JSON to a QVariant of type type (the inverse of variantToJson()).

Detailed Description

Sonde::ObjectTree: the application's object tree, object specs and QVariant/JSON conversion.