/usr/include/tulip/GraphPropertiesModel.h is in libtulip-dev 4.4.0dfsg2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | /*
*
* This file is part of Tulip (www.tulip-software.org)
*
* Authors: David Auber and the Tulip development Team
* from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
*
* Tulip is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Tulip is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
*/
///@cond DOXYGEN_HIDDEN
#ifndef GRAPHPROPERTIESMODEL_H
#define GRAPHPROPERTIESMODEL_H
#include <tulip/TulipModel.h>
#include <tulip/Observable.h>
#include <tulip/Graph.h>
#include <QFont>
#include <QIcon>
#include <QSet>
namespace tlp {
template<typename PROPTYPE>
class GraphPropertiesModel : public tlp::TulipModel, public tlp::Observable {
tlp::Graph* _graph;
QString _placeholder;
bool _checkable;
QSet<PROPTYPE*> _checkedProperties;
QVector<PROPTYPE*> _properties;
bool _removingRows;
bool forcingRedraw;
void rebuildCache();
public:
explicit GraphPropertiesModel(tlp::Graph* graph, bool checkable=false, QObject *parent = NULL);
explicit GraphPropertiesModel(QString placeholder, tlp::Graph* graph, bool checkable=false, QObject *parent = NULL);
virtual ~GraphPropertiesModel() {}
tlp::Graph* graph() const {
return _graph;
}
void setGraph(tlp::Graph* graph) {
if (_graph == graph)
return;
beginResetModel();
if (_graph != NULL)
_graph->removeListener(this);
_graph = graph;
if (_graph != NULL)
_graph->addListener(this);
rebuildCache();
endResetModel();
}
QSet<PROPTYPE*> checkedProperties() const {
return _checkedProperties;
}
// Methods re-implemented from QAbstractItemModel
QModelIndex index(int row, int column,const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &child) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
bool setData(const QModelIndex &quiindex, const QVariant &value, int role);
// Methods inherited from the observable system
void treatEvent(const tlp::Event& evt) {
if (evt.type() == Event::TLP_DELETE) {
beginResetModel();
_graph = NULL;
_properties.clear();
endResetModel();
return;
}
const GraphEvent* graphEvent = dynamic_cast<const GraphEvent*>(&evt);
if (graphEvent == NULL)
return;
if (graphEvent->getType() == GraphEvent::TLP_BEFORE_DEL_LOCAL_PROPERTY || graphEvent->getType() == GraphEvent::TLP_BEFORE_DEL_INHERITED_PROPERTY) {
PROPTYPE* prop = dynamic_cast<PROPTYPE*>(_graph->getProperty(graphEvent->getPropertyName()));
if (prop != NULL) {
int row = rowOf(prop);
beginRemoveRows(QModelIndex(),row,row);
_properties.remove(_properties.indexOf(prop));
_removingRows = true;
_checkedProperties.remove(prop);
}
}
else if (graphEvent->getType() == GraphEvent::TLP_AFTER_DEL_LOCAL_PROPERTY || graphEvent->getType() == GraphEvent::TLP_AFTER_DEL_INHERITED_PROPERTY) {
if (_removingRows) {
endRemoveRows();
_removingRows = false;
}
}
else if (graphEvent->getType() == GraphEvent::TLP_ADD_LOCAL_PROPERTY || graphEvent->getType() == GraphEvent::TLP_ADD_INHERITED_PROPERTY) {
PROPTYPE* prop = dynamic_cast<PROPTYPE*>(_graph->getProperty(graphEvent->getPropertyName()));
if (prop != NULL) {
rebuildCache();
int row = rowOf(prop);
if (row >= 0) {
beginInsertRows(QModelIndex(),row,row);
endInsertRows();
}
}
}
else if (graphEvent->getType() == GraphEvent::TLP_AFTER_RENAME_LOCAL_PROPERTY) {
// force any needed sorting
emit layoutAboutToBeChanged();
changePersistentIndex(createIndex(0, 0),
createIndex(_properties.size() - 1, 0));
emit layoutChanged();
}
}
int rowOf(PROPTYPE*) const;
Qt::ItemFlags flags(const QModelIndex &index) const {
Qt::ItemFlags result = QAbstractItemModel::flags(index);
if (index.column() == 0 && _checkable)
result |= Qt::ItemIsUserCheckable;
return result;
}
};
}
#include "cxx/GraphPropertiesModel.cxx"
#endif // GRAPHPROPERTIESMODEL_H
///@endcond
|