QtSortedCheckListItem.cxx
Go to the documentation of this file.
1 
17 #include "QtSortedCheckListItem.h"
18 
19 #include <cstdlib>
20 
21 using namespace hippodraw;
22 
24 #if QT_VERSION < 0x040000
25 QtSortedCheckListItem ( QListView * parent, const QString & text ):
26  QCheckListItem ( parent, text, CheckBox )
27 #else
28 QtSortedCheckListItem ( Q3ListView * parent, const QString & text ):
29  Q3CheckListItem ( parent, text, CheckBox )
30 #endif
31 {
32 }
33 
34 int
36 #if QT_VERSION < 0x040000
37 compare ( QListViewItem *i, int col, bool ascending ) const
38 #else
39 compare ( Q3ListViewItem *i, int col, bool ascending ) const
40 #endif
41 {
42  int retVal;
43 
44  // Column 1 is names of data fields (text).
45  if ( col == 1 ) {
46 #if QT_VERSION < 0x040000
47  retVal = QCheckListItem::compare ( i, col, ascending );
48 #else
49  retVal = Q3CheckListItem::compare ( i, col, ascending );
50 #endif
51  }
52 
53  else {
54  double a = std::atof ( key ( col, ascending ) );
55  double b = std::atof ( i -> key ( col, ascending ) );
56  if ( a < b )
57  retVal = -1;
58  else if ( a > b )
59  retVal = 1;
60  else
61  retVal = 0;
62  }
63 
64  return retVal;
65 }
66 

Generated for HippoDraw Class Library by doxygen