Version: 8.3.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
SchemaComponentItem.cxx
Go to the documentation of this file.
1
// Copyright (C) 2006-2016 CEA/DEN, EDF R&D
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
20
#include "
SchemaComponentItem.hxx
"
21
#include "
QtGuiContext.hxx
"
22
#include "
SchemaModel.hxx
"
23
#include "
SchemaReferenceItem.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
33
using namespace
std;
34
using namespace
YACS::HMI;
35
36
37
SchemaComponentItem::SchemaComponentItem(
SchemaItem
*parent, QString label,
Subject
* subject)
38
:
SchemaItem
(parent, label, subject)
39
{
40
_itemDeco
.replace(
YLabel
, QIcon(
"icons:component.png"
));
41
}
42
43
void
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
{
51
case
YACS::HMI::ADDCHILDREF
:
52
{
53
DEBTRACE
(
"ADDCHILDREF "
);
54
model =
QtGuiContext::getQtCurrent
()->
getSchemaModel
();
55
SubjectReference
*
ref
=
dynamic_cast<
SubjectReference
*
>
(son);
56
YASSERT
(ref);
57
SubjectServiceNode
*service =
dynamic_cast<
SubjectServiceNode
*
>
(ref->
getReference
());
58
YASSERT
(service);
59
YACS::ENGINE::Proc
* proc =
GuiContext::getCurrent
()->
getProc
();
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
72
case
YACS::HMI::REMOVECHILDREF
:
73
{
74
DEBTRACE
(
"REMOVECHILDREF "
);
75
}
76
break
;
77
78
case
YACS::HMI::CUT
:
79
{
80
DEBTRACE
(
"CUT on "
<<
getSubject
()->getName());
81
SchemaModel
*model =
QtGuiContext::getQtCurrent
()->
getSchemaModel
();
82
SubjectReference
*
ref
=
dynamic_cast<
SubjectReference
*
>
(son);
83
YASSERT
(ref);
84
DEBTRACE
(
"CUT "
<< ref->
getReference
()->
getName
());
85
SchemaItem
*toMove =
QtGuiContext::getQtCurrent
()->
_mapOfSchemaItem
[
ref
];
86
87
int
position = toMove->row();
88
model->beginRemoveRows(
modelIndex
(), position, position);
89
removeChild
(toMove);
90
model->endRemoveRows();
91
}
92
break
;
93
94
case
YACS::HMI::PASTE
:
95
{
96
DEBTRACE
(
"PASTE on "
<<
getSubject
()->getName());
97
SchemaModel
*model =
QtGuiContext::getQtCurrent
()->
getSchemaModel
();
98
SubjectReference
*
ref
=
dynamic_cast<
SubjectReference
*
>
(son);
99
YASSERT
(ref);
100
DEBTRACE
(
"PASTE "
<< ref->
getReference
()->
getName
());
101
SchemaItem
*toPaste =
QtGuiContext::getQtCurrent
()->
_mapOfSchemaItem
[
ref
];
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
116
void
SchemaComponentItem::popupMenu
(
QWidget
*caller,
const
QPoint &globalPos)
117
{
118
ComponentInstanceMenu
m
;
119
m.
popupMenu
(caller, globalPos);
120
}
121
122
QVariant
SchemaComponentItem::editionWhatsThis
(
int
column)
const
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
}
src
genericgui
SchemaComponentItem.cxx
Copyright © 2006-2017 CEA/DEN, EDF R&D