21 #ifndef GRAPHELEMENTMODEL_H
22 #define GRAPHELEMENTMODEL_H
28 #include <tulip/TulipModel.h>
29 #include <tulip/GraphModel.h>
33 class TLP_QT_SCOPE GraphElementModel :
public TulipModel {
36 GraphElementModel(Graph *graph,
unsigned int id, QObject *parent =
nullptr);
38 int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
39 int columnCount(
const QModelIndex &parent = QModelIndex())
const override;
40 QModelIndex parent(
const QModelIndex &child)
const override;
42 QVariant headerData(
int section, Qt::Orientation orientation,
int role)
const override;
43 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex())
const override;
44 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole)
const override;
46 virtual QString headerText(
unsigned int id)
const = 0;
47 virtual QVariant value(
unsigned int id, PropertyInterface *prop)
const = 0;
49 Qt::ItemFlags flags(
const QModelIndex &index)
const override;
51 const static int PropertyNameRole = 33;
53 void setVisibleProperties(
const std::vector<std::string> &props) {
54 _visibleProps.clear();
55 for (
auto prop : props)
56 _visibleProps.insert(prop);
60 std::vector<PropertyInterface *> getGraphProperties()
const;
64 std::set<std::string> _visibleProps;
67 class TLP_QT_SCOPE GraphNodeElementModel :
public GraphElementModel {
70 GraphNodeElementModel(Graph *graph,
unsigned int id, QObject *parent =
nullptr)
71 : GraphElementModel(graph, id, parent) {}
73 QString headerText(
unsigned int id)
const override {
74 return QString(
"node: ") + QString::number(
id);
77 QVariant value(
unsigned int id, PropertyInterface *prop)
const override {
78 return GraphModel::nodeValue(
id, prop);
81 bool setData(
const QModelIndex &index,
const QVariant &value,
int role)
override;
84 class TLP_QT_SCOPE GraphEdgeElementModel :
public GraphElementModel {
87 GraphEdgeElementModel(Graph *graph,
unsigned int id, QObject *parent =
nullptr)
88 : GraphElementModel(graph, id, parent) {}
90 QString headerText(
unsigned int id)
const override {
91 return QString(
"edge: ") + QString::number(
id);
94 QVariant value(
unsigned int id, PropertyInterface *prop)
const override {
95 return GraphModel::edgeValue(
id, prop);
98 bool setData(
const QModelIndex &index,
const QVariant &value,
int role)
override;