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

Model for displaying translation units in a tree view. More...

#include <TranslationUnitModel.h>

Inheritance diagram for acav::TranslationUnitModel:
[legend]

Public Member Functions

 TranslationUnitModel (FileManager &fileManager, QObject *parent=nullptr)
bool hasChildren (const QModelIndex &parent=QModelIndex()) const override
bool canFetchMore (const QModelIndex &parent) const override
void fetchMore (const QModelIndex &parent) override
void populateFromDependencies (const QJsonObject &dependenciesJson, const QString &overrideProjectRoot=QString(), const QString &compilationDbPath=QString())
 Populate model from query-dependencies JSON output.
QString getSourceFilePathFromIndex (const QModelIndex &index) const
 Get the source file path from a model index.
QStringList getIncludedHeadersForSource (const QString &sourceFilePath) const
 Get all included headers for a source file.
QModelIndex findIndexByFilePath (const QString &filePath) const
 Find model index by file path (legacy method for compatibility).
QModelIndex findIndexByAnyFilePath (const QString &filePath) const
QModelIndex findIndexByAnyFilePathUnder (const QString &filePath, const QModelIndex &root) const
QModelIndex findIndexByFileId (FileID fileId) const
 Find model index by FileID.
void clear ()
 Clear all data from the model.
QString projectRoot () const
 Get the computed project root directory.

Detailed Description

Model for displaying translation units in a tree view.

This model represents the list of source files from the compilation database and their dependencies. It parses the JSON output from query-dependencies and displays it in a hierarchical structure with folders for direct and indirect includes.

Uses FileManager for consistent file identification via FileID throughout the application. File paths are stored for display purposes only.

Definition at line 47 of file TranslationUnitModel.h.

Constructor & Destructor Documentation

◆ TranslationUnitModel()

acav::TranslationUnitModel::TranslationUnitModel ( FileManager & fileManager,
QObject * parent = nullptr )
explicit

Definition at line 198 of file TranslationUnitModel.cpp.

Member Function Documentation

◆ canFetchMore()

bool acav::TranslationUnitModel::canFetchMore ( const QModelIndex & parent) const
override

Definition at line 526 of file TranslationUnitModel.cpp.

◆ clear()

void acav::TranslationUnitModel::clear ( )

Clear all data from the model.

Definition at line 811 of file TranslationUnitModel.cpp.

References clear().

Referenced by clear(), and populateFromDependencies().

◆ fetchMore()

void acav::TranslationUnitModel::fetchMore ( const QModelIndex & parent)
override

Definition at line 544 of file TranslationUnitModel.cpp.

◆ findIndexByAnyFilePath()

QModelIndex acav::TranslationUnitModel::findIndexByAnyFilePath ( const QString & filePath) const

Definition at line 720 of file TranslationUnitModel.cpp.

◆ findIndexByAnyFilePathUnder()

QModelIndex acav::TranslationUnitModel::findIndexByAnyFilePathUnder ( const QString & filePath,
const QModelIndex & root ) const

Definition at line 750 of file TranslationUnitModel.cpp.

◆ findIndexByFileId()

QModelIndex acav::TranslationUnitModel::findIndexByFileId ( FileID fileId) const

Find model index by FileID.

Parameters
fileIdFileID to find
Returns
QModelIndex for the file, or invalid index if not found

Definition at line 782 of file TranslationUnitModel.cpp.

References findIndexByFileId().

Referenced by findIndexByFileId().

◆ findIndexByFilePath()

QModelIndex acav::TranslationUnitModel::findIndexByFilePath ( const QString & filePath) const

Find model index by file path (legacy method for compatibility).

Parameters
filePathFull path to the file to find
Returns
QModelIndex for the file, or invalid index if not found

Definition at line 684 of file TranslationUnitModel.cpp.

References findIndexByFilePath().

Referenced by findIndexByFilePath(), and getIncludedHeadersForSource().

◆ getIncludedHeadersForSource()

QStringList acav::TranslationUnitModel::getIncludedHeadersForSource ( const QString & sourceFilePath) const

Get all included headers for a source file.

Parameters
sourceFilePathPath to the source file
Returns
List of all included headers (direct + indirect)

Definition at line 632 of file TranslationUnitModel.cpp.

References findIndexByFilePath(), and getIncludedHeadersForSource().

Referenced by getIncludedHeadersForSource().

◆ getSourceFilePathFromIndex()

QString acav::TranslationUnitModel::getSourceFilePathFromIndex ( const QModelIndex & index) const

Get the source file path from a model index.

Parameters
indexQModelIndex from the tree view
Returns
Full path to the source file, or empty string if not a file node

Definition at line 617 of file TranslationUnitModel.cpp.

References getSourceFilePathFromIndex().

Referenced by getSourceFilePathFromIndex().

◆ hasChildren()

bool acav::TranslationUnitModel::hasChildren ( const QModelIndex & parent = QModelIndex()) const
override

Definition at line 519 of file TranslationUnitModel.cpp.

◆ populateFromDependencies()

void acav::TranslationUnitModel::populateFromDependencies ( const QJsonObject & dependenciesJson,
const QString & overrideProjectRoot = QString(),
const QString & compilationDbPath = QString() )

Populate model from query-dependencies JSON output.

Parameters
dependenciesJsonJSON object with structure: { "statistics": { "sourceFileCount": N, "totalHeaderCount": M }, "files": [ { "path": "...", "headerCount": N, "headers": [...] } ] }
overrideProjectRootOptional project root override (computed from sources if empty)
compilationDbPathPath to compile_commands.json (used for tie-breaking)

Definition at line 436 of file TranslationUnitModel.cpp.

References clear(), and populateFromDependencies().

Referenced by populateFromDependencies().

◆ projectRoot()

QString acav::TranslationUnitModel::projectRoot ( ) const
inline

Get the computed project root directory.

Returns
Project root path, or empty string if not yet populated

Definition at line 98 of file TranslationUnitModel.h.


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