Version: 9.16.0
SchemaDirTypesItem.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 "ItemMimeData.hxx"
25#include "GuiEditor.hxx"
26
27#include <QIcon>
28#include <cassert>
29
30//#define _DEVDEBUG_
31#include "YacsTrace.hxx"
32
33using namespace std;
34using namespace YACS::ENGINE;
35using namespace YACS::HMI;
36
37SchemaDirTypesItem::SchemaDirTypesItem(SchemaItem *parent, QString label, Subject* subject)
38 : SchemaItem(parent, label, subject)
39{
40 _itemDeco.replace(YLabel, QIcon("icons:folder_cyan.png"));
41}
42
44{
45 DEBTRACE("SchemaDirTypesItem::addTypeItem");
47 int nbsons = childCount();
48 SubjectDataType *sdt = dynamic_cast<SubjectDataType*>(subject);
49 YASSERT(sdt);
50 DEBTRACE(nbsons);
51 model->beginInsertRows(modelIndex(), nbsons, nbsons);
52 SchemaItem *item = new SchemaDataTypeItem(this,
53 sdt->getAlias().c_str(),
54 sdt);
55 model->endInsertRows();
56}
57
59{
60 DEBTRACE("SchemaDirTypesItem::removeTypeItem");
62 YASSERT(QtGuiContext::getQtCurrent()->_mapOfSchemaItem.count(subject));
64 int position = toRemove->row();
65 DEBTRACE(position);
66 model->beginRemoveRows(modelIndex(), position, position);
67 removeChild(toRemove);
68 model->endRemoveRows();
69}
70
71Qt::ItemFlags SchemaDirTypesItem::flags(const QModelIndex &index)
72{
73 //DEBTRACE("SchemaDirTypesItem::flags");
74 return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled;
75}
76
77bool SchemaDirTypesItem::dropMimeData(const QMimeData* data, Qt::DropAction action)
78{
79 DEBTRACE("SchemaDirTypesItem::dropMimeData");
80 if (!data) return false;
81 const ItemMimeData* myData = dynamic_cast<const ItemMimeData*>(data);
82 if (!myData) return false;
83 bool ret =false;
84 if (myData->hasFormat("yacs/cataType"))
85 {
86 ret =true;
88 }
89 return ret;
90}
91
92QVariant SchemaDirTypesItem::editionWhatsThis(int column) const
93{
94return "All the Data types required in this schema must be in this folder.\n" \
95 "You can add data types here by import from catalogs " \
96 "(builtin catalog, session catalog, or a catalog built from another schema).\n" \
97 "To add a data type, drag a data type item from catalogs panel and drop it here.";
98}
99
#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
YACS::HMI::GuiEditor * _guiEditor
Definition: GenericGui.hxx:201
void AddTypeFromCatalog(const ItemMimeData *myData)
Definition: GuiEditor.cxx:203
YACS::HMI::SchemaModel * getSchemaModel()
std::map< YACS::HMI::Subject *, YACS::HMI::SchemaItem * > _mapOfSchemaItem
static QtGuiContext * getQtCurrent()
YACS::HMI::GenericGui * getGMain()
void addTypeItem(Subject *subject)
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action)
void removeTypeItem(Subject *subject)
virtual QVariant editionWhatsThis(int column) const
virtual Qt::ItemFlags flags(const QModelIndex &index)
virtual int row() const
Definition: SchemaItem.cxx:154
QModelIndex modelIndex(int column=0)
Definition: SchemaItem.cxx:253
QList< QVariant > _itemDeco
Definition: SchemaItem.hxx:78
virtual QVariant data(int column, int role) const
Definition: SchemaItem.cxx:123
virtual void removeChild(SchemaItem *child)
Definition: SchemaItem.cxx:93
virtual int childCount() const
Definition: SchemaItem.cxx:111
virtual std::string getAlias()