Salome HOME
Merge Qt5 porting.
[modules/yacs.git] / src / genericgui / GuiEditor.cxx
index c50a41dda7e654fa9519e829a813650acd5e2086..da78dbb9de729622b246972ab5542d99ed4ab209 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2015  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
@@ -269,7 +269,7 @@ void GuiEditor::CreateContainer()
   DEBTRACE("GuiEditor::CreateContainer");
   SubjectProc *sproc = QtGuiContext::getQtCurrent()->getSubjectProc();
   YASSERT(sproc);
-  SubjectContainer *scont = 0;
+  SubjectContainerBase *scont = 0;
   while (!scont)
     {
       std::stringstream name;
@@ -281,6 +281,23 @@ void GuiEditor::CreateContainer()
     }
 }
 
+void GuiEditor::CreateHPContainer()
+{
+  DEBTRACE("GuiEditor::CreateHPContainer");
+  SubjectProc *sproc = QtGuiContext::getQtCurrent()->getSubjectProc();
+  YASSERT(sproc);
+  SubjectContainerBase *scont = 0;
+  while (!scont)
+    {
+      std::stringstream name;
+      long newid = GuiContext::getCurrent()->getNewId();
+      if (newid > 100000) break;
+      name.str("");
+      name << "container" << newid;
+      scont = sproc->addHPContainer(name.str());
+    }
+}
+
 void GuiEditor::CreateComponentInstance()
 {
   DEBTRACE("GuiEditor::CreateComponentInstance");
@@ -439,6 +456,8 @@ void GuiEditor::DeleteSubject(Subject* parent,
   toRemove->askRegisterUndoDestroy();
   if(!parent->destroy(toRemove))
     Message mess;
+  // Empty the clipboard in order to avoid the copy of a destroyed object.
+  QtGuiContext::getQtCurrent()->setSubjectToCopy(NULL);
 }
 
 void GuiEditor::CutSubject()
@@ -697,7 +716,7 @@ void GuiEditor::showRedo(QWidget *parent)
 QString GuiEditor::asciiFilter(const QString & name)
 {
   DEBTRACE(name.toStdString());
-  string aName = name.toAscii().data();
+  string aName = name.toLatin1().data();
   DEBTRACE(aName);
   for (int i=0; i < aName.size(); i++)
     {