Version: 9.16.0
SchemaComponentItem.cxx
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
21#include "QtGuiContext.hxx"
22#include "SchemaModel.hxx"
24#include "guiObservers.hxx"
25#include "Menus.hxx"
26
27#include <QIcon>
28#include <cassert>
29
30//#define _DEVDEBUG_
31#include "YacsTrace.hxx"
32
33using namespace std;
34using namespace YACS::HMI;
35
36
37SchemaComponentItem::SchemaComponentItem(SchemaItem *parent, QString label, Subject* subject)
38 : SchemaItem(parent, label, subject)
39{
40 _itemDeco.replace(YLabel, QIcon("icons:component.png"));
41}
42
43void SchemaComponentItem::update(GuiEvent event, int type, Subject* son)
44{
45 DEBTRACE("SchemaComponentItem::update");
46 //SchemaItem::update(event, type, son);
47 SchemaModel *model = 0;
48 SchemaReferenceItem *item =0;
49 switch (event)
50 {
52 {
53 DEBTRACE("ADDCHILDREF ");
55 SubjectReference *ref = dynamic_cast<SubjectReference*>(son);
56 YASSERT(ref);
57 SubjectServiceNode *service = dynamic_cast<SubjectServiceNode*>(ref->getReference());
58 YASSERT(service);
60 string serviceName = proc->getChildName(service->getNode());
61 DEBTRACE("ADDCHILDREF " << ref->getReference()->getName());
62
63 int nbsons = childCount();
64 model->beginInsertRows(modelIndex(), nbsons, nbsons);
65 item = new SchemaReferenceItem(this,
66 serviceName.c_str(),
67 son);
68 model->endInsertRows();
69 }
70 break;
71
73 {
74 DEBTRACE("REMOVECHILDREF ");
75 }
76 break;
77
78 case YACS::HMI::CUT:
79 {
80 DEBTRACE("CUT on " << getSubject()->getName());
82 SubjectReference *ref = dynamic_cast<SubjectReference*>(son);
83 YASSERT(ref);
84 DEBTRACE("CUT " << ref->getReference()->getName());
86
87 int position = toMove->row();
88 model->beginRemoveRows(modelIndex(), position, position);
89 removeChild(toMove);
90 model->endRemoveRows();
91 }
92 break;
93
95 {
96 DEBTRACE("PASTE on " << getSubject()->getName());
98 SubjectReference *ref = dynamic_cast<SubjectReference*>(son);
99 YASSERT(ref);
100 DEBTRACE("PASTE " << ref->getReference()->getName());
102
103 int nbsons = childCount();
104 model->beginInsertRows(modelIndex(), nbsons, nbsons);
105 toPaste->reparent(this);
106 model->endInsertRows();
107 }
108 break;
109
110
111 default:
112 ;
113 }
114}
115
116void SchemaComponentItem::popupMenu(QWidget *caller, const QPoint &globalPos)
117{
119 m.popupMenu(caller, globalPos);
120}
121
123{
124 return "<p>To edit the component instance properties, select the component instance and use the input panel. <a href=\"modification.html#property-page-for-component-instance-definition\">More...</a></p>";
125}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
std::string getChildName(const Node *node) const
Base class for all schema objects.
Definition: Proc.hxx:44
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
YACS::HMI::SchemaModel * getSchemaModel()
std::map< YACS::HMI::Subject *, YACS::HMI::SchemaItem * > _mapOfSchemaItem
static QtGuiContext * getQtCurrent()
virtual void update(GuiEvent event, int type, Subject *son)
virtual void popupMenu(QWidget *caller, const QPoint &globalPos)
virtual QVariant editionWhatsThis(int column) const
virtual Subject * getSubject()
Definition: SchemaItem.cxx:169
virtual int row() const
Definition: SchemaItem.cxx:154
QModelIndex modelIndex(int column=0)
Definition: SchemaItem.cxx:253
QList< QVariant > _itemDeco
Definition: SchemaItem.hxx:78
virtual void reparent(SchemaItem *parent)
Definition: SchemaItem.cxx:289
virtual void removeChild(SchemaItem *child)
Definition: SchemaItem.cxx:93
virtual int childCount() const
Definition: SchemaItem.cxx:111
virtual YACS::ENGINE::Node * getNode()
def ref(target, callback=None)
Definition: CONNECTOR.py:120