1 // Copyright (C) 2006-2012 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "SchemaComponentItem.hxx"
21 #include "QtGuiContext.hxx"
22 #include "SchemaModel.hxx"
23 #include "SchemaReferenceItem.hxx"
24 #include "guiObservers.hxx"
31 #include "YacsTrace.hxx"
34 using namespace YACS::HMI;
37 SchemaComponentItem::SchemaComponentItem(SchemaItem *parent, QString label, Subject* subject)
38 : SchemaItem(parent, label, subject)
40 _itemDeco.replace(YLabel, QIcon("icons:component.png"));
43 void SchemaComponentItem::update(GuiEvent event, int type, Subject* son)
45 DEBTRACE("SchemaComponentItem::update");
46 //SchemaItem::update(event, type, son);
47 SchemaModel *model = 0;
48 SchemaReferenceItem *item =0;
51 case YACS::HMI::ADDCHILDREF:
53 DEBTRACE("ADDCHILDREF ");
54 model = QtGuiContext::getQtCurrent()->getSchemaModel();
55 SubjectReference *ref = dynamic_cast<SubjectReference*>(son);
57 SubjectServiceNode *service = dynamic_cast<SubjectServiceNode*>(ref->getReference());
59 YACS::ENGINE::Proc* proc = GuiContext::getCurrent()->getProc();
60 string serviceName = proc->getChildName(service->getNode());
61 DEBTRACE("ADDCHILDREF " << ref->getReference()->getName());
63 int nbsons = childCount();
64 model->beginInsertRows(modelIndex(), nbsons, nbsons);
65 item = new SchemaReferenceItem(this,
68 model->endInsertRows();
72 case YACS::HMI::REMOVECHILDREF:
74 DEBTRACE("REMOVECHILDREF ");
80 DEBTRACE("CUT on " << getSubject()->getName());
81 SchemaModel *model = QtGuiContext::getQtCurrent()->getSchemaModel();
82 SubjectReference *ref = dynamic_cast<SubjectReference*>(son);
84 DEBTRACE("CUT " << ref->getReference()->getName());
85 SchemaItem *toMove = QtGuiContext::getQtCurrent()->_mapOfSchemaItem[ref];
87 int position = toMove->row();
88 model->beginRemoveRows(modelIndex(), position, position);
90 model->endRemoveRows();
94 case YACS::HMI::PASTE:
96 DEBTRACE("PASTE on " << getSubject()->getName());
97 SchemaModel *model = QtGuiContext::getQtCurrent()->getSchemaModel();
98 SubjectReference *ref = dynamic_cast<SubjectReference*>(son);
100 DEBTRACE("PASTE " << ref->getReference()->getName());
101 SchemaItem *toPaste = QtGuiContext::getQtCurrent()->_mapOfSchemaItem[ref];
103 int nbsons = childCount();
104 model->beginInsertRows(modelIndex(), nbsons, nbsons);
105 toPaste->reparent(this);
106 model->endInsertRows();
116 void SchemaComponentItem::popupMenu(QWidget *caller, const QPoint &globalPos)
118 ComponentInstanceMenu m;
119 m.popupMenu(caller, globalPos);
122 QVariant SchemaComponentItem::editionWhatsThis(int column) const
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>";