Skip to content

Commit 7b88dda

Browse files
committed
Add tooltips for DXCC entities in the DXCC table and improve data loading
1 parent ef63b8d commit 7b88dda

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

not1mm/__main__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4513,7 +4513,6 @@ def poll_radio(self, the_dict):
45134513
"""
45144514
# This section has nothing to do with polling the radio
45154515
# It's here because it gets called often enough to be useful.
4516-
print("weeee")
45174516
if self.auto_cq is True:
45184517
now = datetime.datetime.now()
45194518
total_duration = self.auto_cq_time - self.auto_cq_then

not1mm/dxcc_tracker.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from not1mm.lib.database import DataBase
99
import os
1010
from json import loads
11+
from json.decoder import JSONDecodeError
1112

1213
import logging
1314

@@ -16,6 +17,7 @@
1617

1718
class DXCCWindow(QDockWidget):
1819
message = pyqtSignal(dict)
20+
ctyfile = {}
1921
dbname = None
2022
db = None
2123
model = None
@@ -54,10 +56,37 @@ def __init__(self, action):
5456
self.get_log()
5557
self.dxcc_table.resizeColumnsToContents()
5658
self.dxcc_table.resizeRowsToContents()
59+
self.load_cty_data()
5760

5861
def setActive(self, mode: bool):
5962
self.active = bool(mode)
6063

64+
def load_cty_data(self):
65+
try:
66+
with open(
67+
fsutils.APP_DATA_PATH / "cty.json", "rt", encoding="utf-8"
68+
) as c_file:
69+
self.ctyfile = loads(c_file.read())
70+
except (IOError, JSONDecodeError, TypeError):
71+
logging.critical("There was an error parsing the BigCity file.")
72+
73+
def dxcc_lookup(self, dxcc: str) -> str:
74+
"""Lookup callsign in cty.dat file.
75+
76+
Parameters
77+
----------
78+
callsign : str
79+
callsign to lookup
80+
81+
Returns
82+
-------
83+
return : dict
84+
{'entity': 'European Russia', 'cq': 16, 'itu': 29, 'continent': 'EU', 'lat': 53.65, 'long': -41.37, 'tz': 4.0, 'len': 2, 'primary_pfx': 'UA', 'exact_match': False}
85+
"""
86+
87+
result = self.ctyfile.get(dxcc, {})
88+
return result.get("entity", "")
89+
6190
def get_log(self):
6291
"""dxcc_table"""
6392

@@ -74,6 +103,8 @@ def get_log(self):
74103
self.dxcc_table.insertRow(row_number)
75104
for column, data in enumerate(row_data.values()):
76105
item = QtWidgets.QTableWidgetItem(str(data))
106+
if column == 0:
107+
item.setToolTip(self.dxcc_lookup(data))
77108
if column > 0 and column < 7:
78109
if data == 0:
79110
item.setBackground(QBrush(QColor(44, 138, 44)))

0 commit comments

Comments
 (0)