Tulip  4.6.0
Better Visualization Through Research
library/tulip-gui/include/tulip/GraphElementModel.h
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 ///@cond DOXYGEN_HIDDEN
00020 
00021 #ifndef GRAPHELEMENTMODEL_H
00022 #define GRAPHELEMENTMODEL_H
00023 
00024 #include <tulip/TulipModel.h>
00025 #include <tulip/GraphModel.h>
00026 
00027 namespace tlp {
00028 
00029 class TLP_QT_SCOPE GraphElementModel: public TulipModel {
00030 
00031 public:
00032 
00033   GraphElementModel(Graph *graph, unsigned int id, QObject *parent=NULL);
00034 
00035   int rowCount(const QModelIndex &parent = QModelIndex()) const;
00036   int columnCount(const QModelIndex &parent = QModelIndex()) const;
00037   QModelIndex parent(const QModelIndex &child) const;
00038 
00039   QVariant headerData(int section, Qt::Orientation orientation, int role) const;
00040   QModelIndex index(int row, int column,const QModelIndex &parent = QModelIndex()) const;
00041   QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00042 
00043   virtual QString headerText(unsigned int id) const = 0;
00044   virtual QVariant value(unsigned int id,PropertyInterface *prop) const = 0;
00045 
00046   Qt::ItemFlags flags(const QModelIndex &index) const;
00047 
00048 protected :
00049 
00050   Graph *_graph;
00051   unsigned int _id;
00052 
00053 };
00054 
00055 class TLP_QT_SCOPE GraphNodeElementModel : public GraphElementModel {
00056 public :
00057 
00058   GraphNodeElementModel(Graph *graph, unsigned int id, QObject *parent=NULL):GraphElementModel(graph,id,parent) {}
00059 
00060   QString headerText(unsigned int id) const {
00061     return QString("node: ") + QString::number(id);
00062   }
00063 
00064   QVariant value(unsigned int id, PropertyInterface *prop) const {
00065     return GraphModel::nodeValue(id,prop);
00066   }
00067 
00068   bool setData(const QModelIndex &index, const QVariant &value, int role);
00069 
00070 };
00071 
00072 class TLP_QT_SCOPE GraphEdgeElementModel : public GraphElementModel {
00073 public :
00074 
00075   GraphEdgeElementModel(Graph *graph, unsigned int id, QObject *parent=NULL):GraphElementModel(graph,id,parent) {}
00076 
00077   QString headerText(unsigned int id) const {
00078     return QString("edge: ") + QString::number(id);
00079   }
00080 
00081   QVariant value(unsigned int id, PropertyInterface *prop) const {
00082     return GraphModel::edgeValue(id,prop);
00083   }
00084 
00085   bool setData(const QModelIndex &index, const QVariant &value, int role);
00086 
00087 };
00088 
00089 }
00090 
00091 #endif // GRAPHELEMENTMODEL_H
00092 ///@endcond
 All Classes Files Functions Variables Enumerations Enumerator Properties