Tulip  5.1.0
Large graphs analysis and drawing
GraphElementModel.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef GRAPHELEMENTMODEL_H
22 #define GRAPHELEMENTMODEL_H
23 
24 #include <tulip/TulipModel.h>
25 #include <tulip/GraphModel.h>
26 
27 namespace tlp {
28 
29 class TLP_QT_SCOPE GraphElementModel: public TulipModel {
30 
31 public:
32 
33  GraphElementModel(Graph *graph, unsigned int id, QObject *parent=NULL, bool displayvisual=true);
34 
35  void setShowVisualProp(bool show);
36 
37  int rowCount(const QModelIndex &parent = QModelIndex()) const;
38  int columnCount(const QModelIndex &parent = QModelIndex()) const;
39  QModelIndex parent(const QModelIndex &child) const;
40 
41  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
42  QModelIndex index(int row, int column,const QModelIndex &parent = QModelIndex()) const;
43  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
44 
45  virtual QString headerText(unsigned int id) const = 0;
46  virtual QVariant value(unsigned int id,PropertyInterface *prop) const = 0;
47 
48  Qt::ItemFlags flags(const QModelIndex &index) const;
49 
50 protected :
51 
52  Graph *_graph;
53  unsigned int _id;
54  bool _displayvisualprop;
55 
56 
57 };
58 
59 class TLP_QT_SCOPE GraphNodeElementModel : public GraphElementModel {
60 
61 public :
62 
63  GraphNodeElementModel(Graph *graph, unsigned int id, QObject *parent=NULL,bool displayvisual=true):GraphElementModel(graph,id,parent,displayvisual) {}
64 
65  QString headerText(unsigned int id) const {
66  return QString("node: ") + QString::number(id);
67  }
68 
69  QVariant value(unsigned int id, PropertyInterface *prop) const {
70  return GraphModel::nodeValue(id,prop);
71  }
72 
73  bool setData(const QModelIndex &index, const QVariant &value, int role);
74 
75 };
76 
77 class TLP_QT_SCOPE GraphEdgeElementModel : public GraphElementModel {
78 
79 public :
80 
81  GraphEdgeElementModel(Graph *graph, unsigned int id, QObject *parent=NULL,bool displayvisual=true):GraphElementModel(graph,id,parent,displayvisual) {}
82 
83  QString headerText(unsigned int id) const {
84  return QString("edge: ") + QString::number(id);
85  }
86 
87  QVariant value(unsigned int id, PropertyInterface *prop) const {
88  return GraphModel::edgeValue(id,prop);
89  }
90 
91  bool setData(const QModelIndex &index, const QVariant &value, int role);
92 
93 };
94 
95 }
96 
97 #endif // GRAPHELEMENTMODEL_H
98 ///@endcond