Skip to content

Commit

Permalink
Include the total number of QSOs in the Summary page. Addresses issue #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Jacobs committed Apr 2, 2015
1 parent 141e920 commit 233b996
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions pyqso/logbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,21 +241,28 @@ def _create_summary_page(self):
label = Gtk.Label(halign=Gtk.Align.START)
label.set_markup("<span size=\"x-large\">%s</span>" % basename(self.path))
hbox.pack_start(label, False, False, 6)
vbox.pack_start(hbox, False, False, 2)
vbox.pack_start(hbox, False, False, 4)

hbox = Gtk.HBox()
label = Gtk.Label("Number of logs: ", halign=Gtk.Align.START)
hbox.pack_start(label, False, False, 6)
self.summary["NUMBER_OF_LOGS"] = Gtk.Label("0")
hbox.pack_start(self.summary["NUMBER_OF_LOGS"], False, False, 2)
vbox.pack_start(hbox, False, False, 2)
self.summary["LOG_COUNT"] = Gtk.Label("0")
hbox.pack_start(self.summary["LOG_COUNT"], False, False, 4)
vbox.pack_start(hbox, False, False, 4)

hbox = Gtk.HBox()
label = Gtk.Label("Total number of QSOs: ", halign=Gtk.Align.START)
hbox.pack_start(label, False, False, 6)
self.summary["QSO_COUNT"] = Gtk.Label("0")
hbox.pack_start(self.summary["QSO_COUNT"], False, False, 4)
vbox.pack_start(hbox, False, False, 4)

hbox = Gtk.HBox()
label = Gtk.Label("Date modified: ", halign=Gtk.Align.START)
hbox.pack_start(label, False, False, 6)
self.summary["DATE_MODIFIED"] = Gtk.Label("0")
hbox.pack_start(self.summary["DATE_MODIFIED"], False, False, 2)
vbox.pack_start(hbox, False, False, 2)
hbox.pack_start(self.summary["DATE_MODIFIED"], False, False, 4)
vbox.pack_start(hbox, False, False, 4)

hbox = Gtk.HBox(False, 0)
label = Gtk.Label("Summary ")
Expand All @@ -271,7 +278,8 @@ def _create_summary_page(self):

def update_summary(self):
""" Update the information presented on the summary page. """
self.summary["NUMBER_OF_LOGS"].set_label(str(self.get_number_of_logs()))
self.summary["LOG_COUNT"].set_label(str(self.get_number_of_logs()))
self.summary["QSO_COUNT"].set_label(str(self.get_number_of_qsos()))
try:
t = datetime.fromtimestamp(getmtime(self.path)).strftime("%d %B %Y @ %H:%M")
self.summary["DATE_MODIFIED"].set_label(str(t))
Expand Down Expand Up @@ -956,6 +964,13 @@ def remove_duplicates_callback(self, widget=None):
def get_number_of_logs(self):
""" Return the total number of logs in the logbook. """
return len(self.logs)

def get_number_of_qsos(self):
""" Return the total number of QSOs/records in the whole logbook. """
total = 0
for log in self.logs:
total += log.get_number_of_records()
return total

def log_name_exists(self, table_name):
""" Return True if the log name already exists in the logbook, and False if it does not already exist. Return None if there is a database error. """
Expand Down

0 comments on commit 233b996

Please sign in to comment.