1 // Copyright (C) 2006-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef _SCHEMAMODEL_HXX_
21 #define _SCHEMAMODEL_HXX_
23 #include <QAbstractItemModel>
24 #include <QItemSelection>
26 #include "guiObservers.hxx"
43 class SchemaComposedNodeItem;
44 class SchemaDirTypesItem;
45 class SchemaDirLinksItem;
46 class SchemaDirContainersItem;
47 class SchemaContainerItem;
49 class SchemaModel: public QAbstractItemModel, public GuiObserver
53 friend class SchemaItem;
54 friend class SchemaNodeItem;
55 friend class SchemaComposedNodeItem;
56 friend class SchemaDirTypesItem;
57 friend class SchemaDirLinksItem;
58 friend class SchemaDirContainersItem;
59 friend class SchemaContainerItem;
60 friend class SchemaComponentItem;
63 SchemaModel(YACS::HMI::Subject *context,
64 QObject * parent = 0);
65 virtual ~SchemaModel();
67 virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
68 virtual QModelIndex parent(const QModelIndex &index) const;
69 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
70 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
71 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
72 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
74 virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
75 virtual Qt::ItemFlags flags(const QModelIndex &index) const;
77 virtual void update(GuiEvent event, int type, Subject* son);
78 inline SchemaItem * getRootItem() {return _rootItem; };
79 inline bool isEdition() {return _isEdition; };
80 void setEdition(bool isEdition = true);
82 const QBrush& stdBackBrush();
83 const QBrush& editedBackBrush();
84 const QBrush& emphasizeBackBrush();
86 virtual QMimeData* mimeData(const QModelIndexList &indexes) const;
87 virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action,
88 int row, int column, const QModelIndex& parent);
89 virtual Qt::DropActions supportedDropActions() const;
90 virtual QStringList mimeTypes() const;
93 void updateSelection(const QItemSelection &selected, const QItemSelection &deselected);
96 void signalSelection(const QModelIndex &index);
99 void setNewRoot(YACS::HMI::Subject *root);
103 SchemaItem *_rootItem;
105 QBrush _stdBackBrush;
106 QBrush _editedBackBrush;
107 QBrush _emphasizeBackBrush;