automatically sort new items, try to always reselect your item after RenderList

This commit is contained in:
Lynne Megido 2020-09-06 15:41:14 +10:00
parent ef39809d13
commit 5103ff4241
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90

View File

@ -285,7 +285,9 @@ namespace Buypeeb {
}).ContinueWith(task => {
taskLimit.Release();
if (renderListWhenDone) {
this.RenderList();
Gtk.Application.Invoke(delegate {
this.RenderList();
});
}
});
}
@ -440,6 +442,11 @@ namespace Buypeeb {
}
private void RenderList() {
string id = null;
if (this.selectedItem != null) {
id = this.selectedItem.id;
}
this.items.Clear();
var values = this.settings.watchlist.Values;
IOrderedEnumerable<YahooAuctionsItem> sorted;
@ -480,6 +487,14 @@ namespace Buypeeb {
var m = (TreeModelFilter)this.itemTreeView.Model;
m.Refilter();
if (id != null) {
// attempt to reselect the item we were just looking at
var pathAndIter = this.GetRow(id);
if (pathAndIter.path != null) {
this.itemTreeView.Selection.SelectPath(pathAndIter.path);
}
}
}
// event handlers
@ -729,11 +744,7 @@ namespace Buypeeb {
if (this.settings.displayFavouritesAtTopOfList) {
var id = this.selectedItem.id;
// re-render the list, to ensure the favourites get pushed to the top
this.RenderList();
// attempt to reselect the item we were just looking at
var pathAndIter = this.GetRow(id);
this.itemTreeView.Selection.SelectPath(pathAndIter.path);
}
else {
// i don't know why this is necessary