1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #ifndef YACSGui_TreeViewItem_HeaderFile
22 #define YACSGui_TreeViewItem_HeaderFile
24 #include <qlistview.h>
27 #include <ElementaryNode.hxx>
28 #include <ServiceNode.hxx>
30 #include <TypeCode.hxx>
31 #include <SalomeContainer.hxx>
32 #include <ComponentInstance.hxx>
33 #include <guiObservers.hxx>
35 /* ================ items for tree view in edition mode ================ */
37 class YACSGui_Executor;
42 class YACSGui_ViewItem : public QListViewItem, public YACS::HMI::GuiObserver
45 YACSGui_ViewItem( QListView* theParent,
46 QListViewItem* theAfter );
47 YACSGui_ViewItem( QListViewItem* theParent,
48 QListViewItem* theAfter );
50 virtual void select(bool isSelected);
51 //virtual void update(YACS::HMI::GuiEvent event, int type, YACS::HMI::Subject* son);
53 // axiluary methods for blocking reaction inside select() method
54 bool blockSelection( const bool toBlock );
55 bool selectionBlocked() const;
57 virtual void update( const bool theIsRecursive = false ) {}
60 void removeNodeItem( YACS::HMI::Subject* theSNode );
61 void removeLinkItem( YACS::HMI::Subject* theSLink );
68 * YACS label tree view item
70 class YACSGui_LabelViewItem : public YACSGui_ViewItem
73 YACSGui_LabelViewItem( QListView* theParent,
74 QListViewItem* theAfter,
75 const QString theName );
76 YACSGui_LabelViewItem( QListViewItem* theParent,
77 QListViewItem* theAfter,
78 const QString theName );
80 virtual void select( bool isSelected );
85 virtual void update( const bool theIsRecursive = false );
92 * YACS reference tree view item
94 class YACSGui_ReferenceViewItem : public YACSGui_ViewItem
97 typedef enum { Text, HighlightedText, Highlight } ColorRole;
99 YACSGui_ReferenceViewItem( QListView* theParent,
100 QListViewItem* theAfter,
101 YACS::HMI::SubjectReference* theSReference );
102 YACSGui_ReferenceViewItem( QListViewItem* theParent,
103 QListViewItem* theAfter,
104 YACS::HMI::SubjectReference* theSReference );
105 virtual ~YACSGui_ReferenceViewItem();
107 virtual void select(bool isSelected);
108 virtual void update(YACS::HMI::GuiEvent event, int type, YACS::HMI::Subject* son);
110 QString name() const;
111 QPixmap icon() const;
112 QColor color( const ColorRole = Text ) const;
114 YACS::ENGINE::Node* getNode() const;
115 YACS::HMI::SubjectReference* getSReference() const { return mySReference; }
117 virtual void paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align );
119 virtual void update( const bool theIsRecursive = false );
122 YACS::HMI::SubjectReference* mySReference;
126 * YACS tree view item for port
128 class YACSGui_PortViewItem : public YACSGui_ViewItem
131 YACSGui_PortViewItem( QListView* theParent,
132 QListViewItem* theAfter,
133 YACS::HMI::SubjectDataPort* theSPort );
134 YACSGui_PortViewItem( QListViewItem* theParent,
135 QListViewItem* theAfter,
136 YACS::HMI::SubjectDataPort* theSPort );
137 virtual ~YACSGui_PortViewItem();
139 QString name() const;
140 QPixmap icon() const;
142 YACS::ENGINE::DataPort* getPort() const;
143 YACS::HMI::SubjectDataPort* getSPort() const { return mySPort; }
145 virtual void update( const bool theIsRecursive = false );
148 YACS::HMI::SubjectDataPort* mySPort;
152 * YACS tree view item for node
154 class YACSGui_NodeViewItem : public YACSGui_ViewItem
157 typedef enum { Text, HighlightedText, Highlight } ColorRole;
159 YACSGui_NodeViewItem( QListView* theParent,
160 QListViewItem* theAfter,
161 YACS::HMI::SubjectNode* theSNode );
162 YACSGui_NodeViewItem( QListViewItem* theParent,
163 QListViewItem* theAfter,
164 YACS::HMI::SubjectNode* theSNode );
165 virtual ~YACSGui_NodeViewItem();
167 virtual void update(YACS::HMI::GuiEvent event, int type, YACS::HMI::Subject* son);
169 QString name() const;
170 QPixmap icon() const;
172 static QPixmap icon( YACS::ENGINE::Node* );
174 YACS::ENGINE::Node* getNode() const;
175 YACS::HMI::SubjectNode* getSNode() const { return mySNode; }
177 virtual void update( const bool theIsRecursive = false );
180 void renamePortItem( YACS::HMI::Subject* theSPort );
181 void addPortItem( YACS::HMI::Subject* theSPort );
182 void removePortItem( YACS::HMI::Subject* theSPort );
183 void addNodeItem( YACS::HMI::Subject* theSNode );
184 void moveUpPortItem( YACS::HMI::Subject* theSPort );
185 void moveDownPortItem( YACS::HMI::Subject* theSPort );
186 bool isPublished( YACS::ENGINE::Port* thePort );
188 void addReferenceItem( YACS::HMI::Subject* theSRef );
189 void removeReferenceItem( YACS::HMI::Subject* theSRef );
191 void addLinkItem( YACS::HMI::Subject* theSLink );
193 YACS::HMI::SubjectNode* mySNode;
197 * YACS tree view item for data link
199 class YACSGui_LinkViewItem : public YACSGui_ViewItem
202 YACSGui_LinkViewItem( QListView* theParent,
203 QListViewItem* theAfter,
204 YACS::HMI::SubjectLink* theSLink );
205 YACSGui_LinkViewItem( QListViewItem* theParent,
206 QListViewItem* theAfter,
207 YACS::HMI::SubjectLink* theSLink );
208 virtual ~YACSGui_LinkViewItem();
210 QString name() const;
211 QPixmap icon() const;
213 YACS::HMI::SubjectLink* getSLink() const { return mySLink; }
215 virtual void update( const bool theIsRecursive = false );
218 YACS::HMI::SubjectLink* mySLink;
222 * YACS tree view item for control link
224 class YACSGui_ControlLinkViewItem : public YACSGui_ViewItem
227 YACSGui_ControlLinkViewItem( QListView* theParent,
228 QListViewItem* theAfter,
229 YACS::HMI::SubjectControlLink* theSLink );
230 YACSGui_ControlLinkViewItem( QListViewItem* theParent,
231 QListViewItem* theAfter,
232 YACS::HMI::SubjectControlLink* theSLink );
233 virtual ~YACSGui_ControlLinkViewItem();
235 QString name() const;
236 QPixmap icon() const;
238 YACS::HMI::SubjectControlLink* getSLink() const { return mySLink; }
240 virtual void update( const bool theIsRecursive = false );
243 YACS::HMI::SubjectControlLink* mySLink;
247 * YACS tree view item for schema
249 class YACSGui_SchemaViewItem : public YACSGui_ViewItem
252 YACSGui_SchemaViewItem( QListView* theParent,
253 QListViewItem* theAfter,
254 YACS::HMI::SubjectProc* theSProc );
255 YACSGui_SchemaViewItem( QListViewItem* theParent,
256 QListViewItem* theAfter,
257 YACS::HMI::SubjectProc* theSProc );
258 virtual ~YACSGui_SchemaViewItem();
260 virtual void update(YACS::HMI::GuiEvent event, int type, YACS::HMI::Subject* son);
262 QPixmap icon() const;
264 YACS::ENGINE::Proc* getProc() const;
265 YACS::HMI::SubjectProc* getSProc() const { return mySProc; }
267 virtual void update( const bool theIsRecursive = false,
268 YACS::HMI::Subject* theSon = 0,
269 YACSGui_NodeViewItem* theBlocItem = 0 );
271 YACSGui_LabelViewItem* buildDataTypesTree();
274 void addNodeItem( YACS::HMI::Subject* theSNode );
275 void addContainerItem( YACS::HMI::Subject* theSContainer );
276 void removeContainerItem( YACS::HMI::Subject* theSContainer );
277 void removeComponentItem( YACS::HMI::Subject* theSComponent );
278 void addDataTypeItem( YACS::HMI::Subject* theSDataType );
279 void removeDataTypeItem( YACS::HMI::Subject* theSDataType );
281 void addLinkItem( YACS::HMI::Subject* theSLink );
283 YACS::HMI::SubjectProc* mySProc;
285 std::map< YACS::ENGINE::DynType, QListViewItem* > myRootDataTypeItems;
289 class YACSGui_ComponentViewItem;
291 * YACS tree view item for container
293 class YACSGui_ContainerViewItem : public YACSGui_ViewItem
296 YACSGui_ContainerViewItem( QListView* theParent,
297 QListViewItem* theAfter,
298 YACS::HMI::SubjectContainer* theSContainer = 0 );
299 YACSGui_ContainerViewItem( QListViewItem* theParent,
300 QListViewItem* theAfter,
301 YACS::HMI::SubjectContainer* theSContainer = 0 );
302 virtual ~YACSGui_ContainerViewItem();
304 virtual void update(YACS::HMI::GuiEvent event, int type, YACS::HMI::Subject* son);
306 QString name() const;
307 QPixmap icon() const;
309 YACS::ENGINE::Container* getContainer() const;
310 YACS::HMI::SubjectContainer* getSContainer() const { return mySContainer; }
312 virtual void update( YACSGui_ComponentViewItem* theComponent = 0 );
314 void addComponentItem( YACS::HMI::Subject* theSComponent );
317 void removeComponentItem( YACS::HMI::Subject* theSComponent );
319 YACS::HMI::SubjectContainer* mySContainer;
323 * YACS tree view item for component
325 class YACSGui_ComponentViewItem : public YACSGui_ViewItem
328 YACSGui_ComponentViewItem( QListView* theParent,
329 QListViewItem* theAfter,
330 YACS::HMI::SubjectComponent* theSComponent = 0 );
331 YACSGui_ComponentViewItem( QListViewItem* theParent,
332 QListViewItem* theAfter,
333 YACS::HMI::SubjectComponent* theSComponent = 0 );
335 virtual ~YACSGui_ComponentViewItem();
337 virtual void update(YACS::HMI::GuiEvent event, int type, YACS::HMI::Subject* son);
339 QString name() const;
340 QString instanceName() const;
341 QPixmap icon() const;
343 YACS::ENGINE::ComponentInstance* getComponent() const;
344 YACS::HMI::SubjectComponent* getSComponent() const { return mySComponent; }
346 virtual void update( const bool theMove = false );
347 virtual void move( YACS::HMI::Subject* theSReference );
350 YACS::HMI::SubjectComponent* mySComponent;
354 * YACS tree view item for data type
356 class YACSGui_DataTypeItem : public YACSGui_ViewItem
359 //typedef enum { Text, HighlightedText, Highlight } ColorRole;
361 YACSGui_DataTypeItem( QListView* theParent,
362 QListViewItem* theAfter,
363 YACS::HMI::SubjectDataType* theSDataType );
364 YACSGui_DataTypeItem( QListViewItem* theParent,
365 QListViewItem* theAfter,
366 YACS::HMI::SubjectDataType* theSDataType );
367 virtual ~YACSGui_DataTypeItem();
369 virtual void update(YACS::HMI::GuiEvent event, int type, YACS::HMI::Subject* son);
371 QString name() const;
372 static QPixmap icon();
374 YACS::HMI::SubjectDataType* getSDataType() const { return mySDataType; }
376 virtual void update( const bool theIsRecursive = false );
379 YACS::HMI::SubjectDataType* mySDataType;
382 /* ================ items for tree view in run mode ================ */
385 class YACSGui_ComposedNodeViewItem: public YACSGui_ViewItem
388 YACSGui_ComposedNodeViewItem(QListView *parent,
390 YACS::ENGINE::ComposedNode *node = 0);
391 YACSGui_ComposedNodeViewItem(QListViewItem *parent,
393 YACS::ENGINE::ComposedNode *node = 0);
394 virtual ~YACSGui_ComposedNodeViewItem();
396 void setState(int state);
397 void setStatus(int status);
398 virtual void paintCell( QPainter *p, const QColorGroup &cg,
399 int column, int width, int alignment );
400 QColor statusBgColor() const;
401 YACS::ENGINE::ComposedNode* getNode() {return _node;};
403 QPixmap icon() const;
405 void update( const bool theIsRecursive = false );
407 YACS::HMI::Subject* getSubject() const;
408 void popup(YACSGui_Executor* anExecutor,const QPoint & point);
413 YACS::ENGINE::ComposedNode *_node;
416 class YACSGui_ElementaryNodeViewItem: public QCheckListItem,
417 public YACS::HMI::GuiObserver
420 YACSGui_ElementaryNodeViewItem(QListView *parent,
422 Type tt = RadioButtonController,
423 YACS::ENGINE::ElementaryNode *node = 0);
424 YACSGui_ElementaryNodeViewItem(QListViewItem *parent,
426 Type tt = RadioButtonController,
427 YACS::ENGINE::ElementaryNode *node = 0);
428 virtual ~YACSGui_ElementaryNodeViewItem();
430 void setState(int state);
431 virtual void paintCell( QPainter *p, const QColorGroup &cg,
432 int column, int width, int alignment );
433 YACS::ENGINE::ElementaryNode* getNode() {return _node;};
435 virtual void select(bool isSelected);
437 void update( const bool theIsRecursive = false );
439 // axiluary methods for blocking reaction inside select() method
440 bool blockSelection( const bool toBlock );
441 bool selectionBlocked() const;
443 YACS::HMI::Subject* getSubject() const;
444 void popup(YACSGui_Executor* anExecutor,const QPoint & point);
449 YACS::ENGINE::ElementaryNode *_node;