don't redraw the whole list after a rename

This commit is contained in:
Lynne Megido 2020-08-23 22:59:56 +10:00
parent 6c5a93b0d8
commit 1fd1fb21d0
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90
2 changed files with 25 additions and 13 deletions

View file

@ -167,18 +167,20 @@ class BuypeebApp:
self.updateListTimes() self.updateListTimes()
def updateListTimes(self): def updateListItem(self, id: str):
now = datetime.now() item = self.settings.watchlist[id]
ndate = now.strftime("%d %b")
for listing in self.items: for listing in self.items:
id = listing[3] if listing[3] == id:
item = self.settings.watchlist[id] treeIter = Gtk.TreeModel.get_iter(self.items, listing.path)
if item.end_date != None: self.items.set(treeIter, 0, item.name)
idate, itime = item.end_date.strftime("%d %b"), item.end_date.strftime("%H:%M") self.items.set(treeIter, 1, item.price_aud())
if idate == ndate: self.items.set(treeIter, 2, item.ending_at())
listing[2] = itime
else:
listing[2] = f"{idate} {itime}" def updateListTimes(self):
for listing in self.items:
item = self.settings.watchlist[listing[3]]
listing[2] = item.ending_at()
def updateSidePane(self, id: str): def updateSidePane(self, id: str):
item = self.settings.watchlist[id] item = self.settings.watchlist[id]
@ -188,7 +190,7 @@ class BuypeebApp:
"Price": item.price_jpy(), "Price": item.price_jpy(),
"PriceAUD": item.price_aud(), "PriceAUD": item.price_aud(),
"Ending": item.ending_in(), "Ending": item.ending_in(),
"Bids": item.bids "Bids": str(item.bids)
} }
for label, contents in info.items(): for label, contents in info.items():
@ -251,7 +253,7 @@ class BuypeebApp:
if name: if name:
item.name = name item.name = name
self.renderList() # TODO: only update the changed item self.updateListItem(item.id)
def btnSelectedRemoveClicked(self, widget): def btnSelectedRemoveClicked(self, widget):
del self.settings.watchlist[self.selected] del self.settings.watchlist[self.selected]

View file

@ -114,3 +114,13 @@ class YahooAuctionsItem:
def ending_in(self): def ending_in(self):
return "heenlo" return "heenlo"
def ending_at(self):
now = datetime.now()
ndate = now.strftime("%d %b")
if self.end_date != None:
idate, itime = self.end_date.strftime("%d %b"), self.end_date.strftime("%H:%M")
if idate == ndate:
return itime
else:
return f"{idate} {itime}"