Salome HOME
Update copyrights 2014.
[modules/yacs.git] / src / genericgui / SchemaItem.hxx
1 // Copyright (C) 2006-2014  CEA/DEN, EDF R&D
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 _SCHEMAITEM_HXX_
21 #define _SCHEMAITEM_HXX_
22
23 #include "SchemaModel.hxx"
24
25 namespace YACS
26 {
27   namespace ENGINE
28   {
29     class Node;
30   }
31
32   namespace HMI
33   {
34     class ItemMimeData;
35
36     class SchemaItem: public QObject, public GuiObserver
37     {
38       Q_OBJECT
39
40     public:
41       SchemaItem(SchemaItem *parent, QString label, Subject* subject);
42       virtual ~SchemaItem();
43       
44       virtual void appendChild(SchemaItem *child);
45       virtual void removeChild(SchemaItem *child);
46       virtual void insertChild(int row, SchemaItem *child);
47       
48       virtual SchemaItem *child(int row);
49       virtual int childCount() const;
50       virtual int columnCount() const;
51       virtual QVariant data(int column, int role) const;
52       virtual Qt::ItemFlags flags(const QModelIndex &index);
53       virtual int row() const;
54       virtual SchemaItem *parent();
55       virtual Subject* getSubject();
56       virtual void update(GuiEvent event, int type, Subject* son);
57       virtual void select(bool isSelected);
58       virtual void toggleState();
59       QModelIndex modelIndex(int column = 0);
60       virtual void popupMenu(QWidget *caller, const QPoint &globalPos);
61       virtual ItemMimeData* mimeData(ItemMimeData *mime);
62       virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action);
63       virtual void reparent(SchemaItem *parent);
64       virtual void setCaseValue();
65
66       bool isEmphasized() {return _emphasized; };
67       void setEmphasize(bool emphasize) {_emphasized = emphasize; };
68
69     protected:
70       virtual QVariant editionToolTip(int column) const;
71       virtual QVariant runToolTip(int column) const;
72       virtual QVariant editionWhatsThis(int column) const;
73       virtual QVariant runWhatsThis(int column) const;
74       virtual QString getMimeFormat();
75       virtual void setExecState(int execState);
76       QList<SchemaItem*> _childItems;
77       QList<QVariant> _itemData;
78       QList<QVariant> _itemDeco;
79       QList<QVariant> _itemForeground;
80       QList<QVariant> _itemBackground;
81       QList<QVariant> _itemCheckState;
82       QList<QVariant> _itemToolTip;
83       QList<QVariant> _itemWhatsThis;
84       QString _label;
85       SchemaItem *_parentItem;
86       Subject* _subject;
87       int _execState;
88       bool _emphasized;
89     };
90
91
92 //     class SchemaSelectionModel: public QItemSelectionModel
93 //     {
94 //     public:
95 //       SchemaSelectionModel(QAbstractItemModel *model);
96 //       SchemaSelectionModel(QAbstractItemModel *model, QObject *parent);
97 //       virtual ~SchemaSelectionModel();
98 //     };
99
100   }
101 }
102
103 #endif