|
Quantum GIS API Documentation
master-4435c4f
|
00001 /*************************************************************************** 00002 QgsAttributeTableIdColumnPair.cpp 00003 -------------------------------------- 00004 Date : Feb 2009 00005 Copyright : (C) 2009 Vita Cizek 00006 Email : weetya (at) gmail.com 00007 *************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 ***************************************************************************/ 00015 00016 #include "qgsattributetableidcolumnpair.h" 00017 #include "qgsfield.h" 00018 00019 #include <QVariant> 00020 00021 //could be faster when type guessed before sorting 00022 bool QgsAttributeTableIdColumnPair::operator<( const QgsAttributeTableIdColumnPair &b ) const 00023 { 00024 //QVariant thinks gid is a string! 00025 QVariant::Type columnType = mItem.type(); 00026 00027 if ( mItem.isNull() ) 00028 return 1; 00029 00030 if ( b.mItem.isNull() ) 00031 return 0; 00032 00033 switch ( columnType ) 00034 { 00035 case QVariant::Int: 00036 case QVariant::UInt: 00037 case QVariant::LongLong: 00038 case QVariant::ULongLong: 00039 return mItem.toLongLong() < b.mItem.toLongLong(); 00040 00041 case QVariant::Double: 00042 return mItem.toDouble() < b.mItem.toDouble(); 00043 00044 default: 00045 return mItem.toString().localeAwareCompare( b.mItem.toString() ) < 0; 00046 } 00047 }