26 #include <QSortFilterProxyModel>
28 #include <tulip/Edge.h>
29 #include <tulip/Observable.h>
30 #include <tulip/TulipModel.h>
34 class PropertyInterface;
35 class BooleanProperty;
37 class TLP_QT_SCOPE GraphModel :
public tlp::TulipModel,
public Observable {
51 explicit GraphModel(QObject *parent =
nullptr);
57 int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
58 int columnCount(
const QModelIndex &parent = QModelIndex())
const override;
59 QModelIndex parent(
const QModelIndex &child)
const override;
60 Qt::ItemFlags flags(
const QModelIndex &index)
const override;
62 QVariant headerData(
int section, Qt::Orientation orientation,
int role)
const override;
63 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex())
const override;
64 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole)
const override;
65 bool setData(
const QModelIndex &index,
const QVariant &value,
int role)
override;
68 void treatEvents(
const std::vector<tlp::Event> &)
override;
70 unsigned int elementAt(
int)
const;
74 virtual bool isNode()
const = 0;
78 QVector<unsigned int> _elements;
79 QVector<QPair<unsigned int, bool>> _elementsToModify;
80 QVector<PropertyInterface *> _properties;
81 QSet<PropertyInterface *> _propertiesModified;
84 void addRemoveRowsSequence(QVector<unsigned int> &rowsSequence,
bool add);
87 class TLP_QT_SCOPE GraphSortFilterProxyModel :
public QSortFilterProxyModel,
public Observable {
88 QVector<PropertyInterface *> _properties;
89 BooleanProperty *_filterProperty;
92 GraphSortFilterProxyModel(QObject *parent =
nullptr);
95 void setSelectedOnly(
bool);
96 void setProperties(QVector<PropertyInterface *>);
98 bool lessThan(
const QModelIndex &left,
const QModelIndex &right)
const override;
99 bool filterAcceptsRow(
int sourceRow,
const QModelIndex &sourceParent)
const override;
106 class TLP_QT_SCOPE NodesGraphModel :
public GraphModel {
108 NodesGraphModel(QObject *parent =
nullptr);
109 void setGraph(Graph *)
override;
112 void treatEvents(
const std::vector<tlp::Event> &)
override;
116 QVariant headerData(
int section, Qt::Orientation orientation,
int role)
const override;
118 bool isNode()
const override {
122 static QString getNodeTooltip(Graph *graph, node n);
132 class TLP_QT_SCOPE EdgesGraphModel :
public GraphModel {
134 EdgesGraphModel(QObject *parent =
nullptr);
135 void setGraph(Graph *)
override;
137 void treatEvents(
const std::vector<tlp::Event> &)
override;
141 QVariant headerData(
int section, Qt::Orientation orientation,
int role)
const override;
143 bool isNode()
const override {
147 static QString getEdgeTooltip(Graph *graph, edge e);
A graph property that maps a Boolean value to graph elements.
Event is the base class for all events used in the Observation mechanism.
PropertyInterface describes the interface of a graph property.