-// Copyright (C) 2006-2008 CEA/DEN, EDF R&D
+// Copyright (C) 2006-2012 CEA/DEN, EDF R&D
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
#include "ValueDelegate.hxx"
#include "guiObservers.hxx"
#include "SchemaItem.hxx"
#include "DataPort.hxx"
+#include "StudyPorts.hxx"
#include "TypeCode.hxx"
#include "Switch.hxx"
+#include "ItemEdition.hxx"
//#define _DEVDEBUG_
#include "YacsTrace.hxx"
QString GenericEditor::GetStrValue()
{
+ return "";
}
Subject* GenericEditor::getSubject()
// -----------------------------------------------------------------------------
+NameEditor::NameEditor(Subject* subject,
+ const ValueDelegate* delegate,
+ int column,
+ QWidget * parent)
+ : QLineEdit(parent), GenericEditor()
+{
+ DEBTRACE("NameEditor::NameEditor");
+ setDelegate(delegate);
+ setSubject(subject);
+ setColumn(column);
+}
+
+NameEditor::~NameEditor()
+{
+}
+
+QString NameEditor::GetStrValue()
+{
+ DEBTRACE("Name::GetStrValue " << text().toStdString());
+ string filtered = ItemEdition::filterName(text().toStdString());
+ return filtered.c_str();
+}
+
+void NameEditor::setData(QVariant val)
+{
+ DEBTRACE("NameEditor::setData " << this);
+ DEBTRACE(val.canConvert<QString>());
+ DEBTRACE(val.toString().toStdString());
+ string filtered = ItemEdition::filterName(val.toString().toStdString());
+ setText(filtered.c_str());
+}
+
+// -----------------------------------------------------------------------------
+
IntEditor::IntEditor(Subject* subject,
const ValueDelegate* delegate,
int column,
if (sport)
{
YACS::ENGINE::DataPort *port = sport->getPort();
+ YACS::ENGINE::InputStudyPort* istport=dynamic_cast<YACS::ENGINE::InputStudyPort*>(port);
+ YACS::ENGINE::OutputStudyPort* ostport=dynamic_cast<YACS::ENGINE::OutputStudyPort*>(port);
YACS::ENGINE::TypeCode *tc = port->edGetType();
YACS::ENGINE::DynType dt = tc->kind();
- if (dt == YACS::ENGINE::Int)
+ if (!istport && !ostport && dt == YACS::ENGINE::Int)
editor = new IntEditor(subject, this, column, parent);
}
else if (snode)
}
}
+ if (column == YLabel)
+ {
+ sport = dynamic_cast<SubjectDataPort*>(subject);
+ if (sport)
+ editor = new NameEditor(subject, this, column, parent);
+ }
+
if (!editor) editor = new GeneralEditor(subject, this, column, parent);
return editor;
}
{
DEBTRACE("ValueDelegate::setEditorData");
GenericEditor* gedit = dynamic_cast<GenericEditor*>(editor);
- assert(gedit);
+ YASSERT(gedit);
QString edited = gedit->GetStrValue();
DEBTRACE(edited.toStdString());
Subject *sub = gedit->getSubject();
{
DEBTRACE("ValueDelegate::setModelData");
GenericEditor* gedit = dynamic_cast<GenericEditor*>(editor);
- assert(gedit);
+ YASSERT(gedit);
QString value = gedit->GetStrValue();
DEBTRACE(value.toStdString());
//model->setData(index, value, Qt::EditRole); // real set done by update
{
DEBTRACE("ValueDelegate::setResultEditing " << isOk);
GenericEditor* gedit = dynamic_cast<GenericEditor*>(editor);
- assert(gedit);
+ YASSERT(gedit);
Subject *sub = gedit->getSubject();
string val = gedit->GetStrValue().toStdString();
DEBTRACE(sub->getName() << " " << val);