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

View File

@ -114,3 +114,13 @@ class YahooAuctionsItem:
def ending_in(self):
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}"