21 #ifndef GRAPHELEMENTMODEL_H 22 #define GRAPHELEMENTMODEL_H 28 #include <tulip/TulipModel.h> 29 #include <tulip/GraphModel.h> 35 class TLP_QT_SCOPE GraphElementModel :
public TulipModel {
38 GraphElementModel(Graph *graph,
unsigned int id, QObject *parent =
nullptr);
40 int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
41 int columnCount(
const QModelIndex &parent = QModelIndex())
const override;
42 QModelIndex parent(
const QModelIndex &child)
const override;
44 QVariant headerData(
int section, Qt::Orientation orientation,
int role)
const override;
45 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex())
const override;
46 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole)
const override;
48 virtual QString headerText(
unsigned int id)
const = 0;
49 virtual QVariant value(
unsigned int id, PropertyInterface *prop)
const = 0;
51 Qt::ItemFlags flags(
const QModelIndex &index)
const override;
53 const static int PropertyNameRole = 33;
55 void setVisibleProperties(
const std::vector<std::string> &props) {
56 _visibleProps.clear();
57 for (
auto prop : props)
58 _visibleProps.insert(prop);
62 QVector<PropertyInterface *> getGraphProperties()
const;
66 std::set<std::string> _visibleProps;
69 class TLP_QT_SCOPE GraphNodeElementModel :
public GraphElementModel {
72 GraphNodeElementModel(Graph *graph,
unsigned int id, QObject *parent =
nullptr)
73 : GraphElementModel(graph, id, parent) {}
75 QString headerText(
unsigned int id)
const override {
76 return QString(
"node: ") + QString::number(
id);
79 QVariant value(
unsigned int id, PropertyInterface *prop)
const override {
80 return GraphModel::nodeValue(
id, prop);
83 bool setData(
const QModelIndex &index,
const QVariant &value,
int role)
override;
86 class TLP_QT_SCOPE GraphEdgeElementModel :
public GraphElementModel {
89 GraphEdgeElementModel(Graph *graph,
unsigned int id, QObject *parent =
nullptr)
90 : GraphElementModel(graph, id, parent) {}
92 QString headerText(
unsigned int id)
const override {
93 return QString(
"edge: ") + QString::number(
id);
96 QVariant value(
unsigned int id, PropertyInterface *prop)
const override {
97 return GraphModel::edgeValue(
id, prop);
100 bool setData(
const QModelIndex &index,
const QVariant &value,
int role)
override;
104 #endif // GRAPHELEMENTMODEL_H