Salome HOME
Updated copyright comment
[modules/gui.git] / src / SUIT / SUIT_SelectionMgr.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 0461e8f..3e68c42
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -92,7 +92,7 @@ void SUIT_SelectionMgr::setEnabled( const bool on, const QString& typ )
 
 /*! Gets selected data owners from list with type \a type to list \a lst.
 */
-void SUIT_SelectionMgr::selected( SUIT_DataOwnerPtrList& lst, const QString& type ) const
+void SUIT_SelectionMgr::selected( SUIT_DataOwnerPtrList& lst, const QString& type, const bool onlyOne ) const
 {
   lst.clear();
 
@@ -103,10 +103,25 @@ void SUIT_SelectionMgr::selected( SUIT_DataOwnerPtrList& lst, const QString& typ
     if ( !type.isEmpty() && (*it)->type() != type )
       continue;
 
-    SUIT_DataOwnerPtrList curList;
+    SUIT_DataOwnerPtrList curList( /*skipAllEqual=*/false );
     (*it)->selected( curList );
-    for ( SUIT_DataOwnerPtrList::const_iterator itr = curList.begin(); itr != curList.end(); ++itr )
-      lst.append( *itr );
+    if ( onlyOne )
+    {
+      for ( SUIT_DataOwnerPtrList::const_iterator itr = curList.begin(); itr != curList.end(); ++itr )
+      {
+        lst.append( *itr );
+        if ( lst.count() > 1 )
+        {
+          lst.clear();
+          return;
+        }
+      }
+    }
+    else
+    {
+      for ( SUIT_DataOwnerPtrList::const_iterator itr = curList.begin(); itr != curList.end(); ++itr )
+        lst.append( *itr );
+    }
   }
 }
 
@@ -352,4 +367,4 @@ void SUIT_SelectionMgr::filterOwners( const SUIT_DataOwnerPtrList& in, SUIT_Data
     if ( isOk( *it ) )
       out.append( *it );
   }
-}
+}
\ No newline at end of file