10#ifndef PROTO_TREE_MODEL_H
11#define PROTO_TREE_MODEL_H
16#include <QAbstractItemModel>
46 virtual Qt::ItemFlags
flags(
const QModelIndex &
index)
const override;
54 QModelIndex
index(
int row,
int,
const QModelIndex &
parent = QModelIndex())
const override;
61 virtual QModelIndex
parent(
const QModelIndex &
index)
const override;
68 virtual int rowCount(
const QModelIndex &
parent = QModelIndex())
const override;
74 virtual int columnCount(
const QModelIndex &)
const override{
return 1; }
82 virtual QVariant
data(
const QModelIndex &
index,
int role = Qt::DisplayRole)
const override;
132 static bool foreachFindHfid(
ProtoNode *node,
void *find_hfid_ptr);
141 static bool foreachFindField(
ProtoNode *node,
void *find_finfo_ptr);
A wrapper class for the core proto_node structure, providing tree traversal and data access.
Definition proto_node.h:24
void setRootNode(proto_node *root_node)
Sets the root node of the proto_node tree exposed by this model.
Definition proto_tree_model.cpp:183
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of child rows under parent.
Definition proto_tree_model.cpp:77
QModelIndex findFirstHfid(int hf_id)
Searches the tree for the first node whose header-field ID matches hf_id.
Definition proto_tree_model.cpp:239
~ProtoTreeModel()
Destroys the model. Does not free the underlying proto_node tree.
Definition proto_tree_model.cpp:33
ProtoTreeModel(QObject *parent=0)
Constructs an empty ProtoTreeModel with no root node.
Definition proto_tree_model.cpp:27
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns data for the given index and role.
Definition proto_tree_model.cpp:91
virtual Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags for the given index.
Definition proto_tree_model.cpp:38
virtual int columnCount(const QModelIndex &) const override
Returns the number of columns (always 1).
Definition proto_tree_model.h:74
QModelIndex indexFromProtoNode(ProtoNode *index_node) const
Returns the model index corresponding to the given ProtoNode.
Definition proto_tree_model.cpp:202
ProtoNode * protoNodeFromIndex(const QModelIndex &index) const
Returns the ProtoNode wrapper for the item at the given model index.
Definition proto_tree_model.cpp:197
QModelIndex index(int row, int, const QModelIndex &parent=QModelIndex()) const override
Returns the model index for the child at row under parent.
Definition proto_tree_model.cpp:48
QModelIndex findFieldInformation(FieldInformation *finfo)
Searches the tree for the node that corresponds to the given FieldInformation.
Definition proto_tree_model.cpp:274
virtual QModelIndex parent(const QModelIndex &index) const override
Returns the parent index of the item at index.
Definition proto_tree_model.cpp:68
struct _proto_node proto_node