Version: 8.3.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
SchemaContainerItem.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 "
SchemaContainerItem.hxx
"
21
#include "
QtGuiContext.hxx
"
22
#include "
SchemaModel.hxx
"
23
#include "
SchemaComponentItem.hxx
"
24
#include "
Menus.hxx
"
25
26
#include <QIcon>
27
#include <cassert>
28
29
//#define _DEVDEBUG_
30
#include "
YacsTrace.hxx
"
31
32
using namespace
std;
33
using namespace
YACS::HMI;
34
35
SchemaContainerItem::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
44
void
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
{
50
case
YACS::HMI::ADDCHILDREF
:
51
{
52
DEBTRACE
(
"ADDCHILDREF "
);
53
SchemaModel
*model =
QtGuiContext::getQtCurrent
()->
getSchemaModel
();
54
SubjectReference
*
ref
=
dynamic_cast<
SubjectReference
*
>
(son);
55
YASSERT
(ref);
56
DEBTRACE
(
"ADDCHILDREF "
<< ref->
getReference
()->
getName
());
57
addComponentInstance
(ref->
getReference
());
58
}
59
break
;
60
61
case
YACS::HMI::REMOVECHILDREF
:
62
{
63
DEBTRACE
(
"REMOVECHILDREF on "
<<
getSubject
()->getName());
64
SchemaModel
*model =
QtGuiContext::getQtCurrent
()->
getSchemaModel
();
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());
80
SchemaModel
*model =
QtGuiContext::getQtCurrent
()->
getSchemaModel
();
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
93
case
YACS::HMI::PASTE
:
94
{
95
DEBTRACE
(
"PASTE on "
<<
getSubject
()->getName());
96
SchemaModel
*model =
QtGuiContext::getQtCurrent
()->
getSchemaModel
();
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
115
void
SchemaContainerItem::addComponentInstance
(
Subject
* subject)
116
{
117
DEBTRACE
(
"SchemaContainersItem::addComponentInstance"
);
118
SchemaModel
*model =
QtGuiContext::getQtCurrent
()->
getSchemaModel
();
119
int
nbsons =
childCount
();
120
model->beginInsertRows(
modelIndex
(), nbsons, nbsons);
121
SchemaComponentItem
*item =
new
SchemaComponentItem
(
this
,
122
subject->
getName
().c_str(),
123
subject);
124
model->endInsertRows();
125
}
126
127
void
SchemaContainerItem::popupMenu
(
QWidget
*caller,
const
QPoint &globalPos)
128
{
129
ContainerMenu
m
;
130
m.
popupMenu
(caller, globalPos);
131
}
132
133
QVariant
SchemaContainerItem::editionWhatsThis
(
int
column)
const
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
}
src
genericgui
SchemaContainerItem.cxx
Copyright © 2006-2017 CEA/DEN, EDF R&D