]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Add possibility to generate name without indexes.
authormzn <mzn@opencascade.com>
Wed, 20 Nov 2013 07:41:15 +0000 (07:41 +0000)
committermzn <mzn@opencascade.com>
Wed, 20 Nov 2013 07:41:15 +0000 (07:41 +0000)
src/HYDROData/HYDROData_Tool.cxx
src/HYDROData/HYDROData_Tool.h

index c217725ab2e48741aef2f8397b07306ed75da90d..fee6e1105dc018dac99aff70dd9077297291c9bb 100644 (file)
@@ -68,7 +68,8 @@ void HYDROData_Tool::SetMustBeUpdatedImages(
 
 QString HYDROData_Tool::GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
                                             const QString&                    thePrefix,
-                                            const QStringList&                theUsedNames )
+                                            const QStringList&                theUsedNames,
+                                            const bool                        theIsTryToUsePurePrefix )
 {
   QStringList aNamesList( theUsedNames );
 
@@ -89,14 +90,18 @@ QString HYDROData_Tool::GenerateObjectName( const Handle(HYDROData_Document)& th
 
   QString aName;
 
-  int anId = 1;
-  while( anId < 1000 )
-  {
-    aName = QString( "%1_%2" ).arg( thePrefix ).arg( QString::number( anId++ ) );
+  if ( theIsTryToUsePurePrefix && !aNamesList.contains( thePrefix ) ) {
+    aName = thePrefix;
+  } else {
+    int anId = 1;
+    while( anId < 1000 )
+    {
+      aName = QString( "%1_%2" ).arg( thePrefix ).arg( QString::number( anId++ ) );
 
-    // check that there are no other objects with the same name in the document
-    if ( !aNamesList.contains( aName ) )
-      break;
+      // check that there are no other objects with the same name in the document
+      if ( !aNamesList.contains( aName ) )
+        break;
+    }
   }
 
   return aName;
index 5b550ca2b5bf502c51fc83b9693ea6136b858183..a1fc83373496e5a1a6d8424d86bb7792769ac627 100644 (file)
@@ -32,11 +32,13 @@ public:
    * \param theModule module
    * \param thePrefix name prefix
    * \param theUsedNames list of already used names
+   * \param theIsTryToUsePurePrefix if true - the prefix will be returned if the name equal to the prefix is not busy
    * \return generated name
    */
   static QString                        GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
                                                             const QString&                    thePrefix,
-                                                            const QStringList&                theUsedNames = QStringList() );
+                                                            const QStringList&                theUsedNames = QStringList(),
+                                                            const bool                        theIsTryToUsePurePrefix = false );
 
   /**
    * \brief Find the data object with the specified name.