kopia lustrzana https://github.com/ctjacobs/pyqso
Added DXCC award tracking functionality.
rodzic
0520be3a6f
commit
10d7d4e662
3
TODO
3
TODO
|
@ -1,4 +1,3 @@
|
|||
- Finish manual
|
||||
- Awards
|
||||
- More error handling
|
||||
|
||||
- Duplicate entry checking and removal
|
||||
|
|
|
@ -24,14 +24,73 @@ import logging
|
|||
class Awards(Gtk.VBox):
|
||||
|
||||
def __init__(self, parent):
|
||||
#TODO: This only considers the DXCC award for now.
|
||||
logging.debug("New Awards instance created!")
|
||||
|
||||
Gtk.VBox.__init__(self, spacing=2)
|
||||
|
||||
self.parent = parent
|
||||
|
||||
self.bands = ["70cm", "2m", "6m", "10m", "12m", "15m", "17m", "20m", "30m", "40m", "80m", "160m"]
|
||||
self.modes = ["Phone", "CW", "Digital", "Mixed"]
|
||||
|
||||
data_types = [str] + [int]*len(self.bands)
|
||||
self.awards = Gtk.ListStore(*data_types)
|
||||
|
||||
# The main table for the awards
|
||||
self.treeview = Gtk.TreeView(self.awards)
|
||||
# A separate, empty column just for the mode names
|
||||
renderer = Gtk.CellRendererText()
|
||||
column = Gtk.TreeViewColumn("Modes", renderer, text=0)
|
||||
column.set_clickable(False)
|
||||
self.treeview.append_column(column)
|
||||
# Now for all the bands...
|
||||
logging.debug("Initialising the columns in the awards table.")
|
||||
for i in range(0, len(self.bands)):
|
||||
renderer = Gtk.CellRendererText()
|
||||
column = Gtk.TreeViewColumn(self.bands[i], renderer, text=i+1)
|
||||
column.set_min_width(40)
|
||||
column.set_clickable(False)
|
||||
self.treeview.append_column(column)
|
||||
|
||||
# Add a label to inform the user that this only considers the DXCC award for now.
|
||||
label = Gtk.Label(halign=Gtk.Align.START)
|
||||
label.set_markup("<span size=\"x-large\">%s</span>" % "DXCC Award")
|
||||
self.pack_start(label, False, False, 4)
|
||||
# Show the table in the Awards tab
|
||||
self.add(self.treeview)
|
||||
self.show_all()
|
||||
|
||||
self.count()
|
||||
|
||||
return
|
||||
|
||||
def count(self):
|
||||
logging.debug("Counting the band/mode combinations for the awards table.")
|
||||
# Wipe everything and start again
|
||||
self.awards.clear()
|
||||
# For each mode, add a new list for holding the totals, and initialise the values to zero.
|
||||
count = []
|
||||
for i in range(0, len(self.bands)):
|
||||
count.append([0]*len(self.bands))
|
||||
|
||||
for log in self.parent.logbook.logs:
|
||||
records = log.get_all_records()
|
||||
for r in records:
|
||||
if(r["BAND"] != "" and r["MODE"] != ""):
|
||||
band = self.bands.index(r["BAND"])
|
||||
# Phone modes
|
||||
if(r["MODE"].upper() in ["FM", "AM", "SSB", "SSTV"]):
|
||||
count[0][band] += 1
|
||||
elif(r["MODE"].upper() == "CW"):
|
||||
count[1][band] += 1
|
||||
else:
|
||||
#FIXME: This assumes that all the other modes in the ADIF list are digital modes. Is this the case?
|
||||
count[2][band] += 1
|
||||
count[3][band] += 1 # Keep the total of each column in the "Mixed" mode
|
||||
|
||||
# Insert the rows containing the totals
|
||||
for i in range(0, len(self.modes)):
|
||||
self.awards.append([self.modes[i]] + count[i])
|
||||
return
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ class Logbook(Gtk.Notebook):
|
|||
self.parent = parent
|
||||
self.connection = None
|
||||
self.summary = {}
|
||||
self.logs = []
|
||||
|
||||
logging.debug("New Logbook instance created!")
|
||||
|
||||
|
@ -277,6 +278,7 @@ class Logbook(Gtk.Notebook):
|
|||
self.render_log(self.get_number_of_logs()-1)
|
||||
|
||||
self._update_summary()
|
||||
self.parent.toolbox.awards.count()
|
||||
return
|
||||
|
||||
def delete_log(self, widget, page=None):
|
||||
|
@ -318,6 +320,7 @@ class Logbook(Gtk.Notebook):
|
|||
self.remove_page(page_index)
|
||||
|
||||
self._update_summary()
|
||||
self.parent.toolbox.awards.count()
|
||||
return
|
||||
|
||||
def filter_log(self, widget, callsign):
|
||||
|
@ -564,6 +567,7 @@ class Logbook(Gtk.Notebook):
|
|||
self.logs.append(l)
|
||||
self.render_log(self.get_number_of_logs()-1)
|
||||
self._update_summary()
|
||||
self.parent.toolbox.awards.count()
|
||||
|
||||
return
|
||||
|
||||
|
@ -692,6 +696,7 @@ class Logbook(Gtk.Notebook):
|
|||
# All data has been validated, so we can go ahead and add the new record.
|
||||
log.add_record(fields_and_data)
|
||||
self._update_summary()
|
||||
self.parent.toolbox.awards.count()
|
||||
# Select the new Record's row in the treeview.
|
||||
self.treeselection[log_index].select_path(log.get_number_of_records())
|
||||
|
||||
|
@ -720,6 +725,7 @@ class Logbook(Gtk.Notebook):
|
|||
# 'iter' is needed to remove the record from the ListStore itself.
|
||||
log.delete_record(row_index, child_iter)
|
||||
self._update_summary()
|
||||
self.parent.toolbox.awards.count()
|
||||
return
|
||||
|
||||
def edit_record_callback(self, widget, path, view_column):
|
||||
|
@ -773,6 +779,7 @@ class Logbook(Gtk.Notebook):
|
|||
# (we add 1 onto the column_index here because we don't want to consider the index column)
|
||||
log.set(child_iter, i+1, fields_and_data[field_names[i]])
|
||||
self._update_summary()
|
||||
self.parent.toolbox.awards.count()
|
||||
|
||||
dialog.destroy()
|
||||
return
|
||||
|
|
Ładowanie…
Reference in New Issue