- Improvements to backwards compatibility. PyQSO now adds a column with the field name to the database if it doesn't already exist. All entries are initially set to NULL. This prevents problems when the ListStore expects the column names to all be in AVAILABLE_FIELD_NAMES.

- Added a TODO file.
pull/17/head
Christian Jacobs 2013-07-04 23:04:31 +01:00
rodzic 1aaae548f1
commit 5cada62d02
3 zmienionych plików z 30 dodań i 3 usunięć

7
TODO 100644
Wyświetl plik

@ -0,0 +1,7 @@
- Log printing
- Backwards compatibility (e.g. if the number of columns changes then copy over the contents of the database into a new database with the additional/removed columns)
- Lookup via qrz.com
- Hamlib support
- Additional field names, particularly for the "station information" frame.
- Finish manual

Wyświetl plik

@ -43,8 +43,25 @@ class Log(Gtk.ListStore):
logging.debug("New Log instance created!")
def enforce_table_consistency(self):
''' Checks whether each field name in AVAILABLE_FIELD_NAMES_ORDERED is in the database. If not, PyQSO will add it
(with all entries being set to NULL initially). '''
with(self.connection):
c = self.connection.cursor()
for field_name in AVAILABLE_FIELD_NAMES_ORDERED:
try:
# Tries to add a column, regardless of whether it already exists or not.
# If an error occurs, then PyQSO just continues onto the next field name without doing anything.
# FIXME: The error will (hopefully) be caused by the column name already existing. But in the case of a different error,
# a better solution should be implemented here.
c.execute('ALTER TABLE %s ADD COLUMN %s' % (self.name, field_name.lower()))
except:
pass # Column already exists, so don't do anything.
return
def populate(self):
# Remove everything that is rendered already and start afresh
self.enforce_table_consistency()
self.clear()
records = self.get_all_records()
for r in records:

Wyświetl plik

@ -193,12 +193,15 @@ class RecordDialog(Gtk.Dialog):
record = log.get_record_by_index(index)
field_names = AVAILABLE_FIELD_NAMES_ORDERED
for i in range(0, len(field_names)):
data = record[field_names[i].lower()]
if(data is None):
data = ""
if(field_names[i] == "BAND"):
self.sources[field_names[i]].set_active(bands.index(record[field_names[i].lower()]))
self.sources[field_names[i]].set_active(bands.index(data))
elif(field_names[i] == "MODE"):
self.sources[field_names[i]].set_active(modes.index(record[field_names[i].lower()]))
self.sources[field_names[i]].set_active(modes.index(data))
else:
self.sources[field_names[i]].set_text(record[field_names[i].lower()])
self.sources[field_names[i]].set_text(data)
self.show_all()