Back to index

salome-gui  6.5.0
Classes | Functions
QtxPopupMgr.cxx File Reference
#include "QtxPopupMgr.h"
#include "QtxAction.h"
#include "QtxEvalExpr.h"
#include <QMenu>

Go to the source code of this file.

Classes

class  QtxPopupMgr::PopupCreator
 Popup menu actions creator. More...

Functions

bool operator< (const QVariant &v1, const QVariant &v2)
 Used for comparing of two QVariant values.

Function Documentation

bool operator< ( const QVariant &  v1,
const QVariant &  v2 
)

Used for comparing of two QVariant values.

Parameters:
v1first argument for comparison
v2second argument for comparison
Returns:
true if v1 less than v2

Definition at line 37 of file QtxPopupMgr.cxx.

{
  QVariant::Type t1 = v1.type(), t2 = v2.type();
  if ( t1 == t2 )
  {
    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();
    }
  }
  return t1 < t2;
}