Skip to content

Commit

Permalink
Faster sorting of custom data in the tables.
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriySalnikov committed Jan 2, 2025
1 parent ff9003e commit be33f65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions Explorer/UI/Forms/CreatePCKFile.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.IO;
using System.Security.Cryptography;

namespace GodotPCKExplorer.UI
namespace GodotPCKExplorer.UI
{
public partial class CreatePCKFile : Form
{
Expand Down Expand Up @@ -207,7 +204,7 @@ void UpdateTableContent()
tmpRow.Cells.Add(new DataGridViewTextBoxCell() { Value = $"{Utils.SizeSuffix(orig_file.Size)} -> {Utils.SizeSuffix(f.Value.Size)}", Tag = f.Value.Size, Style = current_styleRealFileSize });
else
tmpRow.Cells.Add(new DataGridViewTextBoxCell() { Value = Utils.SizeSuffix(f.Value.Size), Tag = f.Value.Size, Style = current_styleRealFileSize });
tmpRow.Cells.Add(new DataGridViewTextBoxCell() { Value = "*", Tag = false });
tmpRow.Cells.Add(new DataGridViewTextBoxCell() { Value = "*", Tag = true });
}
else
{
Expand Down Expand Up @@ -332,14 +329,22 @@ private void btn_create_Click(object? sender, EventArgs e)

private void dataGridView1_SortCompare(object? sender, DataGridViewSortCompareEventArgs e)
{
if (e.Column.Index != 1)
if (e.Column.Index != 1 && e.Column.Index != 2)
{
e.Handled = false;
return;
}

e.SortResult = (long)(dataGridView1.Rows[e.RowIndex1].Cells[1].Tag) > (long)(dataGridView1.Rows[e.RowIndex2].Cells[1].Tag) ? 1 : -1;
e.Handled = true;
if (e.Column.Index == 1)
{
e.SortResult = ((long)(dataGridView1.Rows[e.RowIndex1].Cells[1].Tag)).CompareTo((long)(dataGridView1.Rows[e.RowIndex2].Cells[1].Tag));
e.Handled = true;
}
else if (e.Column.Index == 2)
{
e.SortResult = ((bool)(dataGridView1.Rows[e.RowIndex1].Cells[2].Tag)).CompareTo((bool)(dataGridView1.Rows[e.RowIndex2].Cells[2].Tag));
e.Handled = true;
}
}

private void tb_folder_path_KeyDown(object? sender, KeyEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion Explorer/UI/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ private void dataGridView1_SortCompare(object? sender, DataGridViewSortCompareEv
return;
}

e.SortResult = (long)(dataGridView1.Rows[e.RowIndex1].Cells[2].Tag) > (long)(dataGridView1.Rows[e.RowIndex2].Cells[2].Tag) ? 1 : -1;
e.SortResult = ((long)(dataGridView1.Rows[e.RowIndex1].Cells[2].Tag)).CompareTo((long)(dataGridView1.Rows[e.RowIndex2].Cells[2].Tag));
e.Handled = true;
}

Expand Down

0 comments on commit be33f65

Please sign in to comment.