Salome HOME
Update translation files from Crowdin
[samples/light.git] / src / LIGHTGUI / LIGHTGUI.cxx
index 5bbd2ff55444507b8318d91998fb3bf50899025e..8bba2f69b3171178ea4323e523cbbfd6cada7126 100644 (file)
@@ -1,27 +1,30 @@
-//  Copyright (C) 2005-2008  OPEN CASCADE
+// Copyright (C) 2005-2014  OPEN CASCADE
 //
-//  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, or (at your option) any later version.
 //
-//  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
 //
+
 // LIGHT : sample (no-corba-engine) SALOME module
 // File   : LIGHTGUI.cxx
 // Author : Julia DOROVSKIKH
 //
 #include "LIGHTGUI.h"
 
+#include <LIGHT_version.h>
+
 #include "LIGHTGUI_Selection.h"
 #include "LIGHTGUI_DataModel.h"
 #include "LightApp_DataOwner.h"
@@ -586,20 +589,55 @@ void LIGHTGUI::onClear()
   updateObjBrowser( true );
 }
 
+/*!
+  \brief Check if this object is can't be renamed in place
+
+  This method can be re-implemented in the subclasses.
+  Return true in case if object isn't reference or component (module root).
+
+  \param entry column id
+  \return \c true if the item can be renamed by the user in place (e.g. in the Object browser)
+*/
+bool LIGHTGUI::renameAllowed( const QString& entry ) const
+{
+  LIGHTGUI_DataModel* dm = dynamic_cast<LIGHTGUI_DataModel*>( dataModel() );
+  return dm && dm->lineNb( entry ) >= 0;
+}
+
+/*!
+  Rename object by entry.
+  \param entry entry of the object
+  \param name new name of the object
+  \brief Return \c true if rename operation finished successfully, \c false otherwise.
+*/
+bool LIGHTGUI::renameObject( const QString& entry, const QString& name )
+{
+  bool result = false;
+
+  LIGHTGUI_DataModel* dm = dynamic_cast<LIGHTGUI_DataModel*>( dataModel() );
+  if ( dm && dm->lineNb( entry ) ) {
+    int id = LIGHTGUI_DataModel::id( entry );
+    result = dm->setLineText( id, name );
+    if ( result ) {
+      updateLine( id, true );
+      updateObjBrowser( true );
+    }
+  }
+  return result;
+}
+
 /*!
   \fn CAM_Module* createModule();
   \brief Export module instance (factory function).
   \return new created instance of the module
 */
 
-#ifdef WNT
-#define LIGHTGUI_EXPORT __declspec(dllexport)
-#else   // WNT
-#define LIGHTGUI_EXPORT
-#endif  // WNT
-
 extern "C" {
-  LIGHTGUI_EXPORT CAM_Module* createModule() {
+  LIGHT_EXPORT CAM_Module* createModule() {
     return new LIGHTGUI();
   }
+  
+  LIGHT_EXPORT char* getModuleVersion() {
+    return (char*)LIGHT_VERSION_STR;
+  }
 }