Skip to content

Commit

Permalink
take the ARRL country list into account for ARRL-sponsored contests
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Thienel <[email protected]>
  • Loading branch information
ftl committed Dec 23, 2024
1 parent aceeb07 commit 3420f98
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 17 deletions.
1 change: 1 addition & 0 deletions core/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func (c *Controller) Startup() {
c.Settings.Notify(c.Callinfo)
c.Settings.Notify(c.Clusters)
c.Settings.Notify(c.Bandmap)
c.Settings.Notify(c.dxccFinder)
c.Settings.Notify(c.callHistoryFinder)
c.Settings.Notify(settings.SettingsListenerFunc(func(s core.Settings) {
if !c.dxccFinder.Available() {
Expand Down
6 changes: 3 additions & 3 deletions core/callinfo/callinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type ExchangeFilter interface {
// View defines the visual part of the call information window.
type View interface {
SetBestMatchingCallsign(callsign core.AnnotatedCallsign)
SetDXCC(string, string, int, int, bool)
SetDXCC(string, string, int, int)
SetValue(points, multis, value int)
SetPredictedExchange(index int, text string)
SetPredictedExchangeFields(fields []core.ExchangeField)
Expand Down Expand Up @@ -282,7 +282,7 @@ func (c *Callinfo) showDXCCEntity(entity dxcc.Prefix) {
if entity.PrimaryPrefix != "" {
dxccName = fmt.Sprintf("%s (%s)", entity.Name, entity.PrimaryPrefix)
}
c.view.SetDXCC(dxccName, entity.Continent, int(entity.ITUZone), int(entity.CQZone), !entity.NotARRLCompliant)
c.view.SetDXCC(dxccName, entity.Continent, int(entity.ITUZone), int(entity.CQZone))
}

func (c *Callinfo) findBestMatch() (core.AnnotatedCallsign, bool) {
Expand Down Expand Up @@ -426,7 +426,7 @@ type nullView struct{}
func (v *nullView) Show() {}
func (v *nullView) Hide() {}
func (v *nullView) SetBestMatchingCallsign(callsign core.AnnotatedCallsign) {}
func (v *nullView) SetDXCC(string, string, int, int, bool) {}
func (v *nullView) SetDXCC(string, string, int, int) {}
func (v *nullView) SetValue(int, int, int) {}
func (v *nullView) SetPredictedExchange(int, string) {}
func (v *nullView) SetPredictedExchangeFields(fields []core.ExchangeField) {}
Expand Down
21 changes: 18 additions & 3 deletions core/dxcc/dxcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"log"

"github.com/ftl/hamradio/dxcc"
"github.com/ftl/hellocontest/core"
)

func New() *Finder {
Expand All @@ -21,8 +22,9 @@ func New() *Finder {
}

type Finder struct {
entities *dxcc.Prefixes
available chan struct{}
entities *dxcc.Prefixes
available chan struct{}
onlyARRLCompliant bool
}

func (f *Finder) Available() bool {
Expand All @@ -41,6 +43,14 @@ func (f *Finder) WhenAvailable(callback func()) {
}()
}

func (f *Finder) ContestChanged(contest core.Contest) {
if contest.Definition == nil {
f.onlyARRLCompliant = false
return
}
f.onlyARRLCompliant = contest.Definition.ARRLCountryList
}

func (f *Finder) Find(s string) (entity dxcc.Prefix, found bool) {
if entities := f.FindAll(s); len(entities) > 0 {
entity = entities[0]
Expand All @@ -53,7 +63,12 @@ func (f *Finder) FindAll(s string) []dxcc.Prefix {
if f.entities == nil {
return []dxcc.Prefix{}
}
result, _ := f.entities.Find(s)
var result []dxcc.Prefix
if f.onlyARRLCompliant {
result, _ = f.entities.FindARRLCompliant(s)
} else {
result, _ = f.entities.Find(s)
}
return result
}

Expand Down
2 changes: 1 addition & 1 deletion core/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (s *Settings) SetAvailableCallHistoryFieldNames(fieldNames []string) {
s.updateExchangeFields()
}

func (s *Settings) Notify(listener interface{}) {
func (s *Settings) Notify(listener any) {
s.listeners = append(s.listeners, listener)

s.updateContestPages()
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ go 1.22.3
require (
github.com/ftl/cabrillo v0.2.2
github.com/ftl/clusterix v0.1.0
github.com/ftl/conval v0.7.7
github.com/ftl/conval v0.8.0
github.com/ftl/gmtry v0.0.0-20201120192810-fa4a1b99fc04
github.com/ftl/godxmap v1.0.1
github.com/ftl/hamradio v0.2.11
github.com/ftl/hamradio v0.2.12
github.com/ftl/rigproxy v0.2.6
github.com/ftl/tci v0.3.2
github.com/golang/protobuf v1.5.4
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ github.com/ftl/cabrillo v0.2.2 h1:c54U9f14eo/aEKp1z9cfGcPfAn2feJTNbPr230hOXlQ=
github.com/ftl/cabrillo v0.2.2/go.mod h1:KYCrmgZXhXuta03bS8fnD27bJoRSmP/mvkzCV7lMU1w=
github.com/ftl/clusterix v0.1.0 h1:+fbTybTvkVorx3B4zZ3DBiVbmLV0hhFpfDGW50Ss9cg=
github.com/ftl/clusterix v0.1.0/go.mod h1:N89RHOExeAbnWqoXs/MD76uackK2/9Dcu+FooVq1tKg=
github.com/ftl/conval v0.7.7 h1:bCQEpIvK+QnhNNn0YIvc4IrJmYv/g0ubEyIDML7suLg=
github.com/ftl/conval v0.7.7/go.mod h1:Dzx7lU1NMWXgue6ZBRNqNuhVN1kgZb4mu3PQ9hwB1XY=
github.com/ftl/conval v0.8.0 h1:ZD1b+YpNne8ED53jmDR6l3Amv+wtOveLwHQSPSGgTMc=
github.com/ftl/conval v0.8.0/go.mod h1:McmMHWMs0y/rY1RVUoUB7GbeBxGDdVovfNXqHDOKhj4=
github.com/ftl/gmtry v0.0.0-20201120192810-fa4a1b99fc04 h1:S7z3LXqDYk4avXKj+B2orGWquOo/A+1ZJbcUPx0duLo=
github.com/ftl/gmtry v0.0.0-20201120192810-fa4a1b99fc04/go.mod h1:AQpbHYBSPV1Bc1nqG8vv8BK3qxXMZIn32OQBi/4A7Sc=
github.com/ftl/godxmap v1.0.1 h1:VzzpC2TBTO3/NMHDeqNTpGhhFxHrTLfhycUq0edh4JE=
github.com/ftl/godxmap v1.0.1/go.mod h1:re+DTuokHPkwc9u3GQfj9R4wlKIWw60kWQObybVyupU=
github.com/ftl/hamradio v0.2.11 h1:pUll2s4mW+XgxeXhDtrQxKSUjILvNMd1rbV1r3osdZY=
github.com/ftl/hamradio v0.2.11/go.mod h1:BvA+ni3sOKmrIJpLt6f2sYK9vc3VfihZm4x0h8kzOPw=
github.com/ftl/hamradio v0.2.12 h1:FipuUaYSK/hFDg49KJF/PiTQgl5EexXrpMiuCt2v9wA=
github.com/ftl/hamradio v0.2.12/go.mod h1:BvA+ni3sOKmrIJpLt6f2sYK9vc3VfihZm4x0h8kzOPw=
github.com/ftl/localcopy v0.0.0-20190616142648-8915fb81f0d9 h1:ORI3EUKpLTsfA372C6xpuZFDXw+ckmCzLaCcJvakG24=
github.com/ftl/localcopy v0.0.0-20190616142648-8915fb81f0d9/go.mod h1:4sZLCxjgn++exy5u0muVzlvnahfanPuiHLQo0GJQnPA=
github.com/ftl/rigproxy v0.2.6 h1:umsoOET+VWpWc3jSXz+FoZq5zwuodrigiOiwZyafr3o=
Expand Down
5 changes: 1 addition & 4 deletions ui/callinfoView.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (v *callinfoView) SetBestMatchingCallsign(callsign core.AnnotatedCallsign)
v.callsignLabel.SetMarkup(v.renderCallsign(callsign))
}

func (v *callinfoView) SetDXCC(dxccName, continent string, itu, cq int, arrlCompliant bool) {
func (v *callinfoView) SetDXCC(dxccName, continent string, itu, cq int) {
if dxccName == "" {
v.dxccLabel.SetMarkup("")
return
Expand All @@ -108,9 +108,6 @@ func (v *callinfoView) SetDXCC(dxccName, continent string, itu, cq int, arrlComp
if cq != 0 {
text += fmt.Sprintf(", CQ %d", cq)
}
if dxccName != "" && !arrlCompliant {
text += ", <span foreground='red' font-weight='heavy'>not ARRL compliant</span>"
}

v.dxccLabel.SetMarkup(text)
}
Expand Down

0 comments on commit 3420f98

Please sign in to comment.