Version: 9.16.0
SchemaModel.hxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
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, or (at your option) any later version.
7//
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.
12//
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
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef _SCHEMAMODEL_HXX_
21#define _SCHEMAMODEL_HXX_
22
23#include <QAbstractItemModel>
24#include <QItemSelection>
25#include <QBrush>
26#include "guiObservers.hxx"
27#include <list>
28
29namespace YACS
30{
31 namespace HMI
32 {
33 typedef enum
34 {
35 YLabel = 0,
36 YType = 1,
37 YValue = 2,
38 YState = 2,
39 } columnId;
40
41 class SchemaItem;
42 class SchemaNodeItem;
43 class SchemaComposedNodeItem;
44 class SchemaDirTypesItem;
45 class SchemaDirLinksItem;
46 class SchemaDirContainersItem;
47 class SchemaContainerItem;
48
50 {
51 Q_OBJECT
52
53 friend class SchemaItem;
54 friend class SchemaNodeItem;
56 friend class SchemaDirTypesItem;
57 friend class SchemaDirLinksItem;
59 friend class SchemaContainerItem;
60 friend class SchemaComponentItem;
61
62 public:
64 QObject * parent = 0);
65 virtual ~SchemaModel();
66
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;
73
74 virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
75 virtual Qt::ItemFlags flags(const QModelIndex &index) const;
76
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);
81
82 const QBrush& stdBackBrush();
83 const QBrush& editedBackBrush();
84 const QBrush& emphasizeBackBrush();
85
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;
91
92 public slots:
93 void updateSelection(const QItemSelection &selected, const QItemSelection &deselected);
94
95 signals:
96 void signalSelection(const QModelIndex &index);
97
98 protected:
100
104
109 };
110
111 }
112}
113
114#endif
SchemaModel(YACS::HMI::Subject *context, QObject *parent=0)
Definition: SchemaModel.cxx:39
void setEdition(bool isEdition=true)
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
virtual Qt::DropActions supportedDropActions() const
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
const QBrush & emphasizeBackBrush()
virtual QMimeData * mimeData(const QModelIndexList &indexes) const
SchemaItem * getRootItem()
Definition: SchemaModel.hxx:78
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Definition: SchemaModel.cxx:60
virtual QModelIndex parent(const QModelIndex &index) const
Definition: SchemaModel.cxx:80
void signalSelection(const QModelIndex &index)
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
const QBrush & editedBackBrush()
virtual Qt::ItemFlags flags(const QModelIndex &index) const
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
void setNewRoot(YACS::HMI::Subject *root)
virtual void update(GuiEvent event, int type, Subject *son)
const QBrush & stdBackBrush()
void updateSelection(const QItemSelection &selected, const QItemSelection &deselected)
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: SchemaModel.cxx:92
virtual QStringList mimeTypes() const