26 #include <QSortFilterProxyModel> 28 #include <tulip/Observable.h> 29 #include <tulip/TulipModel.h> 33 class PropertyInterface;
34 class BooleanProperty;
36 class TLP_QT_SCOPE GraphModel :
public tlp::TulipModel,
public Observable {
50 explicit GraphModel(QObject *parent =
nullptr);
56 int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
57 int columnCount(
const QModelIndex &parent = QModelIndex())
const override;
58 QModelIndex parent(
const QModelIndex &child)
const override;
59 Qt::ItemFlags flags(
const QModelIndex &index)
const override;
61 QVariant headerData(
int section, Qt::Orientation orientation,
int role)
const override;
62 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex())
const override;
63 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole)
const override;
64 bool setData(
const QModelIndex &index,
const QVariant &value,
int role)
override;
67 void treatEvents(
const std::vector<tlp::Event> &)
override;
69 unsigned int elementAt(
int)
const;
73 virtual bool isNode()
const = 0;
77 QVector<unsigned int> _elements;
78 QVector<QPair<unsigned int, bool>> _elementsToModify;
79 QVector<PropertyInterface *> _properties;
80 QSet<PropertyInterface *> _propertiesModified;
83 void addRemoveRowsSequence(QVector<unsigned int> &rowsSequence,
bool add);
86 class TLP_QT_SCOPE GraphSortFilterProxyModel :
public QSortFilterProxyModel,
public Observable {
87 QVector<PropertyInterface *> _properties;
88 BooleanProperty *_filterProperty;
91 GraphSortFilterProxyModel(QObject *parent =
nullptr);
94 void setSelectedOnly(
bool);
95 void setProperties(QVector<PropertyInterface *>);
97 bool lessThan(
const QModelIndex &left,
const QModelIndex &right)
const override;
98 bool filterAcceptsRow(
int sourceRow,
const QModelIndex &sourceParent)
const override;
105 class TLP_QT_SCOPE NodesGraphModel :
public GraphModel {
107 NodesGraphModel(QObject *parent =
nullptr);
108 void setGraph(Graph *)
override;
111 void treatEvents(
const std::vector<tlp::Event> &)
override;
115 QVariant headerData(
int section, Qt::Orientation orientation,
int role)
const override;
117 bool isNode()
const override {
121 static QString getNodeTooltip(Graph *graph, node n);
131 class TLP_QT_SCOPE EdgesGraphModel :
public GraphModel {
133 EdgesGraphModel(QObject *parent =
nullptr);
134 void setGraph(Graph *)
override;
136 void treatEvents(
const std::vector<tlp::Event> &)
override;
140 QVariant headerData(
int section, Qt::Orientation orientation,
int role)
const override;
142 bool isNode()
const override {
146 static QString getEdgeTooltip(Graph *graph, edge e);
157 #endif // GRAPHMODEL_H
A graph property that maps a boolean value to graph elements.
PropertyInterface describes the interface of a graph property.
Event is the base class for all events used in the Observation mechanism.