52 #if QT_VERSION >= 0x050000
58 #include "TreeModelObjectSelection.hh"
61 #include "../OpenFlipper/BasePlugin/PluginFunctions.hh"
109 if (!index.isValid())
116 std::cerr <<
"Root" << std::endl;
120 if ( role == Qt::BackgroundRole ) {
122 return QVariant (QBrush (QColor (192, 192, 192)));
126 if (role == Qt::DisplayRole)
128 switch (index.column ())
131 return QVariant(item->
id());
133 return QVariant(item->
name());
152 if (!index.isValid())
155 Qt::ItemFlags
flags = 0;
158 if ( index.column() == 0 || index.column() == 1 )
159 flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
161 flags = Qt::ItemIsEnabled;
179 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
182 return QVariant(
"ID");
183 else if (section == 1)
184 return QVariant(
"Name");
206 if (!_parent.isValid())
213 return createIndex(row, column, childItem);
215 return QModelIndex();
228 if (!index.isValid())
229 return QModelIndex();
235 return QModelIndex();
237 return createIndex(parentItem->
row(), 0, parentItem);
251 if (_parent.column() > 0)
254 if (!_parent.isValid())
279 if (obj != 0 && item != 0){
286 if ( index.isValid() )
287 emit dataChanged( index, index);
298 if ( index0.isValid() && index1.isValid() ){
300 emit dataChanged( index0, index1);
377 if ( item != 0 && !
isRoot(item) ){
380 QModelIndex parentIndex = itemIndex.parent();
382 beginRemoveRows( parentIndex, itemIndex.row(), itemIndex.row() );
403 QModelIndex oldParentIndex = itemIndex.parent();
407 beginRemoveRows( oldParentIndex, itemIndex.row(), itemIndex.row() );
419 emit layoutChanged();
431 if (index.isValid()) {
433 if (item)
return item;
448 if (index.isValid()) {
465 if (index.isValid()) {
487 return QModelIndex();
489 QModelIndex
index = createIndex(_object->
row(), _column, _object);
511 return QModelIndex();
525 if (
isRoot(_item) || (!_item->isGroup()) )
535 emit dataChanged( index0, index1);
540 emit dataChanged(index, index);
559 bool changed =
false;
578 emit dataChanged(index, index);
581 if ( current->isGroup() )
591 emit dataChangedInside(
itemId(index), index.column(), value );
void propagateUpwards(TreeItemObjectSelection *_obj, int _column, bool _value)
Recursively update a column up to the root of the tree.
void removeChild(TreeItemObjectSelection *_item)
Remove a child from this object.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
bool isRoot(TreeItemObjectSelection *_item)
Check if the given item is the root item.
QModelIndex getModelIndex(TreeItemObjectSelection *_object, int _column)
Return the ModelIndex corresponding to a given TreeItemObjectSelection and Column.
int rowCount(const QModelIndex &parent=QModelIndex()) const
get the number of rows
const DataType DATA_UNKNOWN(0)
None of the other Objects.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
return the header data of the model
bool dataType(DataType _type) const
virtual bool visible()
return if object is visible
void objectChanged(int id_)
The object with the given id has been changed. Check if model also has to be changed.
int itemId(const QModelIndex &index) const
Get the id of a TreeItemObjectSelection corresponding to a given ModelIndex.
QString itemName(const QModelIndex &index) const
Get the name of a TreeItemObjectSelection corresponding to a given ModelIndex.
void objectDeleted(int id_)
The object with the given id has been deleted. delete it from the internal tree.
int columnCount(const QModelIndex &_parent=QModelIndex()) const
Return the number of columns.
bool getObject(int _identifier, BSplineCurveObject *&_object)
QModelIndex parent(const QModelIndex &index) const
Get the parent ModelIndex.
TreeItemObjectSelection * childExists(int _objectId)
Check if the element exists in the subtree of this element.
int row() const
get the row of this item from the parent
void deleteSubtree()
delete the whole subtree below this item ( The item itself is not touched )
~TreeModelObjectSelection()
Destructor.
BaseObject * parent()
Get the parent item ( 0 if rootitem )
TreeItemObjectSelection * getItem(const QModelIndex &index) const
Get the TreeItemObjectSelection corresponding to a given ModelIndex.
Qt::ItemFlags flags(const QModelIndex &index) const
return the types of the corresponding entry
void setParent(TreeItemObjectSelection *_parent)
Set the parent pointer.
int childCount() const
get the number of children
TreeItemObjectSelection * rootItem_
Rootitem of the tree.
TreeItemObjectSelection * child(int row)
return a child
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Get the ModelIndex at given row,column.
void moveItem(TreeItemObjectSelection *_item, TreeItemObjectSelection *_parent)
move the item to a new parent
TreeItemObjectSelection * parent()
Get the parent item ( 0 if rootitem )
TreeModelObjectSelection(QObject *_parent=0)
Constructor.
QVariant data(const QModelIndex &index, int role) const
Get the data of the corresponding entry.
void propagateDownwards(TreeItemObjectSelection *_obj, int _column)
Recursively update a column up to the root of the tree.
BaseObject *& objectRoot()
Get the root of the object structure.
void objectAdded(BaseObject *_object)
The object with the given id has been added. add it to the internal tree.
bool isGroup() const
Check if object is a group.
void appendChild(TreeItemObjectSelection *child)
add a child to this node
bool setData(const QModelIndex &index, const QVariant &value, int role)
Set Data at 'index' to 'value'.