ACAV f0ba4b7c9529
Abstract Syntax Tree (AST) visualization tool for C, C++, and Objective-C
Loading...
Searching...
No Matches
acav::AstModel Class Reference

Qt model for displaying AST hierarchy. More...

#include <AstModel.h>

Inheritance diagram for acav::AstModel:
[legend]

Public Types

enum  CustomRoles { NodePtrRole = Qt::UserRole + 1 }

Signals

void nodeSelected (AstViewNode *node)
 Emitted when node is selected.

Public Member Functions

 AstModel (QObject *parent=nullptr)
void setEmptyMessage (const QString &message)
 Message shown when the model has no AST loaded.
void setRootNode (AstViewNode *root)
 Set the root node of AST.
void setTotalNodeCount (std::size_t count)
 Set total node count for display.
void clear ()
 Clear model and delete AST.
int visibleNodeCount () const
 Number of nodes currently visible.
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
QModelIndex parent (const QModelIndex &child) const override
int rowCount (const QModelIndex &parent=QModelIndex()) const override
int columnCount (const QModelIndex &parent=QModelIndex()) const override
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Qt::ItemFlags flags (const QModelIndex &index) const override
QModelIndex selectNode (AstViewNode *node)
 Programmatically select node and get its model index.
void updateSelectionFromIndex (const QModelIndex &index)
 Update selection from a QModelIndex (e.g., when user clicks directly).
AstViewNodeselectedNode () const
 Get currently selected node.
bool hasNodes () const
 Check if model has any nodes loaded.

Detailed Description

Qt model for displaying AST hierarchy.

Implements QAbstractItemModel to display AstViewNode tree in QTreeView. Shows node kind + name in display role.

Supports millions of nodes via Qt's lazy loading.

Definition at line 41 of file AstModel.h.

Member Enumeration Documentation

◆ CustomRoles

enum acav::AstModel::CustomRoles

Definition at line 78 of file AstModel.h.

Constructor & Destructor Documentation

◆ AstModel()

acav::AstModel::AstModel ( QObject * parent = nullptr)
explicit

Definition at line 171 of file AstModel.cpp.

◆ ~AstModel()

acav::AstModel::~AstModel ( )
override

Definition at line 175 of file AstModel.cpp.

Member Function Documentation

◆ clear()

void acav::AstModel::clear ( )

Clear model and delete AST.

Definition at line 196 of file AstModel.cpp.

References clear().

Referenced by clear().

◆ columnCount()

int acav::AstModel::columnCount ( const QModelIndex & parent = QModelIndex()) const
override

Definition at line 283 of file AstModel.cpp.

◆ data()

QVariant acav::AstModel::data ( const QModelIndex & index,
int role = Qt::DisplayRole ) const
override

Definition at line 288 of file AstModel.cpp.

◆ flags()

Qt::ItemFlags acav::AstModel::flags ( const QModelIndex & index) const
override

Definition at line 393 of file AstModel.cpp.

◆ hasNodes()

bool acav::AstModel::hasNodes ( ) const
inline

Check if model has any nodes loaded.

Definition at line 95 of file AstModel.h.

◆ headerData()

QVariant acav::AstModel::headerData ( int section,
Qt::Orientation orientation,
int role = Qt::DisplayRole ) const
override

Definition at line 383 of file AstModel.cpp.

◆ index()

QModelIndex acav::AstModel::index ( int row,
int column,
const QModelIndex & parent = QModelIndex() ) const
override

Definition at line 208 of file AstModel.cpp.

◆ parent()

QModelIndex acav::AstModel::parent ( const QModelIndex & child) const
override

Definition at line 240 of file AstModel.cpp.

◆ rowCount()

int acav::AstModel::rowCount ( const QModelIndex & parent = QModelIndex()) const
override

Definition at line 263 of file AstModel.cpp.

◆ selectedNode()

AstViewNode * acav::AstModel::selectedNode ( ) const
inline

Get currently selected node.

Definition at line 92 of file AstModel.h.

◆ selectNode()

QModelIndex acav::AstModel::selectNode ( AstViewNode * node)

Programmatically select node and get its model index.

Parameters
nodeNode to select
Returns
QModelIndex for the node (invalid if not found)

Definition at line 418 of file AstModel.cpp.

References nodeSelected(), and selectNode().

Referenced by selectNode().

◆ setEmptyMessage()

void acav::AstModel::setEmptyMessage ( const QString & message)

Message shown when the model has no AST loaded.

Definition at line 180 of file AstModel.cpp.

References setEmptyMessage().

Referenced by setEmptyMessage().

◆ setRootNode()

void acav::AstModel::setRootNode ( AstViewNode * root)

Set the root node of AST.

Parameters
rootRoot AstViewNode (does NOT take ownership - owned by AstContext)

Definition at line 189 of file AstModel.cpp.

References setRootNode().

Referenced by setRootNode().

◆ setTotalNodeCount()

void acav::AstModel::setTotalNodeCount ( std::size_t count)
inline

Set total node count for display.

Definition at line 57 of file AstModel.h.

◆ updateSelectionFromIndex()

void acav::AstModel::updateSelectionFromIndex ( const QModelIndex & index)

Update selection from a QModelIndex (e.g., when user clicks directly).

Parameters
indexThe model index that was selected

Definition at line 448 of file AstModel.cpp.

References updateSelectionFromIndex().

Referenced by updateSelectionFromIndex().

◆ visibleNodeCount()

int acav::AstModel::visibleNodeCount ( ) const

Number of nodes currently visible.

Definition at line 204 of file AstModel.cpp.

References visibleNodeCount().

Referenced by visibleNodeCount().


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