Export ADIF defaults

* fix missing right click - save defaults
This commit is contained in:
dave-w1hkj 2025-09-04 07:55:00 -05:00
parent 012ecb78c1
commit 73a641244c
7 changed files with 469 additions and 108 deletions

View file

@ -31,6 +31,10 @@ fields you want to export with the right panel controls. Press the OK
button to continue or Cancel to abort the operation. A file chooser dialog
will open which allows you to specify the name and location of the exported
file. Use the extension ".adi" on Windows and ".adif" on the other OS's.
You can save and reload the "Defaults". Left click on the button to load
the default button state(s). Right click on the button to save the current
button state(s) as the new default.
<br>
\section export_text_csv Export Text / CSV

View file

@ -578,6 +578,7 @@ fldigi_SOURCES += \
logbook/county_lists.cxx \
logbook/cty-dat.cxx \
logbook/date.cxx \
logbook/export_prefs.cxx \
logbook/fd_logger.cxx \
logbook/fd_view.cxx \
logbook/lgbook.cxx \
@ -793,6 +794,7 @@ EXTRA_fldigi_SOURCES += \
include/dx_cluster.h \
include/dx_dialog.h \
include/estrings.h \
include/export_prefs.h \
include/fd_logger.h \
include/fd_view.h \
include/feld.h \

View file

@ -162,6 +162,7 @@ extern Fl_Scroll *wefax_pic_rx_scroll;
#include "test_signal.h"
#include "logbook.h"
#include "export_prefs.h"
#include "rx_extract.h"
#include "speak.h"

101
src/include/export_prefs.h Normal file
View file

@ -0,0 +1,101 @@
// ---------------------------------------------------------------------
// export_prefs.h
//
// Copyright (C) 2025
// Dave Freese, W1HKJ
//
// This file is part of fldigi.
//
// Fldigi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Fldigi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with fldigi. If not, see <http://www.gnu.org/licenses/>.
// ---------------------------------------------------------------------
//
// Save all floating point values as integers
//
// int_fval = fval * NNN where NNN is a factor of 10
//
// restore using fval = int_fval / NNN
//
// A work around for a bug in class preferences. Read/Write of floating
// point values fails on read if locale is not EN_...
//
//----------------------------------------------------------------------
#ifndef EXPORT_PREFS_H
#define EXPORT_PREFS_H
#include <string>
#include <FL/Fl.H>
#include <FL/Enumerations.H>
#include "lgbook.h"
struct export_prefs {
int Call;
int Name;
int Freq;
int Band;
int Mode;
int QSOdateOn;
int QSOdateOff;
int TimeON;
int TimeOFF;
int TX_pwr;
int RSTsent;
int RSTrcvd;
int Qth;
int LOC;
int State;
int Age;
int StaCall;
int StaGrid;
int StaCity;
int Operator;
int Province;
int Country;
int Notes;
int QSLrcvd;
int QSLsent;
int eQSLrcvd;
int eQSLsent;
int LOTWrcvd;
int LOTWsent;
int QSL_VIA;
int SerialIN;
int SerialOUT;
int Check;
int XchgIn;
int MyXchg;
int CNTY;
int CONT;
int CQZ;
int DXCC;
int IOTA;
int ITUZ;
int Class;
int Section;
int cwss_serno;
int cwss_prec;
int cwss_check;
int tenten;
void save_defaults();
void load_defaults();
};
extern export_prefs export_defaults;
#endif

View file

@ -0,0 +1,329 @@
// ---------------------------------------------------------------------
// export_prefs.cxx
//
// Copyright (C) 2025
// Dave Freese, W1HKJ
//
// This file is part of fldigi.
//
// Fldigi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Fldigi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with fldigi. If not, see <http://www.gnu.org/licenses/>.
// ---------------------------------------------------------------------
//
// Save all floating point values as integers
//
// int_fval = fval * NNN where NNN is a factor of 10
//
// restore using fval = int_fval / NNN
//
// A work around for a bug in class preferences. Read/Write of floating
// point values fails on read if locale is not EN_...
//
//----------------------------------------------------------------------
#include <config.h>
#include <iostream>
#include <fstream>
#include <string>
#include <FL/Fl_Preferences.H>
#include "gettext.h"
#include "main.h"
#include "export_prefs.h"
#include "lgbook.h"
#define EXPORT_PREFS_FILENAME "export_prefs"
export_prefs export_defaults = {
1, // Call = 1;
1, // Name = 1;
1, // Freq = 1;
1, // Band = 1;
1, // Mode = 1;
1, // QSOdateOn = 1;
1, // QSOdateOff = 1;
1, // TimeON = 1;
1, // TimeOFF = 1;
0, // TX_pwr = 0;
1, // RSTsent = 1;
1, // RSTrcvd = 1;
0, // Qth = 0;
0, // LOC = 0;
0, // State = 0;
0, // Age = 0;
0, // StaCall = 0;
0, // StaGrid = 0;
0, // StaCity = 0;
0, // Operator = 0;
0, // Province = 0;
0, // Country = 0;
0, // Notes = 0;
0, // QSLrcvd = 0;
0, // QSLsent = 0;
0, // eQSLrcvd = 0;
0, // eQSLsent = 0;
0, // LOTWrcvd = 0;
0, // LOTWsent = 0;
0, // QSL_VIA = 0;
0, // SerialIN = 0;
0, // SerialOUT = 0;
0, // Check = 0;
0, // XchgIn = 0;
0, // MyXchg = 0;
0, // CNTY = 0;
0, // CONT = 0;
0, // CQZ = 0;
0, // DXCC = 0;
0, // IOTA = 0;
0, // ITUZ = 0;
0, // Class = 0;
0, // Section = 0;
0, // cwss_serno = 0;
0, // cwss_prec = 0;
0, // cwss_check = 0;
0, // tenten = 0;
};
void export_prefs::save_defaults()
{
#if FLDIGI_FLTK_API_MINOR < 4
Fl_Preferences spref(HomeDir.c_str(), "w1hkj.org", EXPORT_PREFS_FILENAME);
#else
Fl_Preferences spref(
HomeDir.c_str(),
"w1hkj.org",
EXPORT_PREFS_FILENAME,
Fl_Preferences::C_LOCALE);
#endif
Call = btnSelectCall->value();
Name = btnSelectName->value();
Freq = btnSelectFreq->value();
Band = btnSelectBand->value();
Mode = btnSelectMode->value();
QSOdateOn = btnSelectQSOdateOn->value();
QSOdateOff = btnSelectQSOdateOff->value();
TimeON = btnSelectTimeON->value();
TimeOFF = btnSelectTimeOFF->value();
TX_pwr = btnSelectTX_pwr->value();
RSTsent = btnSelectRSTsent->value();
RSTrcvd = btnSelectRSTrcvd->value();
Qth = btnSelectQth->value();
LOC = btnSelectLOC->value();
State = btnSelectState->value();
Age = btnSelectAge->value();
StaCall = btnSelectStaCall->value();
StaGrid = btnSelectStaGrid->value();
StaCity = btnSelectStaCity->value();
Operator = btnSelectOperator->value();
Province = btnSelectProvince->value();
Country = btnSelectCountry->value();
Notes = btnSelectNotes->value();
QSLrcvd = btnSelectQSLrcvd->value();
QSLsent = btnSelectQSLsent->value();
eQSLrcvd = btnSelecteQSLrcvd->value();
eQSLsent = btnSelecteQSLsent->value();
LOTWrcvd = btnSelectLOTWrcvd->value();
LOTWsent = btnSelectLOTWsent->value();
QSL_VIA = btnSelectQSL_VIA->value();
SerialIN = btnSelectSerialIN->value();
SerialOUT = btnSelectSerialOUT->value();
Check = btnSelectCheck->value();
XchgIn = btnSelectXchgIn->value();
MyXchg = btnSelectMyXchg->value();
CNTY = btnSelectCNTY->value();
CONT = btnSelectCONT->value();
CQZ = btnSelectCQZ->value();
DXCC = btnSelectDXCC->value();
IOTA = btnSelectIOTA->value();
ITUZ = btnSelectITUZ->value();
Class = btnSelectClass->value();
Section = btnSelectSection->value();
cwss_serno = btnSelect_cwss_serno->value();
cwss_prec = btnSelect_cwss_prec->value();
cwss_check = btnSelect_cwss_check->value();
tenten = btnSelect_1010->value();
spref.set("Call", Call);
spref.set("Name", Name);
spref.set("Freq", Freq);
spref.set("Band", Band);
spref.set("Mode", Mode);
spref.set("QSOdateOn", QSOdateOn);
spref.set("QSOdateOff", QSOdateOff);
spref.set("TimeON", TimeON);
spref.set("TimeOFF", TimeOFF);
spref.set("TX_pwr", TX_pwr);
spref.set("RSTsent", RSTsent);
spref.set("RSTrcvd", RSTrcvd);
spref.set("Qth", Qth);
spref.set("LOC", LOC);
spref.set("State", State);
spref.set("Age", Age);
spref.set("StaCall", StaCall);
spref.set("StaGrid", StaGrid);
spref.set("StaCity", StaCity);
spref.set("Operator", Operator);
spref.set("Province", Province);
spref.set("Country", Country);
spref.set("Notes", Notes);
spref.set("QSLrcvd", QSLrcvd);
spref.set("QSLsent", QSLsent);
spref.set("eQSLrcvd", eQSLrcvd);
spref.set("eQSLsent", eQSLsent);
spref.set("LOTWrcvd", LOTWrcvd);
spref.set("LOTWsent", LOTWsent);
spref.set("QSL_VIA", QSL_VIA);
spref.set("SerialIN", SerialIN);
spref.set("SerialOUT", SerialOUT);
spref.set("Check", Check);
spref.set("XchgIn", XchgIn);
spref.set("MyXchg", MyXchg);
spref.set("CNTY", CNTY);
spref.set("CONT", CONT);
spref.set("CQZ", CQZ);
spref.set("DXCC", DXCC);
spref.set("IOTA", IOTA);
spref.set("ITUZ", ITUZ);
spref.set("Class", Class);
spref.set("Section", Section);
spref.set("cwss_serno", cwss_serno);
spref.set("cwss_prec", cwss_prec);
spref.set("cwss_check", cwss_check);
spref.set("tenten", tenten);
}
void export_prefs::load_defaults()
{
#if FLDIGI_FLTK_API_MINOR < 4
Fl_Preferences spref(HomeDir.c_str(), "w1hkj.org", EXPORT_PREFS_FILENAME);
#else
Fl_Preferences spref(
HomeDir.c_str(),
"w1hkj.org",
EXPORT_PREFS_FILENAME,
Fl_Preferences::C_LOCALE);
#endif
spref.get("Call", Call, Call);
spref.get("Name", Name, Name);
spref.get("Freq", Freq, Freq);
spref.get("Band", Band, Band);
spref.get("Mode", Mode, Mode);
spref.get("QSOdateOn", QSOdateOn, QSOdateOn);
spref.get("QSOdateOff", QSOdateOff, QSOdateOff);
spref.get("TimeON", TimeON, TimeON);
spref.get("TimeOFF", TimeOFF, TimeOFF);
spref.get("TX_pwr", TX_pwr, TX_pwr);
spref.get("RSTsent", RSTsent, RSTsent);
spref.get("RSTrcvd", RSTrcvd, RSTrcvd);
spref.get("Qth", Qth, Qth);
spref.get("LOC", LOC, LOC);
spref.get("State", State, State);
spref.get("Age", Age, Age);
spref.get("StaCall", StaCall, StaCall);
spref.get("StaGrid", StaGrid, StaGrid);
spref.get("StaCity", StaCity, StaCity);
spref.get("Operator", Operator, Operator);
spref.get("Province", Province, Province);
spref.get("Country", Country, Country);
spref.get("Notes", Notes, Notes);
spref.get("QSLrcvd", QSLrcvd, QSLrcvd);
spref.get("QSLsent", QSLsent, QSLsent);
spref.get("eQSLrcvd", eQSLrcvd, eQSLrcvd);
spref.get("eQSLsent", eQSLsent, eQSLsent);
spref.get("LOTWrcvd", LOTWrcvd, LOTWrcvd);
spref.get("LOTWsent", LOTWsent, LOTWsent);
spref.get("QSL_VIA", QSL_VIA, QSL_VIA);
spref.get("SerialIN", SerialIN, SerialIN);
spref.get("SerialOUT", SerialOUT, SerialOUT);
spref.get("Check", Check, Check);
spref.get("XchgIn", XchgIn, XchgIn);
spref.get("MyXchg", MyXchg, MyXchg);
spref.get("CNTY", CNTY, CNTY);
spref.get("CONT", CONT, CONT);
spref.get("CQZ", CQZ, CQZ);
spref.get("DXCC", DXCC, DXCC);
spref.get("IOTA", IOTA, IOTA);
spref.get("ITUZ", ITUZ, ITUZ);
spref.get("Class", Class, Class);
spref.get("Section", Section, Section);
spref.get("cwss_serno", cwss_serno, cwss_serno);
spref.get("cwss_prec", cwss_prec, cwss_prec);
spref.get("cwss_check", cwss_check, cwss_check);
spref.get("tenten", tenten, tenten);
btnSelectCall->value(Call);
btnSelectName->value(Name);
btnSelectFreq->value(Freq);
btnSelectBand->value(Band);
btnSelectMode->value(Mode);
btnSelectQSOdateOn->value(QSOdateOn);
btnSelectQSOdateOff->value(QSOdateOff);
btnSelectTimeON->value(TimeON);
btnSelectTimeOFF->value(TimeOFF);
btnSelectTX_pwr->value(TX_pwr);
btnSelectRSTsent->value(RSTsent);
btnSelectRSTrcvd->value(RSTrcvd);
btnSelectQth->value(Qth);
btnSelectLOC->value(LOC);
btnSelectState->value(State);
btnSelectAge->value(Age);
btnSelectStaCall->value(StaCall);
btnSelectStaGrid->value(StaGrid);
btnSelectStaCity->value(StaCity);
btnSelectOperator->value(Operator);
btnSelectProvince->value(Province);
btnSelectCountry->value(Country);
btnSelectNotes->value(Notes);
btnSelectQSLrcvd->value(QSLrcvd);
btnSelectQSLsent->value(QSLsent);
btnSelecteQSLrcvd->value(QSLrcvd);
btnSelecteQSLsent->value(QSLsent);
btnSelectLOTWrcvd->value(LOTWrcvd);
btnSelectLOTWsent->value(LOTWsent);
btnSelectQSL_VIA->value(QSL_VIA);
btnSelectSerialIN->value(SerialIN);
btnSelectSerialOUT->value(SerialOUT);
btnSelectCheck->value(Check);
btnSelectXchgIn->value(XchgIn);
btnSelectMyXchg->value(MyXchg);
btnSelectCNTY->value(CNTY);
btnSelectCONT->value(CONT);
btnSelectCQZ->value(CQZ);
btnSelectDXCC->value(DXCC);
btnSelectIOTA->value(IOTA);
btnSelectITUZ->value(ITUZ);
btnSelectClass->value(Class);
btnSelectSection->value(Section);
btnSelect_cwss_serno->value(cwss_serno);
btnSelect_cwss_prec->value(cwss_prec);
btnSelect_cwss_check->value(cwss_check);
btnSelect_1010->value(tenten);
}

View file

@ -10,9 +10,14 @@
#include "flmisc.h"
#include "logsupport.h"
#include "pixmaps.h"
#include "export_prefs.h"
Fl_Double_Window *wExport=(Fl_Double_Window *)0;
static void cb_wExport(Fl_Double_Window*, void*) {
export_defaults.load_defaults();
}
Fl_Check_Browser *chkExportBrowser=(Fl_Check_Browser *)0;
Fl_Button *btnClearAll=(Fl_Button *)0;
@ -255,55 +260,11 @@ static void cb_btnCheckAllFields(Fl_Button*, void*) {
Fl_Button *btnSetFieldDefaults=(Fl_Button *)0;
static void cb_btnSetFieldDefaults(Fl_Button*, void*) {
btnSelectCall->value(1);
btnSelectName->value(1);
btnSelectFreq->value(1);
btnSelectBand->value(1);
btnSelectMode->value(1);
btnSelectQSOdateOn->value(1);
btnSelectQSOdateOff->value(1);
btnSelectTimeON->value(1);
btnSelectTimeOFF->value(1);
btnSelectTX_pwr->value(0);
btnSelectRSTsent->value(1);
btnSelectRSTrcvd->value(1);
btnSelectQth->value(0);
btnSelectLOC->value(0);
btnSelectState->value(0);
btnSelectAge->value(0);
btnSelectStaCall->value(0);
btnSelectStaGrid->value(0);
btnSelectStaCity->value(0);
btnSelectOperator->value(0);
btnSelectProvince->value(0);
btnSelectCountry->value(0);
btnSelectNotes->value(0);
btnSelectQSLrcvd->value(0);
btnSelectQSLsent->value(0);
btnSelecteQSLrcvd->value(0);
btnSelecteQSLsent->value(0);
btnSelectLOTWrcvd->value(0);
btnSelectLOTWsent->value(0);
btnSelectQSL_VIA->value(0);
btnSelectSerialIN->value(0);
btnSelectSerialOUT->value(0);
btnSelectCheck->value(0);
btnSelectXchgIn->value(0);
btnSelectMyXchg->value(0);
btnSelectCNTY->value(0);
btnSelectCONT->value(0);
btnSelectCQZ->value(0);
btnSelectDXCC->value(0);
btnSelectIOTA->value(0);
btnSelectITUZ->value(0);
btnSelectClass->value(0);
btnSelectSection->value(0);
btnSelect_cwss_serno->value(0);
btnSelect_cwss_prec->value(0);
btnSelect_cwss_check->value(0);
btnSelect_1010->value(0);
if (Fl::event_button() == FL_RIGHT_MOUSE) {
export_defaults.save_defaults();
} else {
export_defaults.load_defaults();
}
}
Fl_Button *btnSetLoTWfields=(Fl_Button *)0;
@ -1442,6 +1403,7 @@ static void cb_btnCLDcancel(Fl_Button*, void*) {
void create_logbook_dialogs() {
{ wExport = new Fl_Double_Window(805, 440, gettext("Export Setup"));
wExport->callback((Fl_Callback*)cb_wExport);
{ Fl_Group* o = new Fl_Group(4, 4, 388, 430, gettext("Select Records to Export"));
o->box(FL_ENGRAVED_FRAME);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE));

View file

@ -1,8 +1,10 @@
# data file for the Fltk User Interface Designer (fluid)
version 1.0309
version 1.0403
i18n_type 1
i18n_include "gettext.h"
i18n_function _
i18n_include {"gettext.h"}
i18n_conditional {}
i18n_gnu_function gettext
i18n_gnu_static_function gettext_noop
header_name {.h}
code_name {.cxx}
decl {\#include <config.h>} {private local
@ -26,6 +28,9 @@ decl {\#include "flinput2.h"} {public local
decl {\#include "logger.h"} {public local
}
decl {\#include "export_prefs.h"} {private local
}
decl {// Avoid 'nitems' macro collision between FreeBSD's sys/params.h and fltk's
// FL/Fl_Check_Browser.H (http://www.fltk.org/str.php?L2984)
\#undef nitems
@ -40,7 +45,8 @@ Function {create_logbook_dialogs()} {open return_type void
} {
Fl_Window wExport {
label {Export Setup}
xywh {494 421 805 440} type Double hide
callback {export_defaults.load_defaults();} open selected
xywh {551 25 805 440} type Double visible
} {
Fl_Group {} {
label {Select Records to Export}
@ -388,55 +394,11 @@ btnSelect_1010->value(1);}
}
Fl_Button btnSetFieldDefaults {
label Defaults
callback {btnSelectCall->value(1);
btnSelectName->value(1);
btnSelectFreq->value(1);
btnSelectBand->value(1);
btnSelectMode->value(1);
btnSelectQSOdateOn->value(1);
btnSelectQSOdateOff->value(1);
btnSelectTimeON->value(1);
btnSelectTimeOFF->value(1);
btnSelectTX_pwr->value(0);
btnSelectRSTsent->value(1);
btnSelectRSTrcvd->value(1);
btnSelectQth->value(0);
btnSelectLOC->value(0);
btnSelectState->value(0);
btnSelectAge->value(0);
btnSelectStaCall->value(0);
btnSelectStaGrid->value(0);
btnSelectStaCity->value(0);
btnSelectOperator->value(0);
btnSelectProvince->value(0);
btnSelectCountry->value(0);
btnSelectNotes->value(0);
btnSelectQSLrcvd->value(0);
btnSelectQSLsent->value(0);
btnSelecteQSLrcvd->value(0);
btnSelecteQSLsent->value(0);
btnSelectLOTWrcvd->value(0);
btnSelectLOTWsent->value(0);
btnSelectQSL_VIA->value(0);
btnSelectSerialIN->value(0);
btnSelectSerialOUT->value(0);
btnSelectCheck->value(0);
btnSelectXchgIn->value(0);
btnSelectMyXchg->value(0);
btnSelectCNTY->value(0);
btnSelectCONT->value(0);
btnSelectCQZ->value(0);
btnSelectDXCC->value(0);
btnSelectIOTA->value(0);
btnSelectITUZ->value(0);
btnSelectClass->value(0);
btnSelectSection->value(0);
btnSelect_cwss_serno->value(0);
btnSelect_cwss_prec->value(0);
btnSelect_cwss_check->value(0);
btnSelect_1010->value(0);}
callback {if (Fl::event_button() == FL_RIGHT_MOUSE) {
export_defaults.save_defaults();
} else {
export_defaults.load_defaults();
}}
xywh {602 373 85 20}
}
Fl_Button btnSetLoTWfields {
@ -1032,11 +994,11 @@ btnCabRSTrcvd->value(1);}
}
}
Fl_Window wUDPfields {
label {UDP export fields} open
xywh {566 318 423 405} type Double visible
label {UDP export fields}
xywh {566 318 423 405} type Double hide
} {
Fl_Group {} {
label {Select Fields to Export} open selected
label {Select Fields to Export} open
xywh {5 5 410 397} box ENGRAVED_FRAME align 21
} {
Fl_Check_Button btn_udp_Call {
@ -1449,11 +1411,11 @@ wUDPfields->hide();}
}
}
Fl_Window wCLDfields {
label {Cloud Log export fields} open
xywh {566 318 423 405} type Double visible
label {Cloud Log export fields}
xywh {566 318 423 405} type Double hide
} {
Fl_Group {} {
label {Select Fields to Export} open selected
label {Select Fields to Export} open
xywh {5 5 410 397} box ENGRAVED_FRAME align 21
} {
Fl_Check_Button btn_cloud_Call {