Skip to content

Commit

Permalink
add the remaining Cabrillo fields
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Thienel <[email protected]>
  • Loading branch information
ftl committed Dec 30, 2024
1 parent 77db7c0 commit 42e4859
Show file tree
Hide file tree
Showing 4 changed files with 303 additions and 20 deletions.
90 changes: 85 additions & 5 deletions core/export/cabrillo/cabrillo.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ type View interface {

SetName(string)
SetEmail(string)
SetLocation(string)
SetAddressText(string)
SetAddressCity(string)
SetAddressPostalCode(string)
SetAddressStateProvince(string)
SetAddressCountry(string)
SetClub(string)
SetSpecific(string)

SetCertificate(bool)
SetSoapBox(string)

SetOpenAfterExport(bool)
}
Expand All @@ -40,10 +51,20 @@ type Controller struct {
qsoBand cabrillo.CategoryBand
qsoMode cabrillo.CategoryMode

category cabrillo.Category
name string
email string
openAfterExport bool
category cabrillo.Category
name string
email string
location string
addressText string
addressCity string
addressPostalCode string
addressStateProvince string
addressCountry string
club string
specific string
certificate bool
soapBox string
openAfterExport bool
}

func NewController() *Controller {
Expand Down Expand Up @@ -74,6 +95,16 @@ func (c *Controller) Run(settings core.Settings, claimedScore int, qsos []core.Q
c.updateCategorySettings()
c.view.SetName(c.name)
c.view.SetEmail(c.email)
c.view.SetLocation(c.location)
c.view.SetAddressText(c.addressText)
c.view.SetAddressCity(c.addressCity)
c.view.SetAddressPostalCode(c.addressPostalCode)
c.view.SetAddressStateProvince(c.addressStateProvince)
c.view.SetAddressCountry(c.addressCountry)
c.view.SetClub(c.club)
c.view.SetSpecific(c.specific)
c.view.SetCertificate(c.certificate)
c.view.SetSoapBox(c.soapBox)
c.view.SetOpenAfterExport(c.openAfterExport)
accepted := c.view.Show()
if !accepted {
Expand All @@ -84,6 +115,16 @@ func (c *Controller) Run(settings core.Settings, claimedScore int, qsos []core.Q
export.Category = c.category
export.Name = c.name
export.Email = c.email
export.Location = c.location
export.Address.Text = c.addressText
export.Address.City = c.addressCity
export.Address.Postalcode = c.addressPostalCode
export.Address.StateProvince = c.addressStateProvince
export.Address.Country = c.addressCountry
export.Club = c.club
export.Custom["SPECIFIC"] = c.specific
export.Certificate = c.certificate
export.Soapbox = c.soapBox

return export, c.openAfterExport, true
}
Expand Down Expand Up @@ -320,6 +361,46 @@ func (c *Controller) SetEmail(email string) {
c.email = email
}

func (c *Controller) SetLocation(location string) {
c.location = location
}

func (c *Controller) SetAddressText(addressText string) {
c.addressText = addressText
}

func (c *Controller) SetAddressCity(addressCity string) {
c.addressCity = addressCity
}

func (c *Controller) SetAddressPostalCode(addressPostalCode string) {
c.addressPostalCode = addressPostalCode
}

func (c *Controller) SetAddressStateProvince(addressStateProvince string) {
c.addressStateProvince = addressStateProvince
}

func (c *Controller) SetAddressCountry(addressCountry string) {
c.addressCountry = addressCountry
}

func (c *Controller) SetClub(club string) {
c.club = club
}

func (c *Controller) SetSpecific(specific string) {
c.specific = specific
}

func (c *Controller) SetCertificate(certificate bool) {
c.certificate = certificate
}

func (c *Controller) SetSoapBox(soapBox string) {
c.soapBox = soapBox
}

func (c *Controller) SetOpenAfterExport(open bool) {
c.openAfterExport = open
}
Expand All @@ -332,7 +413,6 @@ func createCabrilloLog(settings core.Settings, claimedScore int, qsos []core.QSO
export.Operators = []callsign.Callsign{settings.Station().Operator}
export.GridLocator = settings.Station().Locator
export.ClaimedScore = claimedScore
export.Certificate = true

qsoData := make([]cabrillo.QSO, 0, len(qsos))
ignoredQSOs := make([]cabrillo.QSO, 0, len(qsos))
Expand Down
31 changes: 27 additions & 4 deletions ui/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ func buildExplanationLabel(grid *gtk.Grid, row int, labelText string) *gtk.Label
return label
}

func buildSeparator(grid *gtk.Grid, row int) {
func buildSeparator(grid *gtk.Grid, row int, width int) {
separator, _ := gtk.SeparatorNew(gtk.ORIENTATION_HORIZONTAL)
separator.SetHExpand(true)
separator.SetMarginTop(5)
separator.SetMarginBottom(5)
grid.Attach(separator, 0, row, 2, 1)
grid.Attach(separator, 0, row, width, 1)
}

func buildLabeledCombo(grid *gtk.Grid, row int, labelText string, withEntry bool, items []string, handler any) *gtk.ComboBoxText {
label, _ := gtk.LabelNew(labelText)
label.SetHAlign(gtk.ALIGN_END)
label.SetHExpand(false)
grid.Attach(label, 0, row, 1, 1)

var combo *gtk.ComboBoxText
Expand All @@ -45,7 +46,6 @@ func buildLabeledCombo(grid *gtk.Grid, row int, labelText string, withEntry bool
combo, _ = gtk.ComboBoxTextNew()
}
combo.SetHExpand(true)
combo.RemoveAll()
combo.Append("", "")
for _, item := range items {
combo.Append(item, item)
Expand All @@ -60,6 +60,7 @@ func buildLabeledCombo(grid *gtk.Grid, row int, labelText string, withEntry bool
func buildLabeledEntry(grid *gtk.Grid, row int, labelText string, handler any) *gtk.Entry {
label, _ := gtk.LabelNew(labelText)
label.SetHAlign(gtk.ALIGN_END)
label.SetHExpand(false)
grid.Attach(label, 0, row, 1, 1)

entry, _ := gtk.EntryNew()
Expand All @@ -71,10 +72,32 @@ func buildLabeledEntry(grid *gtk.Grid, row int, labelText string, handler any) *
return entry
}

func buildLabeledTextView(grid *gtk.Grid, row int, labelText string, handler any) *gtk.TextView {
label, _ := gtk.LabelNew(labelText)
label.SetHAlign(gtk.ALIGN_START)
grid.Attach(label, 0, row, 1, 1)

textView, _ := gtk.TextViewNew()

scrolledWindow, _ := gtk.ScrolledWindowNew(nil, nil)
scrolledWindow.Add(textView)
scrolledWindow.SetHExpand(true)
scrolledWindow.SetVExpand(true)
scrolledWindow.SetSizeRequest(0, 100)
scrolledWindow.SetMarginStart(5)
scrolledWindow.SetMarginEnd(5)
grid.Attach(scrolledWindow, 0, row+1, 1, 1)

buffer, _ := textView.GetBuffer()
buffer.Connect("changed", handler)

return textView
}

func buildCheckButton(grid *gtk.Grid, row int, labelText string, handler any) *gtk.CheckButton {
checkButton, _ := gtk.CheckButtonNewWithLabel(labelText)
checkButton.SetHExpand(true)
grid.Attach(checkButton, 0, row, 2, 1)
grid.Attach(checkButton, 0, row, 1, 1)

checkButton.Connect("toggled", handler)

Expand Down
99 changes: 97 additions & 2 deletions ui/exportCabrilloDialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,20 @@ type exportCabrilloDialog struct {
categoryOverlay string
categoryTime string

name string
email string
name string
email string
location string
addressText string
addressCity string
addressPostalCode string
addressStateProvince string
addressCountry string
club string
specific string

certificate bool
soapBox string

openAfterExport bool
}

Expand Down Expand Up @@ -53,6 +65,18 @@ func (d *exportCabrilloDialog) Show() bool {
d.view.categoryTimeCombo.SetActiveID(d.categoryTime)
d.view.nameEntry.SetText(d.name)
d.view.emailEntry.SetText(d.email)
d.view.locationEntry.SetText(d.location)
d.view.addressTextEntry.SetText(d.addressText)
d.view.addressCityEntry.SetText(d.addressCity)
d.view.addressPostalCodeEntry.SetText(d.addressPostalCode)
d.view.addressStateProvinceEntry.SetText(d.addressStateProvince)
d.view.addressCountryEntry.SetText(d.addressCountry)
d.view.clubEntry.SetText(d.club)
d.view.specificEntry.SetText(d.specific)
d.view.certificateCheckButton.SetActive(d.certificate)
buffer, _ := d.view.soapBoxEntry.GetBuffer()
buffer.SetText(d.soapBox)
// d.view.soapBoxEntry.SetBuffer(buffer)
d.view.openAfterExportCheckButton.SetActive(d.openAfterExport)

dialog, _ := gtk.DialogNew()
Expand Down Expand Up @@ -153,6 +177,77 @@ func (d *exportCabrilloDialog) SetEmail(email string) {
}
}

func (d *exportCabrilloDialog) SetLocation(location string) {
d.location = location
if d.view != nil {
d.view.locationEntry.SetText(location)
}
}

func (d *exportCabrilloDialog) SetAddressText(addressText string) {
d.addressText = addressText
if d.view != nil {
d.view.addressTextEntry.SetText(addressText)
}
}

func (d *exportCabrilloDialog) SetAddressCity(addressCity string) {
d.addressCity = addressCity
if d.view != nil {
d.view.addressCityEntry.SetText(addressCity)
}
}

func (d *exportCabrilloDialog) SetAddressPostalCode(addressPostalCode string) {
d.addressPostalCode = addressPostalCode
if d.view != nil {
d.view.addressPostalCodeEntry.SetText(addressPostalCode)
}
}

func (d *exportCabrilloDialog) SetAddressStateProvince(addressStateProvince string) {
d.addressStateProvince = addressStateProvince
if d.view != nil {
d.view.addressStateProvinceEntry.SetText(addressStateProvince)
}
}

func (d *exportCabrilloDialog) SetAddressCountry(addressCountry string) {
d.addressCountry = addressCountry
if d.view != nil {
d.view.addressCountryEntry.SetText(addressCountry)
}
}

func (d *exportCabrilloDialog) SetClub(club string) {
d.club = club
if d.view != nil {
d.view.clubEntry.SetText(club)
}
}

func (d *exportCabrilloDialog) SetSpecific(specific string) {
d.specific = specific
if d.view != nil {
d.view.specificEntry.SetText(specific)
}
}

func (d *exportCabrilloDialog) SetCertificate(certificate bool) {
d.certificate = certificate
if d.view != nil {
d.view.certificateCheckButton.SetActive(certificate)
}
}

func (d *exportCabrilloDialog) SetSoapBox(soapBox string) {
d.soapBox = soapBox
if d.view != nil {
buffer, _ := d.view.soapBoxEntry.GetBuffer()
buffer.SetText(soapBox)
}
}

func (d *exportCabrilloDialog) SetOpenAfterExport(open bool) {
d.openAfterExport = open
}
Loading

0 comments on commit 42e4859

Please sign in to comment.