From 253b60217f4f5dbb4735eda209be485edb277eba Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Wed, 25 Jul 2018 11:30:44 -0400 Subject: [PATCH] Added station power to configuration --- Configuration.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ Configuration.hpp | 1 + Configuration.ui | 10 ++++++++++ varicode.cpp | 2 +- 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/Configuration.cpp b/Configuration.cpp index 934c4d1..e486da4 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -181,6 +181,8 @@ #include "MaidenheadLocatorValidator.hpp" #include "CallsignValidator.hpp" +#include "varicode.h" + #include "ui_Configuration.h" #include "moc_Configuration.cpp" @@ -532,6 +534,7 @@ private: QString my_callsign_; QString my_grid_; QString my_station_; + int my_dBm_; QString my_qth_; int callsign_aging_; int activity_aging_; @@ -830,6 +833,10 @@ QString Configuration::my_station() const return m_->my_station_; } +int Configuration::my_dBm() const { + return m_->my_dBm_; +} + QString Configuration::my_qth() const { return m_->my_qth_; @@ -1155,6 +1162,39 @@ void Configuration::impl::initialize_models () { pal.setColor (QPalette::Base, Qt::white); } + + QMap dbm2mw = { + {0 , 1}, + {3 , 2}, + {7 , 5}, + {10 , 10}, + {13 , 20}, + {17 , 50}, + {20 , 100}, + {23 , 200}, + {27 , 500}, + {30 , 1000}, // 1W + {33 , 2000}, // 2W + {37 , 5000}, // 5W + {40 , 10000}, // 10W + {43 , 20000}, // 20W + {47 , 50000}, // 50W + {50 , 100000}, // 100W + {53 , 200000}, // 200W + {57 , 500000}, // 500W + {60 , 1000000}, // 1000W + }; + + ui_->station_power_combo_box->clear(); + foreach(auto dbm, dbm2mw.keys()){ + ui_->station_power_combo_box->addItem(QString("%1 (%2 dBm)").arg(Varicode::formatPWR(dbm)).arg(dbm), dbm); + + if(dbm == my_dBm_){ + ui_->station_power_combo_box->setCurrentIndex(ui_->station_power_combo_box->count()-1); + } + } + + ui_->callsign_line_edit->setPalette (pal); ui_->grid_line_edit->setPalette (pal); ui_->callsign_line_edit->setText (my_callsign_); @@ -1283,6 +1323,7 @@ void Configuration::impl::read_settings () my_callsign_ = settings_->value ("MyCall", QString {}).toString (); my_grid_ = settings_->value ("MyGrid", QString {}).toString (); my_station_ = settings_->value("MyStation", QString {}).toString(); + my_dBm_ = settings_->value("MyPower", 0).toInt(); callsign_aging_ = settings_->value ("CallsignAging", 0).toInt (); activity_aging_ = settings_->value ("ActivityAging", 2).toInt (); my_qth_ = settings_->value("MyQTH", QString {}).toString(); @@ -1474,6 +1515,7 @@ void Configuration::impl::write_settings () settings_->setValue ("MyCall", my_callsign_); settings_->setValue ("MyGrid", my_grid_); settings_->setValue ("MyStation", my_station_); + settings_->setValue ("MyPower", my_dBm_); settings_->setValue ("MyQTH", my_qth_); settings_->setValue ("CallsignAging", callsign_aging_); settings_->setValue ("ActivityAging", activity_aging_); @@ -1930,6 +1972,7 @@ void Configuration::impl::accept () my_callsign_ = ui_->callsign_line_edit->text (); my_grid_ = ui_->grid_line_edit->text (); my_station_ = ui_->station_message_line_edit->text().toUpper(); + my_dBm_ = ui_->station_power_combo_box->currentData().toInt(); my_qth_ = ui_->qth_message_line_edit->text().toUpper(); callsign_aging_ = ui_->callsign_aging_spin_box->value(); activity_aging_ = ui_->activity_aging_spin_box->value(); diff --git a/Configuration.hpp b/Configuration.hpp index 5251f83..0821c45 100644 --- a/Configuration.hpp +++ b/Configuration.hpp @@ -97,6 +97,7 @@ public: QString my_callsign () const; QString my_grid () const; QString my_station () const; + int my_dBm() const; int activity_aging() const; int callsign_aging() const; QString my_qth () const; diff --git a/Configuration.ui b/Configuration.ui index 4cb09d5..aa156b4 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -202,6 +202,16 @@ + + + + Station Power: + + + + + + diff --git a/varicode.cpp b/varicode.cpp index 68110bd..9ef1489 100644 --- a/varicode.cpp +++ b/varicode.cpp @@ -193,7 +193,7 @@ QString Varicode::formatPWR(int dbm){ int mwatts = dbmTomwatts(dbm); if(mwatts < 1000){ - return QString("%1MW").arg(mwatts); + return QString("%1mW").arg(mwatts); } return QString("%1W").arg(mwatts/1000);