Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/gui.git] / src / SUIT / SUIT_TreeSync.h
index 1369fde22b819cac0aa26a16e67592e207d97492..2b94e98ea7a37faebba02e6cf9e29e9978d104dc 100644 (file)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  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
 //
+
 // File   : SUIT_TreeSync.h
 // Author : Alexander SOLOVYOV
 //
@@ -54,17 +55,17 @@ TrgItem synchronize( const SrcItem&, const TrgItem&, const TreeData& );
 
 template <class SrcItem, class TrgItem, class TreeData>
 QList< DiffItem<SrcItem,TrgItem> > diffSiblings( const SrcItem&, 
-                                                const TrgItem&, 
-                                                const TreeData& );
+                                                 const TrgItem&, 
+                                                 const TreeData& );
 
 template <class SrcItem, class TrgItem, class TreeData>
 TrgItem createSubTree( const SrcItem&, const TrgItem&, const TrgItem&, const TreeData& );
 
 template <class SrcItem, class TrgItem, class TreeData>
 const typename QList<TrgItem>::const_iterator findEqual( const SrcItem& it,
-                                                        const typename QList<TrgItem>::const_iterator& first,
-                                                        const typename QList<TrgItem>::const_iterator& last,
-                                                        const TreeData& td );
+                                                         const typename QList<TrgItem>::const_iterator& first,
+                                                         const typename QList<TrgItem>::const_iterator& last,
+                                                         const TreeData& td );
 
 
 //
@@ -129,24 +130,24 @@ TrgItem synchronize( const SrcItem& r1, const TrgItem& r2, const TreeData& td )
     for ( ; anIt != aLast; anIt++ ) {
       const DiffItem<SrcItem,TrgItem>& item = *anIt;
       if ( item.mySrc == td.nullSrc() ) {
-       if ( item.myTrg == td.nullTrg() )
-         qDebug( "error: both null" );
+        if ( item.myTrg == td.nullTrg() )
+          qDebug( "error: both null" );
         else
-         // delete item
-         td.deleteItemWithChildren( item.myTrg );
+          // delete item
+          td.deleteItemWithChildren( item.myTrg );
       }
       else {
-       if ( item.myTrg == td.nullTrg() ) {
-         // add item (recursively)
-         TrgItem nitem = createSubTree( item.mySrc, r2, lastItem, td );
-         if ( nitem != td.nullTrg() )
-           lastItem = nitem;
-       }
+        if ( item.myTrg == td.nullTrg() ) {
+          // add item (recursively)
+          TrgItem nitem = createSubTree( item.mySrc, r2, lastItem, td );
+          if ( nitem != td.nullTrg() )
+            lastItem = nitem;
+        }
         else {
-         // update item
-         synchronize( item.mySrc, item.myTrg, td );
-         lastItem = item.myTrg;
-       }
+          // update item
+          synchronize( item.mySrc, item.myTrg, td );
+          lastItem = item.myTrg;
+        }
       }
     }
     return r2;
@@ -177,9 +178,9 @@ TrgItem synchronize( const SrcItem& r1, const TrgItem& r2, const TreeData& td )
 */
 template <class SrcItem, class TrgItem, class TreeData>
 const typename QList<TrgItem>::const_iterator findEqual( const SrcItem& it,
-                                                        const typename QList<TrgItem>::const_iterator& first,
-                                                        const typename QList<TrgItem>::const_iterator& last,
-                                                        const TreeData& td )
+                                                         const typename QList<TrgItem>::const_iterator& first,
+                                                         const typename QList<TrgItem>::const_iterator& last,
+                                                         const TreeData& td )
 {
   typename QList<TrgItem>::const_iterator cur = first;
   for ( ; cur != last; cur++ ) {
@@ -199,7 +200,7 @@ const typename QList<TrgItem>::const_iterator findEqual( const SrcItem& it,
 */
 template <class SrcItem, class TrgItem, class TreeData>
 QList< DiffItem<SrcItem,TrgItem> > diffSiblings( const SrcItem& src, const TrgItem& trg,
-                                                const TreeData& td )
+                                                 const TreeData& td )
 {
   //if( src==td.nullSrc() || trg==td.nullTrg() )
   //  return;
@@ -219,10 +220,10 @@ QList< DiffItem<SrcItem,TrgItem> > diffSiblings( const SrcItem& src, const TrgIt
       // target is found
       // mark all items before found one as "to be deleted"
       for ( typename QList<TrgItem>::const_iterator it = cur; it != f; it++ ) {
-       DiffItem<SrcItem,TrgItem> ndiff;
-       ndiff.mySrc = td.nullSrc();
-       ndiff.myTrg = *it;        // delete item
-       d.append( ndiff );
+        DiffItem<SrcItem,TrgItem> ndiff;
+        ndiff.mySrc = td.nullSrc();
+        ndiff.myTrg = *it;        // delete item
+        d.append( ndiff );
       }
       cur = f;
       DiffItem<SrcItem,TrgItem> ndiff;
@@ -261,7 +262,7 @@ QList< DiffItem<SrcItem,TrgItem> > diffSiblings( const SrcItem& src, const TrgIt
 */
 template <class SrcItem, class TrgItem, class TreeData>
 TrgItem createSubTree( const SrcItem& src, const TrgItem& parent,
-                      const TrgItem& after, const TreeData& td )
+                       const TrgItem& after, const TreeData& td )
 {
   if ( src == td.nullSrc() )
     return td.nullTrg();