Tulip  4.8.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
GraphElementModel.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
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);
34 
35  int rowCount(const QModelIndex &parent = QModelIndex()) const;
36  int columnCount(const QModelIndex &parent = QModelIndex()) const;
37  QModelIndex parent(const QModelIndex &child) const;
38 
39  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
40  QModelIndex index(int row, int column,const QModelIndex &parent = QModelIndex()) const;
41  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
42 
43  virtual QString headerText(unsigned int id) const = 0;
44  virtual QVariant value(unsigned int id,PropertyInterface *prop) const = 0;
45 
46  Qt::ItemFlags flags(const QModelIndex &index) const;
47 
48 protected :
49 
50  Graph *_graph;
51  unsigned int _id;
52 
53 };
54 
55 class TLP_QT_SCOPE GraphNodeElementModel : public GraphElementModel {
56 public :
57 
58  GraphNodeElementModel(Graph *graph, unsigned int id, QObject *parent=NULL):GraphElementModel(graph,id,parent) {}
59 
60  QString headerText(unsigned int id) const {
61  return QString("node: ") + QString::number(id);
62  }
63 
64  QVariant value(unsigned int id, PropertyInterface *prop) const {
65  return GraphModel::nodeValue(id,prop);
66  }
67 
68  bool setData(const QModelIndex &index, const QVariant &value, int role);
69 
70 };
71 
72 class TLP_QT_SCOPE GraphEdgeElementModel : public GraphElementModel {
73 public :
74 
75  GraphEdgeElementModel(Graph *graph, unsigned int id, QObject *parent=NULL):GraphElementModel(graph,id,parent) {}
76 
77  QString headerText(unsigned int id) const {
78  return QString("edge: ") + QString::number(id);
79  }
80 
81  QVariant value(unsigned int id, PropertyInterface *prop) const {
82  return GraphModel::edgeValue(id,prop);
83  }
84 
85  bool setData(const QModelIndex &index, const QVariant &value, int role);
86 
87 };
88 
89 }
90 
91 #endif // GRAPHELEMENTMODEL_H
92 ///@endcond