Salome HOME
Updated copyright comment
[modules/gui.git] / src / Qtx / QtxPopupMgr.cxx
index 2710a09337c45da9f17b50b254e573e65b32507b..3e732104f872faa689b8db0ecfd693e595d971fa 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  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
@@ -6,7 +6,7 @@
 // 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.
+// 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
 #include "QtxPopupMgr.h"
 #include "QtxAction.h"
 #include "QtxEvalExpr.h"
+#include <QList>
 #include <QMenu>
+#include <QVariant>
 
-/*!
-  \brief Used for comparing of two QVariant values.
-  \param v1 first argument for comparison
-  \param v2 second argument for comparison
-  \return \c true if \a v1 less than \a v2
-*/
-bool operator<( const QVariant& v1, const QVariant& v2 )
+bool operator<( const QList<QVariant>& v1, const QList<QVariant>& v2 )
 {
-  QVariant::Type t1 = v1.type(), t2 = v2.type();
-  if ( t1 == t2 )
+  QList<QVariant>::const_iterator anIt1 = v1.begin(), aLast1 = v1.end(),
+    anIt2 = v2.begin(), aLast2 = v2.end();
+  for ( ; anIt1 != aLast1 && anIt2 != aLast2;  anIt1++, anIt2++ )
   {
-    switch( t1 )
-    {
-    case QVariant::Int:
-      return v1.toInt() < v2.toInt();
-    case QVariant::Double:
-      return v1.toDouble() < v2.toDouble();
-    case QVariant::String:
-      return v1.toString() < v2.toString();
-    case QVariant::StringList:
-    case QVariant::List:
-    {
-      const QList<QVariant>& aList1 = v1.toList(), aList2 = v2.toList();
-      QList<QVariant>::const_iterator anIt1 = aList1.begin(), aLast1 = aList1.end(),
-        anIt2 = aList2.begin(), aLast2 = aList2.end();
-      for ( ; anIt1 != aLast1 && anIt2 != aLast2;  anIt1++, anIt2++ )
-      {
-        if ( (*anIt1) != (*anIt2) )
-          return (*anIt1)<(*anIt2);
-      }
-      return anIt1 == aLast1 && anIt2 != aLast2;
-    }
-    default:
-      return v1.toString() < v2.toString();
-    }
+    if ( (*anIt1) != (*anIt2) )
+      return (*anIt1) < (*anIt2);
   }
-  return t1 < t2;
+  return anIt1 == aLast1 && anIt2 != aLast2;
 }
 
 /*!
@@ -374,7 +349,7 @@ int QtxPopupMgr::insertAction( QAction* a, const int pId, const QString& rule, c
 */
 bool QtxPopupMgr::hasRule( QAction* a, const RuleType t ) const
 {
-  return a ? expression( a, t, false ) : false;
+  return a ? expression( a, t, false )!=0 : false;
 }
 
 /*!