it makes more sense to call them "YahooAuctionsItem"s rather than "Listing"s because i always use variable names like "item" or "SelectedItem" for them

This commit is contained in:
Lynne Megido 2020-09-04 19:13:16 +10:00
parent 11020ed0c4
commit 9ad7e4f288
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90
3 changed files with 15 additions and 15 deletions

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Text.Json;
namespace Buypeeb {
class Listing {
class YahooAuctionsItem {
public string url {
get {
return $"https://page.auctions.yahoo.co.jp/jp/auction/{this.id}";
@ -31,13 +31,13 @@ namespace Buypeeb {
private bool success { get; set; } // TODO: custom setter that throws an exception if set to false or something idk
public Listing(string id, string name) {
public YahooAuctionsItem(string id, string name) {
this.id = id;
this.name = name;
this.ready = false;
}
public Listing() {
public YahooAuctionsItem() {
// parameterless constructor for deserialisation
}

View File

@ -52,10 +52,10 @@ namespace Buypeeb {
static SemaphoreSlim tasklimit = new SemaphoreSlim(4);
private Listing SelectedItem {
private YahooAuctionsItem SelectedItem {
get {
this.itemTreeView.Selection.GetSelected(out TreeIter iter);
return (Listing)this.itemTreeView.Model.GetValue(iter, 0);
return (YahooAuctionsItem)this.itemTreeView.Model.GetValue(iter, 0);
}
}
@ -97,7 +97,7 @@ namespace Buypeeb {
// bind treeview columns to watchlist instead of needing to manually sync its liststore
this.itemTreeView = (TreeView)builder.GetObject("TreeViewItems");
this.items = new ListStore(typeof(Listing));
this.items = new ListStore(typeof(YahooAuctionsItem));
this.RenderList();
this.itemTreeView.Model = this.items;
@ -136,7 +136,7 @@ namespace Buypeeb {
this.itemTreeView.Model.GetIterFirst(out iter);
for (int i = 0; i < this.itemTreeView.Model.IterNChildren(); i++) {
var x = (Listing)this.itemTreeView.Model.GetValue(iter, 0);
var x = (YahooAuctionsItem)this.itemTreeView.Model.GetValue(iter, 0);
if (x.id == id) {
return (this.itemTreeView.Model.GetPath(iter), iter);
}
@ -413,22 +413,22 @@ namespace Buypeeb {
// column renderers
private void RenderColumnName(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.ITreeModel model, Gtk.TreeIter iter) {
Listing item = (Listing)model.GetValue(iter, 0);
YahooAuctionsItem item = (YahooAuctionsItem)model.GetValue(iter, 0);
(cell as Gtk.CellRendererText).Text = item.name ?? "Loading...";
}
private void RenderColumnPriceYen(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.ITreeModel model, Gtk.TreeIter iter) {
Listing item = (Listing)model.GetValue(iter, 0);
YahooAuctionsItem item = (YahooAuctionsItem)model.GetValue(iter, 0);
(cell as Gtk.CellRendererText).Text = item.ready ? item.PriceJPY() : "...";
}
private void RenderColumnPriceAUD(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.ITreeModel model, Gtk.TreeIter iter) {
Listing item = (Listing)model.GetValue(iter, 0);
YahooAuctionsItem item = (YahooAuctionsItem)model.GetValue(iter, 0);
(cell as Gtk.CellRendererText).Text = item.ready ? item.PriceAUD() : "...";
}
private void RenderColumnEnding(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.ITreeModel model, Gtk.TreeIter iter) {
Listing item = (Listing)model.GetValue(iter, 0);
YahooAuctionsItem item = (YahooAuctionsItem)model.GetValue(iter, 0);
(cell as Gtk.CellRendererText).Text = item.ready ? "whatever" : "...";
}

View File

@ -9,14 +9,14 @@ namespace Buypeeb {
public int updateIntervalCritical { get; set; } = 60;
public int favouriteUpdateIntervalCritical { get; set; } = 30;
public Dictionary<string, Listing> watchlist {
public Dictionary<string, YahooAuctionsItem> watchlist {
get; set;
}
public Settings() {
if (this.watchlist == null) {
// either this is the first time the program has been run, or there's something wrong with userdata.json
this.watchlist = new Dictionary<string, Listing>();
this.watchlist = new Dictionary<string, YahooAuctionsItem>();
// this.Watch("https://buypeeb.biz/whatever/k12345", "my thingy");
// this.Watch("https://buypeeb.biz/whatever/z09876", "your thingy");
// this.Watch("https://buypeeb.biz/whatever/h55555", "our thingy");
@ -28,10 +28,10 @@ namespace Buypeeb {
}
public Listing Watch(string url, string name) {
public YahooAuctionsItem Watch(string url, string name) {
string id = BuypeebApp.IDFromURL(url);
Console.WriteLine(id);
this.watchlist[id] = new Listing(id, name);
this.watchlist[id] = new YahooAuctionsItem(id, name);
return this.watchlist[id];
}
}