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; using System.Text.Json;
namespace Buypeeb { namespace Buypeeb {
class Listing { class YahooAuctionsItem {
public string url { public string url {
get { get {
return $"https://page.auctions.yahoo.co.jp/jp/auction/{this.id}"; 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 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.id = id;
this.name = name; this.name = name;
this.ready = false; this.ready = false;
} }
public Listing() { public YahooAuctionsItem() {
// parameterless constructor for deserialisation // parameterless constructor for deserialisation
} }

View file

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

View file

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