Skip to content

Adds station county and operator callsign to the station and deps #497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/Migration.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Migration : public QObject
QString fixIntlField(QSqlQuery &query, const QString &columName, const QString &columnNameIntl);
bool refreshUploadStatusTrigger();

static const int latestVersion = 29;
static const int latestVersion = 30;
};

#endif // QLOG_CORE_MIGRATION_H
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 @@ -51,7 +53,7 @@ StationProfilesManager::StationProfilesManager(QObject *parent) :

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 @@ -77,6 +79,8 @@ StationProfilesManager::StationProfilesManager(QObject *parent) :
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 @@ -101,8 +105,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 @@ -131,6 +135,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 @@ -163,7 +169,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 @@ -175,8 +184,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
1 change: 1 addition & 0 deletions res/res.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
<file>sql/migration_027.sql</file>
<file>sql/migration_028.sql</file>
<file>sql/migration_029.sql</file>
<file>sql/migration_030.sql</file>
</qresource>
</RCC>
3 changes: 3 additions & 0 deletions res/sql/migration_030.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

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 @@ -92,7 +92,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);
alertButton = new QPushButton("0", ui->statusBar);
alertButton->setIcon(QIcon(":/icons/alert.svg"));
Expand Down Expand Up @@ -469,12 +469,19 @@ 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());

emit settingsChanged();
}

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
1 change: 1 addition & 0 deletions ui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private slots:

void restoreUserDefinedShortcuts();
void saveUserDefinedShortcuts();
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 @@ -1178,6 +1178,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
Loading