00001
00017 #include "QtSortedCheckListItem.h"
00018
00019 #include <cstdlib>
00020
00021 using namespace hippodraw;
00022
00023 QtSortedCheckListItem::
00024 #if QT_VERSION < 0x040000
00025 QtSortedCheckListItem ( QListView * parent, const QString & text ):
00026 QCheckListItem ( parent, text, CheckBox )
00027 #else
00028 QtSortedCheckListItem ( Q3ListView * parent, const QString & text ):
00029 Q3CheckListItem ( parent, text, CheckBox )
00030 #endif
00031 {
00032 }
00033
00034 int
00035 QtSortedCheckListItem::
00036 #if QT_VERSION < 0x040000
00037 compare ( QListViewItem *i, int col, bool ascending ) const
00038 #else
00039 compare ( Q3ListViewItem *i, int col, bool ascending ) const
00040 #endif
00041 {
00042 int retVal;
00043
00044
00045 if ( col == 1 ) {
00046 #if QT_VERSION < 0x040000
00047 retVal = QCheckListItem::compare ( i, col, ascending );
00048 #else
00049 retVal = Q3CheckListItem::compare ( i, col, ascending );
00050 #endif
00051 }
00052
00053 else {
00054 double a = std::atof ( key ( col, ascending ) );
00055 double b = std::atof ( i -> key ( col, ascending ) );
00056 if ( a < b )
00057 retVal = -1;
00058 else if ( a > b )
00059 retVal = 1;
00060 else
00061 retVal = 0;
00062 }
00063
00064 return retVal;
00065 }
00066