Salome HOME
72dbdd86da220cd0737db399c3bf77fdc23fc8da
[modules/yacs.git] / src / genericgui / SchemaDirLinksItem.cxx
1 // Copyright (C) 2006-2023  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
20 #include "SchemaDirLinksItem.hxx"
21 #include "SchemaLinkItem.hxx"
22 #include "SchemaModel.hxx"
23 #include "QtGuiContext.hxx"
24 #include "GuiEditor.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::ENGINE;
34 using namespace YACS::HMI;
35
36 SchemaDirLinksItem::SchemaDirLinksItem(SchemaItem *parent, QString label, Subject* subject)
37   : SchemaItem(parent, label, subject)
38 {
39   _itemDeco.replace(YLabel, QIcon("icons:folder_cyan.png"));
40 }
41
42 void SchemaDirLinksItem::addLinkItem(Subject* subject)
43 {
44   DEBTRACE("SchemaDirLinksItem::addTypeItem");
45   SchemaModel *model = QtGuiContext::getQtCurrent()->getSchemaModel();
46   int nbsons = childCount();
47   model->beginInsertRows(modelIndex(), nbsons, nbsons);
48   SchemaItem *item = new SchemaLinkItem(this,
49                                         subject->getName().c_str(),
50                                         subject);
51   model->endInsertRows();
52 }
53
54 Qt::ItemFlags SchemaDirLinksItem::flags(const QModelIndex &index)
55 {
56   //DEBTRACE("SchemaDirLinksItem::flags");
57   return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
58 }
59
60 QVariant SchemaDirLinksItem::editionWhatsThis(int column) const
61 {
62 return "<p>Links between ports or nodes under that block level appears in this folder.\n" \
63   "You can add data links (between ports) and control links (between nodes) " \
64   "by drag from origin (out node or out port) to destination (in node or in port) " \
65   "either in 2D graphic view or tree view. <a href=\"modification.html#create-a-link\">More...</a></p>";
66 }
67