Skip to content

Commit

Permalink
Misc: Sort collections in alphabetical order by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotrekol committed Jun 2, 2022
1 parent f7fc863 commit a9359ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CollectionManagerDll/DataTypes/Collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class Collection : IEnumerable, ICollection
/// </summary>
public Beatmaps KnownBeatmaps { get; } = new Beatmaps();


public override string ToString() => $"osu! map Collection: \"{Name}\" Count: {BeatmapHashes.Count}";

/// <summary>
/// Total number of beatmaps contained in this collection
Expand Down
15 changes: 9 additions & 6 deletions GuiComponents/Controls/CollectionListingView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public partial class CollectionListingView : UserControl, ICollectionListingView
{
public event GuiHelpers.LoadFileArgs OnLoadFile;
public event GuiHelpers.CollectionReorderEventArgs OnCollectionReorder;

public string SearchText => textBox_collectionNameSearch.Text;
public Collections Collections
{
Expand Down Expand Up @@ -61,6 +60,10 @@ public Collections HighlightedCollections
public event GuiHelpers.CollectionBeatmapsEventArgs BeatmapsDropped;
public event EventHandler<StringEventArgs> RightClick;

private CollectionRenderer _collectionRenderer = new CollectionRenderer();
private RearrangingDropSink _dropsink = new RearrangingDropSink();
private OLVColumn NameColumn;

public CollectionListingView()
{
InitializeComponent();
Expand All @@ -83,9 +86,6 @@ private void Bind()

}

private CollectionRenderer _collectionRenderer = new CollectionRenderer();
private RearrangingDropSink _dropsink = new RearrangingDropSink();

private void init()
{
//ListViewCollections.SelectedIndexChanged += ListViewCollectionsSelectedIndexChanged;
Expand All @@ -94,6 +94,8 @@ private void init()
ListViewCollections.HideSelection = false;
ListViewCollections.DefaultRenderer = _collectionRenderer;
ListViewCollections.IsSimpleDragSource = true;
ListViewCollections.PrimarySortColumn = NameColumn = ListViewCollections.AllColumns[0];
ListViewCollections.PrimarySortOrder = SortOrder.Ascending;

_dropsink.CanDropBetween = true;
_dropsink.CanDropOnItem = true;
Expand Down Expand Up @@ -189,18 +191,19 @@ protected virtual void OnSelectedCollectionChanged()
{
SelectedCollectionChanged?.Invoke(this, EventArgs.Empty);
}

protected virtual void OnSelectedCollectionsChanged()
{
SelectedCollectionsChanged?.Invoke(this, EventArgs.Empty);
}

private void ListViewCollections_ModelDropped(object sender, ModelDropEventArgs e)
{
e.Handled = true;
var targetCollection = (Collection)e.TargetModel;
if (e.SourceModels[0] is Collection)
{
var nameColumn = ListViewCollections.AllColumns[0];
if (ListViewCollections.LastSortColumn != nameColumn || ListViewCollections.LastSortOrder != SortOrder.Ascending)
if (ListViewCollections.LastSortColumn != NameColumn || ListViewCollections.LastSortOrder != SortOrder.Ascending)
ListViewCollections.Sort(ListViewCollections.AllColumns[0], SortOrder.Ascending);

var collections = new Collections();
Expand Down

0 comments on commit a9359ff

Please sign in to comment.