Correct sorting order for doubles and wxDateTime in wxDataViewModel.
They were compared inconsistently with the numbers and strings, -1 is supposed to be returned if the first element is less than the second one, not 1. Closes #15406. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74949 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -330,27 +330,28 @@ int wxDataViewModel::Compare( const wxDataViewItem &item1, const wxDataViewItem
|
|||||||
{
|
{
|
||||||
long l1 = value1.GetLong();
|
long l1 = value1.GetLong();
|
||||||
long l2 = value2.GetLong();
|
long l2 = value2.GetLong();
|
||||||
long res = l1-l2;
|
if (l1 < l2)
|
||||||
if (res)
|
return -1;
|
||||||
return res;
|
else if (l1 > l2)
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
else if (value1.GetType() == wxT("double"))
|
else if (value1.GetType() == wxT("double"))
|
||||||
{
|
{
|
||||||
double d1 = value1.GetDouble();
|
double d1 = value1.GetDouble();
|
||||||
double d2 = value2.GetDouble();
|
double d2 = value2.GetDouble();
|
||||||
if (d1 < d2)
|
if (d1 < d2)
|
||||||
return 1;
|
|
||||||
if (d1 > d2)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
else if (d1 > d2)
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
else if (value1.GetType() == wxT("datetime"))
|
else if (value1.GetType() == wxT("datetime"))
|
||||||
{
|
{
|
||||||
wxDateTime dt1 = value1.GetDateTime();
|
wxDateTime dt1 = value1.GetDateTime();
|
||||||
wxDateTime dt2 = value2.GetDateTime();
|
wxDateTime dt2 = value2.GetDateTime();
|
||||||
if (dt1.IsEarlierThan(dt2))
|
if (dt1.IsEarlierThan(dt2))
|
||||||
return 1;
|
|
||||||
if (dt2.IsEarlierThan(dt1))
|
|
||||||
return -1;
|
return -1;
|
||||||
|
if (dt2.IsEarlierThan(dt1))
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
else if (value1.GetType() == wxT("bool"))
|
else if (value1.GetType() == wxT("bool"))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user