Version: 9.16.0
SchemaDirContainersItem.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
22#include "SchemaModel.hxx"
23#include "QtGuiContext.hxx"
24#include "ComponentInstance.hxx"
25#include "Container.hxx"
26#include "Menus.hxx"
27
28#include <QIcon>
29#include <cassert>
30
31//#define _DEVDEBUG_
32#include "YacsTrace.hxx"
33
34using namespace std;
35using namespace YACS::ENGINE;
36using namespace YACS::HMI;
37
38SchemaDirContainersItem::SchemaDirContainersItem(SchemaItem *parent, QString label, Subject* subject)
39 : SchemaItem(parent, label, subject)
40{
41 _itemDeco.replace(YLabel, QIcon("icons:folder_cyan.png"));
42 _schemaContItemMap.clear();
43 _waitingCompItemMap.clear();
44}
45
46void SchemaDirContainersItem::popupMenu(QWidget *caller, const QPoint &globalPos)
47{
49 m.popupMenu(caller, globalPos);
50}
51
52
53
59{
60 DEBTRACE("SchemaDirContainersItem::addContainerItem");
62 int nbsons = childCount();
63 string contName = subject->getName();
64
65 model->beginInsertRows(modelIndex(), nbsons, nbsons);
67 contName.c_str(),
68 subject);
69 model->endInsertRows();
70
71 _schemaContItemMap[contName] = item;
72}
73
79{
80 DEBTRACE("SchemaDirContainersItem::addComponentItem");
81 SubjectComponent *aSComp = dynamic_cast<SubjectComponent*>(subject);
82 YASSERT(aSComp);
83 ComponentInstance* component = aSComp->getComponent();
84 YASSERT(component);
85
86 string contName = "DefaultContainer";
87 Container *container = component->getContainer();
88 if (container)
89 contName = container->getName();
90 else
91 {
92 if (!_schemaContItemMap.count(contName)) // no container and default container not created
93 {
95 sProc->addContainer(contName);
96 }
97 }
98
99 YASSERT(_schemaContItemMap.count(contName));
101 aSComp->associateToContainer(static_cast<SubjectContainer*>(sci->getSubject()));
102}
103
105{
106 return "<p>Containers used in this schema appears in this folder.\n" \
107 "You can add containers by using the context menu (entry \"Create container\") " \
108 "and then edit its properties in the input panel. <a href=\"modification.html#property-page-for-container\">More...</a></p>";
109}
#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
Base class for all component instances.
virtual std::string getName() const
Definition: Container.hxx:81
YACS::HMI::SubjectProc * getSubjectProc()
Definition: guiContext.hxx:52
YACS::HMI::SchemaModel * getSchemaModel()
static QtGuiContext * getQtCurrent()
virtual void popupMenu(QWidget *caller, const QPoint &globalPos)
virtual QVariant editionWhatsThis(int column) const
std::multimap< std::string, Subject * > _waitingCompItemMap
std::map< std::string, SchemaContainerItem * > _schemaContItemMap
virtual Subject * getSubject()
Definition: SchemaItem.cxx:169
QModelIndex modelIndex(int column=0)
Definition: SchemaItem.cxx:253
QList< QVariant > _itemDeco
Definition: SchemaItem.hxx:78
virtual int childCount() const
Definition: SchemaItem.cxx:111
YACS::ENGINE::ComponentInstance * getComponent() const
virtual bool associateToContainer(SubjectContainerBase *subcont)
virtual SubjectContainerBase * addContainer(std::string name, std::string ref="")
virtual std::string getName()