Skip to content

Commit

Permalink
Fix GUI sort by size
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Feb 24, 2018
1 parent 9712f94 commit 88ee738
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions GUI/MainModList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ private IEnumerable<DataGridViewRow> _SortRowsByColumn(IEnumerable<DataGridViewR
{
return Sort(rows, CheckboxSorter);
}
// XXX: Same for Integer columns
else if (this.configuration.SortByColumnIndex == 7)
{
return Sort(rows, IntegerSorter);
return Sort(rows, DownloadSizeSorter);
}
return Sort(rows, DefaultSorter);
}
Expand Down Expand Up @@ -78,22 +77,12 @@ private string CheckboxSorter(DataGridViewRow row)
}

/// <summary>
/// Transforms a DataGridViewRow into an integer suitable for sorting.
/// Uses this.m_Configuration.SortByColumnIndex to determine which
/// field to sort on.
/// Transforms a DataGridViewRow into a long representing the download size,
/// suitable for sorting.
/// </summary>
private int IntegerSorter(DataGridViewRow row)
private long DownloadSizeSorter(DataGridViewRow row)
{
var cell = row.Cells[this.configuration.SortByColumnIndex];

if (cell.Value.ToString() == "N/A")
return -1;
else if (cell.Value.ToString() == "1<KB")
return 0;

int result = -2;
int.TryParse(cell.Value as string, out result);
return result;
return (row.Tag as GUIMod)?.ToCkanModule()?.download_size ?? 0;
}

private void _UpdateFilters()
Expand Down

0 comments on commit 88ee738

Please sign in to comment.