Version: 9.16.0
SchemaContainerItem.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 "Menus.hxx"
25
26#include <QIcon>
27#include <cassert>
28
29//#define _DEVDEBUG_
30#include "YacsTrace.hxx"
31
32using namespace std;
33using namespace YACS::HMI;
34
35SchemaContainerItem::SchemaContainerItem(SchemaItem *parent, QString label, Subject* subject)
36 : SchemaItem(parent, label, subject)
37{
38 DEBTRACE("SchemaContainerItem::SchemaContainerItem " << subject->getName());
39 SubjectContainer *scont = dynamic_cast<SubjectContainer*>(subject);
40 DEBTRACE(scont);
41 _itemDeco.replace(YLabel, QIcon("icons:container.png"));
42}
43
44void SchemaContainerItem::update(GuiEvent event, int type, Subject* son)
45{
46 DEBTRACE("SchemaContainerItem::update " << eventName(event) << " " << son->getName());
47 //SchemaItem::update(event, type, son);
48 switch (event)
49 {
51 {
52 DEBTRACE("ADDCHILDREF ");
54 SubjectReference *ref = dynamic_cast<SubjectReference*>(son);
55 YASSERT(ref);
56 DEBTRACE("ADDCHILDREF " << ref->getReference()->getName());
57 addComponentInstance(ref->getReference());
58 }
59 break;
60
62 {
63 DEBTRACE("REMOVECHILDREF on " << getSubject()->getName());
65 SubjectReference *ref = dynamic_cast<SubjectReference*>(son);
66 YASSERT(ref);
67 DEBTRACE("REMOVECHILDREF " << ref->getReference()->getName());
68 SchemaItem *toRemove = QtGuiContext::getQtCurrent()->_mapOfSchemaItem[ref->getReference()];
69
70 int position = toRemove->row();
71 model->beginRemoveRows(modelIndex(), position, position);
72 removeChild(toRemove);
73 model->endRemoveRows();
74 }
75 break;
76
77 case YACS::HMI::CUT:
78 {
79 DEBTRACE("CUT on " << getSubject()->getName());
81 SubjectReference *ref = dynamic_cast<SubjectReference*>(son);
82 YASSERT(ref);
83 DEBTRACE("CUT " << ref->getReference()->getName());
84 SchemaItem *toMove = QtGuiContext::getQtCurrent()->_mapOfSchemaItem[ref->getReference()];
85
86 int position = toMove->row();
87 model->beginRemoveRows(modelIndex(), position, position);
88 removeChild(toMove);
89 model->endRemoveRows();
90 }
91 break;
92
94 {
95 DEBTRACE("PASTE on " << getSubject()->getName());
97 SubjectReference *ref = dynamic_cast<SubjectReference*>(son);
98 YASSERT(ref);
99 DEBTRACE("PASTE " << ref->getReference()->getName());
100 SchemaItem *toPaste = QtGuiContext::getQtCurrent()->_mapOfSchemaItem[ref->getReference()];
101
102 int nbsons = childCount();
103 model->beginInsertRows(modelIndex(), nbsons, nbsons);
104 toPaste->reparent(this);
105 model->endInsertRows();
106 }
107 break;
108
109 default:
110 SchemaItem::update(event, type, son);
111 ;
112 }
113}
114
116{
117 DEBTRACE("SchemaContainersItem::addComponentInstance");
119 int nbsons = childCount();
120 model->beginInsertRows(modelIndex(), nbsons, nbsons);
122 subject->getName().c_str(),
123 subject);
124 model->endInsertRows();
125}
126
127void SchemaContainerItem::popupMenu(QWidget *caller, const QPoint &globalPos)
128{
130 m.popupMenu(caller, globalPos);
131}
132
134{
135 return "<p>To edit the container properties, select the container and use the input panel. <a href=\"modification.html#property-page-for-container\">More...</a></p>";
136}
#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
static std::string eventName(GuiEvent event)
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)
void addComponentInstance(Subject *subject)
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 update(GuiEvent event, int type, Subject *son)
Definition: SchemaItem.cxx:174
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 std::string getName()
def ref(target, callback=None)
Definition: CONNECTOR.py:120