[billreminder] Renamed a couple of functions and moved record formating for dueDate to the ui and away from widget
- From: Og B. Maciel <ogmaciel src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [billreminder] Renamed a couple of functions and moved record formating for dueDate to the ui and away from widget
- Date: Tue, 29 Sep 2009 17:33:21 +0000 (UTC)
commit a54d58e751803492d2fc33b490af086a6fcb464d
Author: Og B. Maciel <ogmaciel gnome org>
Date: Tue Sep 29 12:34:33 2009 -0400
Renamed a couple of functions and moved record formating for dueDate to the ui and away from widget code.
src/gui/maindialog.py | 27 +++++++++++++++++----------
src/gui/widgets/viewbill.py | 4 ----
2 files changed, 17 insertions(+), 14 deletions(-)
---
diff --git a/src/gui/maindialog.py b/src/gui/maindialog.py
index 2f64018..c7ce655 100644
--- a/src/gui/maindialog.py
+++ b/src/gui/maindialog.py
@@ -220,7 +220,7 @@ class MainDialog:
else:
self.currentrecord = None
- def _populateTreeView(self, records):
+ def populate_view(self, records):
""" Populates the treeview control with the records passed """
# Reset list
@@ -232,9 +232,14 @@ class MainDialog:
# Loops through bills collection
path = 0
for rec in records:
- self.list.add(self._formated_row(rec))
+ # Format the record prior to adding it to treeview
+ row = self.format_row(rec)
+ self.list.add(row)
+ # Set the cursor to the first (top) record
self.list.set_cursor(path)
+
+ # Returns how many records there are in the treeview
return len(records)
def reloadTreeView(self, *arg):
@@ -254,7 +259,7 @@ class MainDialog:
records = self.actions.get_interval_bills(status, first, last)
# Populate treeview
- self._populateTreeView(records)
+ self.populate_view(records)
# Update status bar
#self._update_statusbar()
# populate chart
@@ -262,15 +267,17 @@ class MainDialog:
return len(records)
- def _formated_row(self, row):
+ def format_row(self, row):
""" Formats a bill to be displayed as a row. """
+ categoryName = len(row.category) and row.category[0].name or _('None')
+ categoryColor = len(row.category) and row.category[0].color or '#000'
formatted = [
row.id,
- create_pixbuf(color="#000"),
- len(row.category) > 0 and row.category[0] or '',
+ create_pixbuf(color=categoryColor),
+ categoryName,
row.payee,
- row.dueDate,
+ row.dueDate.strftime(_('%m/%d').encode('ASCII')),
row.amount,
row.notes,
row.paid,
@@ -381,7 +388,7 @@ class MainDialog:
for rec in records:
bill = self.actions.add_bill(rec.Dictionary)
if bill:
- self.list.add(self._formated_row(bill))
+ self.list.add(self.format_row(bill))
self._update_statusbar()
# Reload records tree (something changed)
self.reloadTreeView()
@@ -400,7 +407,7 @@ class MainDialog:
# Update list with updated record
idx = self.list.get_cursor()[0][0]
self.list.listStore[idx] = \
- self._formated_row(rec.Dictionary)
+ self.format_row(rec.Dictionary)
self._update_statusbar(idx)
except Exception, e:
print str(e)
@@ -427,7 +434,7 @@ class MainDialog:
# Update list with updated record
idx = self.list.get_cursor()[0][0]
self.list.listStore[idx] = \
- self._formated_row(self.currentrecord.Dictionary)
+ self.format_row(self.currentrecord.Dictionary)
self._update_statusbar(idx)
except Exception, e:
print str(e)
diff --git a/src/gui/widgets/viewbill.py b/src/gui/widgets/viewbill.py
index e4f9333..086b941 100644
--- a/src/gui/widgets/viewbill.py
+++ b/src/gui/widgets/viewbill.py
@@ -40,10 +40,6 @@ class ViewBill(GenericListView):
def duedate_cell_data_function(self, column, cell, model, iter):
dueDate = model.get_value (iter, 4)
- # Format the dueDate field
- #dueDate = datetime.datetime.fromtimestamp(dueDate)
- # TRANSLATORS: This is a date format. You can change the order.
- #dueDate = dueDate.strftime(_('%m/%d').encode('ASCII'))
cell.set_property('text', dueDate)
cell.set_property('xalign', 0.5)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]