22 #ifndef GRAPHPROPERTIESMODEL_H 
   23 #define GRAPHPROPERTIESMODEL_H 
   25 #include <tulip/TulipModel.h> 
   26 #include <tulip/Observable.h> 
   27 #include <tulip/Graph.h> 
   35 template<
typename PROPTYPE>
 
   36 class GraphPropertiesModel : 
public tlp::TulipModel, 
public tlp::Observable {
 
   40   QSet<PROPTYPE*> _checkedProperties;
 
   41   QVector<PROPTYPE*> _properties;
 
   48   explicit GraphPropertiesModel(
tlp::Graph* graph, 
bool checkable=
false, QObject *parent = NULL);
 
   49   explicit GraphPropertiesModel(QString placeholder, 
tlp::Graph* graph, 
bool checkable=
false, QObject *parent = NULL);
 
   50   virtual ~GraphPropertiesModel() {}
 
   63       _graph->removeListener(
this);
 
   74   QSet<PROPTYPE*> checkedProperties()
 const {
 
   75     return _checkedProperties;
 
   79   QModelIndex index(
int row, 
int column,
const QModelIndex &parent = QModelIndex()) 
const;
 
   80   QModelIndex parent(
const QModelIndex &child) 
const;
 
   81   int rowCount(
const QModelIndex &parent = QModelIndex()) 
const;
 
   82   int columnCount(
const QModelIndex &parent = QModelIndex()) 
const;
 
   83   QVariant data(
const QModelIndex &index, 
int role = Qt::DisplayRole) 
const;
 
   84   QVariant headerData(
int section, Qt::Orientation orientation, 
int role) 
const;
 
   85   bool setData(
const QModelIndex &quiindex, 
const QVariant &value, 
int role);
 
   89     if (evt.type() == Event::TLP_DELETE) {
 
   97     const GraphEvent* graphEvent = 
dynamic_cast<const GraphEvent*
>(&evt);
 
   99     if (graphEvent == NULL)
 
  102     if (graphEvent->getType() == GraphEvent::TLP_BEFORE_DEL_LOCAL_PROPERTY || graphEvent->getType() == GraphEvent::TLP_BEFORE_DEL_INHERITED_PROPERTY) {
 
  104       PROPTYPE* prop = 
dynamic_cast<PROPTYPE*
>(_graph->getProperty(graphEvent->getPropertyName()));
 
  107         int row = rowOf(prop);
 
  108         beginRemoveRows(QModelIndex(),row,row);
 
  109         _properties.remove(_properties.indexOf(prop));
 
  110         _removingRows = 
true;
 
  111         _checkedProperties.remove(prop);
 
  114     else if (graphEvent->getType() == GraphEvent::TLP_AFTER_DEL_LOCAL_PROPERTY || graphEvent->getType() == GraphEvent::TLP_AFTER_DEL_INHERITED_PROPERTY) {
 
  117         _removingRows = 
false;
 
  120     else if (graphEvent->getType() == GraphEvent::TLP_ADD_LOCAL_PROPERTY || graphEvent->getType() == GraphEvent::TLP_ADD_INHERITED_PROPERTY) {
 
  121       PROPTYPE* prop = 
dynamic_cast<PROPTYPE*
>(_graph->getProperty(graphEvent->getPropertyName()));
 
  125         int row = rowOf(prop);
 
  128           beginInsertRows(QModelIndex(),row,row);
 
  133     else if (graphEvent->getType() == GraphEvent::TLP_AFTER_RENAME_LOCAL_PROPERTY) {
 
  135       emit layoutAboutToBeChanged();
 
  136       changePersistentIndex(createIndex(0, 0),
 
  137                             createIndex(_properties.size() - 1, 0));
 
  138       emit layoutChanged();
 
  142   int rowOf(PROPTYPE*) 
const;
 
  144   Qt::ItemFlags flags(
const QModelIndex &index)
 const {
 
  145     Qt::ItemFlags result = QAbstractItemModel::flags(index);
 
  147     if (index.column() == 0 && _checkable)
 
  148       result |= Qt::ItemIsUserCheckable;
 
  156 #include "cxx/GraphPropertiesModel.cxx" 
  159 #endif // GRAPHPROPERTIESMODEL_H