diff --git a/core/app/app.go b/core/app/app.go index 8c459c3..d0c2228 100644 --- a/core/app/app.go +++ b/core/app/app.go @@ -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() { diff --git a/core/callinfo/callinfo.go b/core/callinfo/callinfo.go index a1866f5..88b3829 100644 --- a/core/callinfo/callinfo.go +++ b/core/callinfo/callinfo.go @@ -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) @@ -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) { @@ -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) {} diff --git a/core/dxcc/dxcc.go b/core/dxcc/dxcc.go index fb5afe8..2619fe4 100644 --- a/core/dxcc/dxcc.go +++ b/core/dxcc/dxcc.go @@ -4,6 +4,7 @@ import ( "log" "github.com/ftl/hamradio/dxcc" + "github.com/ftl/hellocontest/core" ) func New() *Finder { @@ -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 { @@ -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] @@ -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 } diff --git a/core/settings/settings.go b/core/settings/settings.go index 8d31309..2976290 100644 --- a/core/settings/settings.go +++ b/core/settings/settings.go @@ -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() diff --git a/go.mod b/go.mod index af153e3..5f90ba9 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 827e693..1c7bcc4 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/ui/callinfoView.go b/ui/callinfoView.go index c4ede30..4962f23 100644 --- a/ui/callinfoView.go +++ b/ui/callinfoView.go @@ -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 @@ -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 += ", not ARRL compliant" - } v.dxccLabel.SetMarkup(text) }