21 #ifndef GRAPHELEMENTMODEL_H 22 #define GRAPHELEMENTMODEL_H 24 #include <tulip/TulipModel.h> 25 #include <tulip/GraphModel.h> 31 class TLP_QT_SCOPE GraphElementModel :
public TulipModel {
34 GraphElementModel(Graph *graph,
unsigned int id, QObject *parent =
nullptr);
36 int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
37 int columnCount(
const QModelIndex &parent = QModelIndex())
const override;
38 QModelIndex parent(
const QModelIndex &child)
const override;
40 QVariant headerData(
int section, Qt::Orientation orientation,
int role)
const override;
41 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex())
const override;
42 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole)
const override;
44 virtual QString headerText(
unsigned int id)
const = 0;
45 virtual QVariant value(
unsigned int id, PropertyInterface *prop)
const = 0;
47 Qt::ItemFlags flags(
const QModelIndex &index)
const override;
49 const static int PropertyNameRole = 33;
52 QVector<PropertyInterface *> getGraphProperties()
const;
58 class TLP_QT_SCOPE GraphNodeElementModel :
public GraphElementModel {
61 GraphNodeElementModel(Graph *graph,
unsigned int id, QObject *parent =
nullptr)
62 : GraphElementModel(graph, id, parent) {}
64 QString headerText(
unsigned int id)
const override {
65 return QString(
"node: ") + QString::number(
id);
68 QVariant value(
unsigned int id, PropertyInterface *prop)
const override {
69 return GraphModel::nodeValue(
id, prop);
72 bool setData(
const QModelIndex &index,
const QVariant &value,
int role)
override;
75 class TLP_QT_SCOPE GraphEdgeElementModel :
public GraphElementModel {
78 GraphEdgeElementModel(Graph *graph,
unsigned int id, QObject *parent =
nullptr)
79 : GraphElementModel(graph, id, parent) {}
81 QString headerText(
unsigned int id)
const override {
82 return QString(
"edge: ") + QString::number(
id);
85 QVariant value(
unsigned int id, PropertyInterface *prop)
const override {
86 return GraphModel::edgeValue(
id, prop);
89 bool setData(
const QModelIndex &index,
const QVariant &value,
int role)
override;
93 #endif // GRAPHELEMENTMODEL_H