mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-24 14:22:40 -06:00
Fixed ReSort(), DoMin/DoMax now works for dates
git-svn-id: svn://ultimatepp.org/upp/trunk@1633 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
5f584f687b
commit
2d8da64a08
3 changed files with 47 additions and 53 deletions
|
|
@ -2099,12 +2099,6 @@ void GridCtrl::LeftUp(Point p, dword keyflags)
|
|||
|
||||
if(sorting_multicol && (keyflags & K_CTRL))
|
||||
{
|
||||
if(sortCol >= 0)
|
||||
{
|
||||
sortOrder.Add(sortCol);
|
||||
sortCol = -1;
|
||||
}
|
||||
|
||||
int colidx = InMultisort(newSortCol);
|
||||
|
||||
if(colidx < 0)
|
||||
|
|
@ -2149,7 +2143,7 @@ void GridCtrl::LeftUp(Point p, dword keyflags)
|
|||
hitems[idx].sortmode = 0;
|
||||
}
|
||||
|
||||
ClearMultisort();
|
||||
ClearMultisort(1);
|
||||
hitems[j].ChangeSortMode();
|
||||
hitems[j].sortcol = 1;
|
||||
|
||||
|
|
@ -2158,7 +2152,7 @@ void GridCtrl::LeftUp(Point p, dword keyflags)
|
|||
else
|
||||
sortCol = newSortCol;
|
||||
|
||||
sortOrder.Clear();
|
||||
sortOrder.Add(newSortCol);
|
||||
|
||||
if(WhenSort)
|
||||
WhenSort();
|
||||
|
|
@ -4591,20 +4585,22 @@ void GridCtrl::SyncSummary()
|
|||
else
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
for(int j = fixed_rows; j < total_rows; j++)
|
||||
{
|
||||
if(vitems[j].IsHidden())
|
||||
continue;
|
||||
|
||||
int idy = vitems[j].id;
|
||||
|
||||
|
||||
Value v = items[idy][idx].val;
|
||||
|
||||
if(IsNull(v))
|
||||
continue;
|
||||
|
||||
++n;
|
||||
|
||||
|
||||
ProcessSummaryValue(v);
|
||||
|
||||
if(j == fixed_rows && (sop == SOP_MIN || sop == SOP_MAX))
|
||||
if(n == 0 && (sop == SOP_MIN || sop == SOP_MAX))
|
||||
t = v;
|
||||
|
||||
if(IsNumber(v))
|
||||
|
|
@ -4624,9 +4620,33 @@ void GridCtrl::SyncSummary()
|
|||
t = double(t) + double(v);
|
||||
}
|
||||
}
|
||||
else if(IsType<Date>(v))
|
||||
{
|
||||
switch(sop)
|
||||
{
|
||||
case SOP_MIN:
|
||||
if((Date) v < (Date) t)
|
||||
t = v;
|
||||
break;
|
||||
case SOP_MAX:
|
||||
if((Date) v > (Date) t)
|
||||
t = v;
|
||||
break;
|
||||
case SOP_SUM:
|
||||
case SOP_AVG:
|
||||
t = v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
++n;
|
||||
}
|
||||
|
||||
if(sop == SOP_AVG)
|
||||
t = double(t) / double(n);
|
||||
{
|
||||
if(IsNumber(t))
|
||||
t = double(t) / double(n);
|
||||
}
|
||||
}
|
||||
|
||||
summary[idx].val = t;
|
||||
|
|
|
|||
|
|
@ -1641,8 +1641,7 @@ class GridCtrl : public Ctrl
|
|||
void GSort(int col, int order, int from, int count = -1);
|
||||
void Multisort();
|
||||
int InMultisort(int col);
|
||||
bool ClearMultisort();
|
||||
bool ClearSorted();
|
||||
void ClearMultisort(int n = 0);
|
||||
bool IsSorted();
|
||||
void MarkSort(int col, int sort_mode, bool refresh);
|
||||
|
||||
|
|
|
|||
|
|
@ -119,32 +119,20 @@ int GridCtrl::InMultisort(int col)
|
|||
return -1;
|
||||
}
|
||||
|
||||
bool GridCtrl::ClearMultisort()
|
||||
void GridCtrl::ClearMultisort(int n)
|
||||
{
|
||||
if(sortOrder.IsEmpty())
|
||||
return false;
|
||||
|
||||
return ClearSorted();
|
||||
}
|
||||
|
||||
bool GridCtrl::ClearSorted()
|
||||
{
|
||||
bool sorted = false;
|
||||
|
||||
for(int i = 0; i < total_cols; i++)
|
||||
for(int i = n; i < sortOrder.GetCount(); i++)
|
||||
{
|
||||
if(hitems[i].sortMode > 0)
|
||||
sorted = true;
|
||||
hitems[i].sortmode = 0;
|
||||
hitems[i].sortcol = 0;
|
||||
int c = GetIdCol(sortOrder[i], true);
|
||||
hitems[c].sortmode = 0;
|
||||
hitems[c].sortcol = 0;
|
||||
}
|
||||
|
||||
return sorted;
|
||||
sortOrder.Clear();
|
||||
}
|
||||
|
||||
bool GridCtrl::IsSorted()
|
||||
{
|
||||
return sortOrder.GetCount() > 0 || sortCol >= 0;
|
||||
return sortOrder.GetCount() > 0;
|
||||
}
|
||||
|
||||
void GridCtrl::MarkSort(int col, int sort_mode, bool refresh)
|
||||
|
|
@ -174,10 +162,7 @@ GridCtrl& GridCtrl::Sort(int sort_col, int sort_mode, bool multisort, bool repai
|
|||
return *this;
|
||||
|
||||
if(!multisort)
|
||||
{
|
||||
sortOrder.Clear();
|
||||
ClearSorted();
|
||||
}
|
||||
ClearMultisort();
|
||||
|
||||
sortOrder.Add(col);
|
||||
|
||||
|
|
@ -228,27 +213,17 @@ Vector<Id> GridCtrl::GetSortOrderId() const
|
|||
Vector<GridCtrl::SortOrder> GridCtrl::GetSortOrder() const
|
||||
{
|
||||
Vector<SortOrder> v;
|
||||
if(sortOrder.GetCount() > 0)
|
||||
|
||||
for(int i = 0; i < sortOrder.GetCount(); i++)
|
||||
{
|
||||
for(int i = 0; i < sortOrder.GetCount(); i++)
|
||||
{
|
||||
int c = sortOrder[i];
|
||||
SortOrder& s = v.Add();
|
||||
s.id = c;
|
||||
s.name = aliases.GetKey(c);
|
||||
s.ascending = hitems[c].IsSortAsc();
|
||||
s.descending = hitems[c].IsSortDsc();
|
||||
}
|
||||
}
|
||||
else if(sortCol >= 0)
|
||||
{
|
||||
int c = sortCol;
|
||||
int c = sortOrder[i];
|
||||
SortOrder& s = v.Add();
|
||||
s.id = c;
|
||||
s.name = aliases.GetKey(c);
|
||||
s.ascending = hitems[c].IsSortAsc();
|
||||
s.descending = hitems[c].IsSortDsc();
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue