Skip to content

Commit

Permalink
Fixed #441 #493: Adds station county and operator callsign to the sta…
Browse files Browse the repository at this point in the history
…tion and associated dependencies
  • Loading branch information
kyleboyle authored and foldynl committed Nov 10, 2024
1 parent 9206e37 commit 258676e
Show file tree
Hide file tree
Showing 12 changed files with 393 additions and 246 deletions.
26 changes: 19 additions & 7 deletions data/StationProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ MODULE_IDENTIFICATION("qlog.data.stationprofile");
QDataStream& operator<<(QDataStream& out, const StationProfile& v)
{
out << v.profileName << v.callsign << v.locator
<< v.operatorName << v.qthName << v.iota
<< v.operatorName << v.operatorCallsign << v.qthName << v.iota
<< v.sota << v.sig << v.sigInfo << v.vucc
<< v.wwff << v.pota << v.ituz << v.cqz << v.dxcc << v.country;
<< v.wwff << v.pota << v.ituz << v.cqz << v.dxcc << v.country << v.county;
return out;
}

Expand All @@ -23,6 +23,7 @@ QDataStream& operator>>(QDataStream& in, StationProfile& v)
in >> v.callsign;
in >> v.locator;
in >> v.operatorName;
in >> v.operatorCallsign;
in >> v.qthName;
in >> v.iota;
in >> v.sota;
Expand All @@ -35,6 +36,7 @@ QDataStream& operator>>(QDataStream& in, StationProfile& v)
in >> v.cqz;
in >> v.dxcc;
in >> v.country;
in >> v.county;

return in;
}
Expand All @@ -50,7 +52,7 @@ StationProfilesManager::StationProfilesManager() :

if ( ! profileQuery.prepare("SELECT profile_name, callsign, locator, "
"operator_name, qth_name, iota, sota, sig, sig_info, vucc, pota, "
"ituz, cqz, dxcc, country "
"ituz, cqz, dxcc, country, county, operator_callsign "
"FROM station_profiles") )
{
qWarning()<< "Cannot prepare select";
Expand All @@ -76,6 +78,8 @@ StationProfilesManager::StationProfilesManager() :
profileDB.cqz = profileQuery.value(12).toInt();
profileDB.dxcc = profileQuery.value(13).toInt();
profileDB.country = profileQuery.value(14).toString();
profileDB.county = profileQuery.value(15).toString();
profileDB.operatorCallsign = profileQuery.value(16).toString();

addProfile(profileDB.profileName, profileDB);
}
Expand All @@ -100,8 +104,8 @@ void StationProfilesManager::save()
return;
}

if ( ! insertQuery.prepare("INSERT INTO station_profiles(profile_name, callsign, locator, operator_name, qth_name, iota, sota, sig, sig_info, vucc, wwff, pota, ituz, cqz, dxcc, country) "
"VALUES (:profile_name, :callsign, :locator, :operator_name, :qth_name, :iota, :sota, :sig, :sig_info, :vucc, :wwff, :pota, :ituz, :cqz, :dxcc, :country)") )
if ( ! insertQuery.prepare("INSERT INTO station_profiles(profile_name, callsign, locator, operator_name, qth_name, iota, sota, sig, sig_info, vucc, wwff, pota, ituz, cqz, dxcc, country, county, operator_callsign) "
"VALUES (:profile_name, :callsign, :locator, :operator_name, :qth_name, :iota, :sota, :sig, :sig_info, :vucc, :wwff, :pota, :ituz, :cqz, :dxcc, :country, :county, :operator_callsign)") )
{
qWarning() << "cannot prepare Insert statement";
return;
Expand Down Expand Up @@ -130,6 +134,8 @@ void StationProfilesManager::save()
insertQuery.bindValue(":cqz", stationProfile.cqz);
insertQuery.bindValue(":dxcc", stationProfile.dxcc);
insertQuery.bindValue(":country", stationProfile.country);
insertQuery.bindValue(":county", stationProfile.county);
insertQuery.bindValue(":operator_callsign", stationProfile.operatorCallsign);

if ( ! insertQuery.exec() )
{
Expand Down Expand Up @@ -162,7 +168,10 @@ bool StationProfile::operator==(const StationProfile &profile)
&& profile.ituz == this->ituz
&& profile.cqz == this->cqz
&& profile.dxcc == this->dxcc
&& profile.country == this->country);
&& profile.country == this->country
&& profile.country == this->county
&& profile.operatorCallsign == this->operatorCallsign
);
}

bool StationProfile::operator!=(const StationProfile &profile)
Expand All @@ -174,8 +183,11 @@ QString StationProfile::toHTMLString() const
{
QString ret = "<b>" + QObject::tr("Logging Station Callsign") + ":</b> " + callsign + "<br/>" +
((!locator.isEmpty()) ? "<b>" + QObject::tr("My Gridsquare") + ":</b> " + locator + "<br/>" : "") +
((!operatorName.isEmpty()) ? "<b>" + QObject::tr("My Name") + ":</b> " + operatorName + "<br/>" : "") +
((!operatorName.isEmpty()) ? "<b>" + QObject::tr("Operator Name") + ":</b> " + operatorName + "<br/>" : "") +
((!operatorCallsign.isEmpty()) ? "<b>" + QObject::tr("Operator Callsign") + ":</b> " + operatorCallsign + "<br/>" : "") +
((!qthName.isEmpty()) ? "<b>" + QObject::tr("My City") + ":</b> " + qthName + "<br/>" : "") +
((!country.isEmpty()) ? "<b>" + QObject::tr("My Country") + ":</b> " + country + "<br/>" : "") +
((!county.isEmpty()) ? "<b>" + QObject::tr("My County") + ":</b> " + county + "<br/>" : "") +
((!iota.isEmpty()) ? "<b>" + QObject::tr("My IOTA") + ":</b> " + iota + "<br/>" : "") +
((!sota.isEmpty()) ? "<b>" + QObject::tr("My SOTA") + ":</b> " + sota + "<br/>" : "" ) +
((!sig.isEmpty()) ? "<b>" + QObject::tr("My Special Interest Activity") + ":</b> " + sig + "<br/>" : "" )+
Expand Down
2 changes: 2 additions & 0 deletions data/StationProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class StationProfile
QString callsign;
QString locator;
QString operatorName;
QString operatorCallsign;
QString qthName;
QString iota;
QString pota;
Expand All @@ -32,6 +33,7 @@ class StationProfile
int cqz;
int dxcc;
QString country;
QString county;

bool operator== (const StationProfile &profile);
bool operator!= (const StationProfile &profile);
Expand Down
2 changes: 2 additions & 0 deletions logformat/LogFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ unsigned long LogFormat::runImport(QTextStream& importLogStream,
setIfEmpty(LogbookModel::COLUMN_STATION_CALLSIGN, defaultStationProfile->callsign);
setIfEmpty(LogbookModel::COLUMN_MY_GRIDSQUARE, defaultStationProfile->locator);
setIfEmpty(LogbookModel::COLUMN_MY_NAME, defaultStationProfile->operatorName);
setIfEmpty(LogbookModel::COLUMN_OPERATOR, defaultStationProfile->operatorCallsign);
setIfEmpty(LogbookModel::COLUMN_MY_CITY_INTL, defaultStationProfile->qthName);
setIfEmpty(LogbookModel::COLUMN_MY_CITY, Data::removeAccents(defaultStationProfile->qthName));
setIfEmpty(LogbookModel::COLUMN_MY_IOTA, defaultStationProfile->iota);
Expand All @@ -301,6 +302,7 @@ unsigned long LogFormat::runImport(QTextStream& importLogStream,
setIfEmpty(LogbookModel::COLUMN_MY_CQ_ZONE, QString::number(defaultStationProfile->cqz));
setIfEmpty(LogbookModel::COLUMN_MY_COUNTRY_INTL, defaultStationProfile->country);
setIfEmpty(LogbookModel::COLUMN_MY_COUNTRY, Data::removeAccents(defaultStationProfile->country));
setIfEmpty(LogbookModel::COLUMN_MY_CNTY, Data::removeAccents(defaultStationProfile->county));
};

auto setMyEntity = [&](const DxccEntity &myEntity)
Expand Down
3 changes: 3 additions & 0 deletions res/sql/migration_030.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ ALTER TABLE alert_rules ADD COLUMN ituz INTEGER;
ALTER TABLE alert_rules ADD COLUMN cqz INTEGER;

ALTER TABLE main_layout_profiles ADD tabsexpanded INTEGER DEFAULT 1;

ALTER TABLE station_profiles ADD county TEXT;
ALTER TABLE station_profiles ADD operator_callsign TEXT;
1 change: 1 addition & 0 deletions ui/ColumnSettingDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ void ColumnSettingDialog::setupDialog()
case LogbookModel::COLUMN_LON:
case LogbookModel::COLUMN_OWNER_CALLSIGN:
case LogbookModel::COLUMN_CONTACTED_OP:
case LogbookModel::COLUMN_OPERATOR:
case LogbookModel::COLUMN_STATION_CALLSIGN:
case LogbookModel::COLUMN_COMMENT:
case LogbookModel::COLUMN_COUNTRY:
Expand Down
11 changes: 9 additions & 2 deletions ui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ MainWindow::MainWindow(QWidget* parent) :
conditionsLabel->setToolTip(QString("<img src='%1'>").arg(PropConditions::solarSummaryFile()));
profileLabel = new QLabel("<b>" + profile.profileName + ":</b>", ui->statusBar);
profileLabel->setIndent(10);
callsignLabel = new QLabel(profile.callsign.toLower() , ui->statusBar);
callsignLabel = new QLabel(stationCallsignStatus(profile), ui->statusBar);
locatorLabel = new QLabel(profile.locator.toLower(), ui->statusBar);
contestLabel = new QLabel(ui->statusBar);
contestLabel->setIndent(20);
Expand Down Expand Up @@ -543,10 +543,17 @@ void MainWindow::stationProfileChanged()
qCDebug(runtime) << profile.callsign << " " << profile.locator << " " << profile.operatorName;

profileLabel->setText("<b>" + profile.profileName + ":</b>");
callsignLabel->setText(profile.callsign.toLower());
callsignLabel->setText(stationCallsignStatus(profile));
locatorLabel->setText(profile.locator.toLower());
}

QString MainWindow::stationCallsignStatus(const StationProfile &profile) {
if (profile.operatorCallsign.isEmpty() || profile.callsign == profile.operatorCallsign) {
return profile.callsign.toLower();
}
return profile.callsign.toLower() + " [op:" + profile.operatorCallsign.toLower() + "]";
}

void MainWindow::darkModeToggle(int mode)
{
FCT_IDENTIFICATION;
Expand Down
2 changes: 2 additions & 0 deletions ui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ private slots:
void restoreContestMenuSeqnoType();
void restoreContestMenuDupeType();
void restoreContestMenuLinkExchange();

QString stationCallsignStatus(const StationProfile &profile);
};

#endif // QLOG_UI_MAINWINDOW_H
15 changes: 15 additions & 0 deletions ui/NewContactWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,21 @@ void NewContactWidget::addAddlFields(QSqlRecord &record, const StationProfile &p
record.setValue("my_country_intl", profile.country);
}

if ( record.value("my_cnty").toString().isEmpty()
&& !profile.county.isEmpty() )
{
record.setValue("my_cnty", profile.county);
}

if ( record.value("operator").toString().isEmpty()
&& !profile.operatorCallsign.isEmpty() )
{
record.setValue("operator", profile.operatorCallsign.toUpper());
} else if ( record.value("operator").toString().isEmpty()
&& !profile.callsign.isEmpty() ) {
record.setValue("operator", profile.callsign.toUpper());
}

if ( record.value("my_itu_zone").toString().isEmpty()
&& profile.ituz != 0 )
{
Expand Down
3 changes: 3 additions & 0 deletions ui/QSODetailDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ QSODetailDialog::QSODetailDialog(const QSqlRecord &qso,
mapper->addMapping(ui->myVUCCEdit, LogbookModel::COLUMN_MY_VUCC_GRIDS);
mapper->addMapping(ui->myWWFFEdit, LogbookModel::COLUMN_MY_WWFF_REF);
mapper->addMapping(ui->powerEdit, LogbookModel::COLUMN_TX_POWER);
mapper->addMapping(ui->myCountyEdit, LogbookModel::COLUMN_MY_CNTY);
mapper->addMapping(ui->myOperatorCallsignEdit, LogbookModel::COLUMN_OPERATOR);

/* Notes */
mapper->addMapping(ui->noteEdit, LogbookModel::COLUMN_NOTES_INTL);
Expand Down Expand Up @@ -2160,6 +2162,7 @@ bool QSODetailDialog::LogbookModelPrivate::setData(const QModelIndex &index, con
case COLUMN_MY_WWFF_REF:
case COLUMN_WWFF_REF:
case COLUMN_STATION_CALLSIGN:
case COLUMN_OPERATOR:
main_update_result = QSqlTableModel::setData(index, ( !value.toString().isEmpty() ) ? value.toString().toUpper() // clazy:exclude=skipped-base-method
: QVariant(), role);
break;
Expand Down
Loading

0 comments on commit 258676e

Please sign in to comment.