Initial stab at band switching...broken
This commit is contained in:
parent
c0cfac10dc
commit
330eb3a57e
12
Bands.cpp
12
Bands.cpp
@ -87,6 +87,18 @@ int Bands::find (QString const& band) const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Bands::findFreq(QString const& band, Radio::Frequency *pFreq) const {
|
||||||
|
int row = find(band);
|
||||||
|
if(row == -1){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pFreq) *pFreq = ADIF_bands[row].lower_bound_;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString const& Bands::oob ()
|
QString const& Bands::oob ()
|
||||||
{
|
{
|
||||||
return oob_name;
|
return oob_name;
|
||||||
|
@ -56,6 +56,8 @@ public:
|
|||||||
//
|
//
|
||||||
QString find (Frequency) const; // find band Frequency is in
|
QString find (Frequency) const; // find band Frequency is in
|
||||||
int find (QString const&) const; // find row of band (-1 if not valid)
|
int find (QString const&) const; // find row of band (-1 if not valid)
|
||||||
|
bool findFreq(QString const& band, Radio::Frequency *pFreq) const;
|
||||||
|
|
||||||
static QString const& oob ();
|
static QString const& oob ();
|
||||||
|
|
||||||
// Iterators
|
// Iterators
|
||||||
|
@ -161,6 +161,7 @@
|
|||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
#include <QSerialPortInfo>
|
#include <QSerialPortInfo>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
#include <QDateTimeEdit>
|
||||||
|
|
||||||
#include "pimpl_impl.hpp"
|
#include "pimpl_impl.hpp"
|
||||||
#include "qt_helpers.hpp"
|
#include "qt_helpers.hpp"
|
||||||
@ -260,14 +261,18 @@ public:
|
|||||||
: QDialog {parent}
|
: QDialog {parent}
|
||||||
, filtered_bands_ {new CandidateKeyFilter {bands, stations, 0, 0}}
|
, filtered_bands_ {new CandidateKeyFilter {bands, stations, 0, 0}}
|
||||||
{
|
{
|
||||||
setWindowTitle (QApplication::applicationName () + " - " + tr ("Add Station"));
|
setWindowTitle (QApplication::applicationName () + " - " + tr ("Add Schedule"));
|
||||||
|
|
||||||
band_.setModel (filtered_bands_.data ());
|
band_.setModel (filtered_bands_.data ());
|
||||||
|
|
||||||
|
switch_at_.setTimeSpec(Qt::UTC);
|
||||||
|
switch_at_.setDisplayFormat("hh:mm");
|
||||||
|
|
||||||
auto form_layout = new QFormLayout ();
|
auto form_layout = new QFormLayout ();
|
||||||
form_layout->addRow (tr ("&Band:"), &band_);
|
form_layout->addRow (tr ("&Band:"), &band_);
|
||||||
form_layout->addRow (tr ("&Offset (MHz):"), &delta_);
|
form_layout->addRow (tr ("&Frequency (MHz):"), &freq_);
|
||||||
form_layout->addRow (tr ("&Antenna:"), &description_);
|
form_layout->addRow (tr ("&Switch at (UTC)):"), &switch_at_);
|
||||||
|
//form_layout->addRow (tr ("&Antenna:"), &description_);
|
||||||
|
|
||||||
auto main_layout = new QVBoxLayout (this);
|
auto main_layout = new QVBoxLayout (this);
|
||||||
main_layout->addLayout (form_layout);
|
main_layout->addLayout (form_layout);
|
||||||
@ -277,16 +282,11 @@ public:
|
|||||||
|
|
||||||
connect (button_box, &QDialogButtonBox::accepted, this, &StationDialog::accept);
|
connect (button_box, &QDialogButtonBox::accepted, this, &StationDialog::accept);
|
||||||
connect (button_box, &QDialogButtonBox::rejected, this, &StationDialog::reject);
|
connect (button_box, &QDialogButtonBox::rejected, this, &StationDialog::reject);
|
||||||
|
|
||||||
if (delta_.text ().isEmpty ())
|
|
||||||
{
|
|
||||||
delta_.setText ("0");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StationList::Station station () const
|
StationList::Station station () const
|
||||||
{
|
{
|
||||||
return {band_.currentText (), delta_.frequency_delta (), description_.text ()};
|
return {band_.currentText (), freq_.frequency(), QDateTime(QDate(2000, 1, 1), switch_at_.time(), Qt::UTC), description_.text ()};
|
||||||
}
|
}
|
||||||
|
|
||||||
int exec () override
|
int exec () override
|
||||||
@ -299,7 +299,8 @@ private:
|
|||||||
QScopedPointer<CandidateKeyFilter> filtered_bands_;
|
QScopedPointer<CandidateKeyFilter> filtered_bands_;
|
||||||
|
|
||||||
QComboBox band_;
|
QComboBox band_;
|
||||||
FrequencyDeltaLineEdit delta_;
|
FrequencyLineEdit freq_;
|
||||||
|
QTimeEdit switch_at_;
|
||||||
QLineEdit description_;
|
QLineEdit description_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -501,8 +502,7 @@ private:
|
|||||||
FrequencyList_v2 next_frequencies_;
|
FrequencyList_v2 next_frequencies_;
|
||||||
StationList stations_;
|
StationList stations_;
|
||||||
StationList next_stations_;
|
StationList next_stations_;
|
||||||
FrequencyDelta current_offset_;
|
bool auto_switch_bands_;
|
||||||
FrequencyDelta current_tx_offset_;
|
|
||||||
|
|
||||||
QAction * frequency_delete_action_;
|
QAction * frequency_delete_action_;
|
||||||
QAction * frequency_insert_action_;
|
QAction * frequency_insert_action_;
|
||||||
@ -706,6 +706,7 @@ Bands * Configuration::bands () {return &m_->bands_;}
|
|||||||
Bands const * Configuration::bands () const {return &m_->bands_;}
|
Bands const * Configuration::bands () const {return &m_->bands_;}
|
||||||
StationList * Configuration::stations () {return &m_->stations_;}
|
StationList * Configuration::stations () {return &m_->stations_;}
|
||||||
StationList const * Configuration::stations () const {return &m_->stations_;}
|
StationList const * Configuration::stations () const {return &m_->stations_;}
|
||||||
|
bool Configuration::auto_switch_bands() const { return &m_->auto_switch_bands_; }
|
||||||
IARURegions::Region Configuration::region () const {return m_->region_;}
|
IARURegions::Region Configuration::region () const {return m_->region_;}
|
||||||
FrequencyList_v2 * Configuration::frequencies () {return &m_->frequencies_;}
|
FrequencyList_v2 * Configuration::frequencies () {return &m_->frequencies_;}
|
||||||
FrequencyList_v2 const * Configuration::frequencies () const {return &m_->frequencies_;}
|
FrequencyList_v2 const * Configuration::frequencies () const {return &m_->frequencies_;}
|
||||||
@ -724,7 +725,7 @@ void Configuration::set_calibration (CalibrationParams params)
|
|||||||
|
|
||||||
void Configuration::enable_calibration (bool on)
|
void Configuration::enable_calibration (bool on)
|
||||||
{
|
{
|
||||||
auto target_frequency = m_->remove_calibration (m_->cached_rig_state_.frequency ()) - m_->current_offset_;
|
auto target_frequency = m_->remove_calibration (m_->cached_rig_state_.frequency ());
|
||||||
m_->frequency_calibration_disabled_ = !on;
|
m_->frequency_calibration_disabled_ = !on;
|
||||||
transceiver_frequency (target_frequency);
|
transceiver_frequency (target_frequency);
|
||||||
}
|
}
|
||||||
@ -910,8 +911,6 @@ Configuration::impl::impl (Configuration * self, QDir const& temp_directory,
|
|||||||
, next_frequencies_ {&bands_}
|
, next_frequencies_ {&bands_}
|
||||||
, stations_ {&bands_}
|
, stations_ {&bands_}
|
||||||
, next_stations_ {&bands_}
|
, next_stations_ {&bands_}
|
||||||
, current_offset_ {0}
|
|
||||||
, current_tx_offset_ {0}
|
|
||||||
, frequency_dialog_ {new FrequencyDialog {®ions_, &modes_, this}}
|
, frequency_dialog_ {new FrequencyDialog {®ions_, &modes_, this}}
|
||||||
, station_dialog_ {new StationDialog {&next_stations_, &bands_, this}}
|
, station_dialog_ {new StationDialog {&next_stations_, &bands_, this}}
|
||||||
, last_port_type_ {TransceiverFactory::Capabilities::none}
|
, last_port_type_ {TransceiverFactory::Capabilities::none}
|
||||||
@ -1112,6 +1111,7 @@ Configuration::impl::impl (Configuration * self, QDir const& temp_directory,
|
|||||||
|
|
||||||
ui_->stations_table_view->setModel (&next_stations_);
|
ui_->stations_table_view->setModel (&next_stations_);
|
||||||
ui_->stations_table_view->sortByColumn (StationList::band_column, Qt::AscendingOrder);
|
ui_->stations_table_view->sortByColumn (StationList::band_column, Qt::AscendingOrder);
|
||||||
|
connect(ui_->auto_switch_bands_check_box, &QCheckBox::clicked, ui_->stations_table_view, &QTableView::setEnabled);
|
||||||
|
|
||||||
// delegates
|
// delegates
|
||||||
auto stations_item_delegate = new QStyledItemDelegate {this};
|
auto stations_item_delegate = new QStyledItemDelegate {this};
|
||||||
@ -1230,6 +1230,8 @@ void Configuration::impl::initialize_models ()
|
|||||||
ui_->monitor_off_check_box->setChecked (monitor_off_at_startup_);
|
ui_->monitor_off_check_box->setChecked (monitor_off_at_startup_);
|
||||||
ui_->monitor_last_used_check_box->setChecked (monitor_last_used_);
|
ui_->monitor_last_used_check_box->setChecked (monitor_last_used_);
|
||||||
ui_->log_as_RTTY_check_box->setChecked (log_as_RTTY_);
|
ui_->log_as_RTTY_check_box->setChecked (log_as_RTTY_);
|
||||||
|
ui_->auto_switch_bands_check_box->setChecked(auto_switch_bands_);
|
||||||
|
ui_->stations_table_view->setEnabled(ui_->auto_switch_bands_check_box->isChecked());
|
||||||
ui_->report_in_comments_check_box->setChecked (report_in_comments_);
|
ui_->report_in_comments_check_box->setChecked (report_in_comments_);
|
||||||
ui_->prompt_to_log_check_box->setChecked (prompt_to_log_);
|
ui_->prompt_to_log_check_box->setChecked (prompt_to_log_);
|
||||||
ui_->insert_blank_check_box->setChecked (insert_blank_);
|
ui_->insert_blank_check_box->setChecked (insert_blank_);
|
||||||
@ -1308,6 +1310,7 @@ void Configuration::impl::initialize_models ()
|
|||||||
next_frequencies_.frequency_list (frequencies_.frequency_list ());
|
next_frequencies_.frequency_list (frequencies_.frequency_list ());
|
||||||
next_stations_.station_list (stations_.station_list ());
|
next_stations_.station_list (stations_.station_list ());
|
||||||
|
|
||||||
|
|
||||||
set_rig_invariants ();
|
set_rig_invariants ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1457,6 +1460,7 @@ void Configuration::impl::read_settings ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
stations_.station_list (settings_->value ("stations").value<StationList::Stations> ());
|
stations_.station_list (settings_->value ("stations").value<StationList::Stations> ());
|
||||||
|
auto_switch_bands_ = settings_->value("AutoSwitchBands", false).toBool();
|
||||||
|
|
||||||
log_as_RTTY_ = settings_->value ("toRTTY", false).toBool ();
|
log_as_RTTY_ = settings_->value ("toRTTY", false).toBool ();
|
||||||
report_in_comments_ = settings_->value("dBtoComments", false).toBool ();
|
report_in_comments_ = settings_->value("dBtoComments", false).toBool ();
|
||||||
@ -1571,6 +1575,7 @@ void Configuration::impl::write_settings ()
|
|||||||
settings_->setValue ("Macros", macros_.stringList ());
|
settings_->setValue ("Macros", macros_.stringList ());
|
||||||
settings_->setValue ("FrequenciesForRegionModes", QVariant::fromValue (frequencies_.frequency_list ()));
|
settings_->setValue ("FrequenciesForRegionModes", QVariant::fromValue (frequencies_.frequency_list ()));
|
||||||
settings_->setValue ("stations", QVariant::fromValue (stations_.station_list ()));
|
settings_->setValue ("stations", QVariant::fromValue (stations_.station_list ()));
|
||||||
|
settings_->setValue ("AutoSwitchBands", auto_switch_bands_);
|
||||||
settings_->setValue ("toRTTY", log_as_RTTY_);
|
settings_->setValue ("toRTTY", log_as_RTTY_);
|
||||||
settings_->setValue ("dBtoComments", report_in_comments_);
|
settings_->setValue ("dBtoComments", report_in_comments_);
|
||||||
settings_->setValue ("Rig", rig_params_.rig_name);
|
settings_->setValue ("Rig", rig_params_.rig_name);
|
||||||
@ -1993,6 +1998,7 @@ void Configuration::impl::accept ()
|
|||||||
autoreply_off_at_startup_ = ui_->autoreply_off_check_box->isChecked ();
|
autoreply_off_at_startup_ = ui_->autoreply_off_check_box->isChecked ();
|
||||||
monitor_off_at_startup_ = ui_->monitor_off_check_box->isChecked ();
|
monitor_off_at_startup_ = ui_->monitor_off_check_box->isChecked ();
|
||||||
monitor_last_used_ = ui_->monitor_last_used_check_box->isChecked ();
|
monitor_last_used_ = ui_->monitor_last_used_check_box->isChecked ();
|
||||||
|
auto_switch_bands_ = ui_->auto_switch_bands_check_box->isChecked();
|
||||||
type_2_msg_gen_ = static_cast<Type2MsgGen> (ui_->type_2_msg_gen_combo_box->currentIndex ());
|
type_2_msg_gen_ = static_cast<Type2MsgGen> (ui_->type_2_msg_gen_combo_box->currentIndex ());
|
||||||
log_as_RTTY_ = ui_->log_as_RTTY_check_box->isChecked ();
|
log_as_RTTY_ = ui_->log_as_RTTY_check_box->isChecked ();
|
||||||
report_in_comments_ = ui_->report_in_comments_check_box->isChecked ();
|
report_in_comments_ = ui_->report_in_comments_check_box->isChecked ();
|
||||||
@ -2467,16 +2473,24 @@ void Configuration::impl::delete_stations ()
|
|||||||
selection_model->select (selection_model->selection (), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
selection_model->select (selection_model->selection (), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
||||||
next_stations_.removeDisjointRows (selection_model->selectedRows ());
|
next_stations_.removeDisjointRows (selection_model->selectedRows ());
|
||||||
ui_->stations_table_view->resizeColumnToContents (StationList::band_column);
|
ui_->stations_table_view->resizeColumnToContents (StationList::band_column);
|
||||||
ui_->stations_table_view->resizeColumnToContents (StationList::offset_column);
|
ui_->stations_table_view->resizeColumnToContents (StationList::frequency_column);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Configuration::impl::insert_station ()
|
void Configuration::impl::insert_station ()
|
||||||
{
|
{
|
||||||
if (QDialog::Accepted == station_dialog_->exec ())
|
if (QDialog::Accepted == station_dialog_->exec ())
|
||||||
{
|
{
|
||||||
ui_->stations_table_view->setCurrentIndex (next_stations_.add (station_dialog_->station ()));
|
auto station = station_dialog_->station ();
|
||||||
|
if(station.frequency_ == 0){
|
||||||
|
Frequency f;
|
||||||
|
if(bands_.findFreq(station.band_name_, &f)){
|
||||||
|
station.frequency_ = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui_->stations_table_view->setCurrentIndex (next_stations_.add (station));
|
||||||
ui_->stations_table_view->resizeColumnToContents (StationList::band_column);
|
ui_->stations_table_view->resizeColumnToContents (StationList::band_column);
|
||||||
ui_->stations_table_view->resizeColumnToContents (StationList::offset_column);
|
ui_->stations_table_view->resizeColumnToContents (StationList::frequency_column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2640,8 +2654,7 @@ void Configuration::impl::transceiver_frequency (Frequency f)
|
|||||||
// cannot absolutely determine if the offset should apply but by
|
// cannot absolutely determine if the offset should apply but by
|
||||||
// simply picking an offset when the Rx frequency is set and
|
// simply picking an offset when the Rx frequency is set and
|
||||||
// sticking to it we get sane behaviour
|
// sticking to it we get sane behaviour
|
||||||
current_offset_ = stations_.offset (f);
|
cached_rig_state_.frequency (apply_calibration (f));
|
||||||
cached_rig_state_.frequency (apply_calibration (f + current_offset_));
|
|
||||||
|
|
||||||
Q_EMIT set_transceiver (cached_rig_state_, ++transceiver_command_number_);
|
Q_EMIT set_transceiver (cached_rig_state_, ++transceiver_command_number_);
|
||||||
}
|
}
|
||||||
@ -2664,8 +2677,7 @@ void Configuration::impl::transceiver_tx_frequency (Frequency f)
|
|||||||
// rig, we cannot absolutely determine if the offset should
|
// rig, we cannot absolutely determine if the offset should
|
||||||
// apply but by simply picking an offset when the Rx
|
// apply but by simply picking an offset when the Rx
|
||||||
// frequency is set and sticking to it we get sane behaviour
|
// frequency is set and sticking to it we get sane behaviour
|
||||||
current_tx_offset_ = stations_.offset (f);
|
cached_rig_state_.tx_frequency (apply_calibration (f));
|
||||||
cached_rig_state_.tx_frequency (apply_calibration (f + current_tx_offset_));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EMIT set_transceiver (cached_rig_state_, ++transceiver_command_number_);
|
Q_EMIT set_transceiver (cached_rig_state_, ++transceiver_command_number_);
|
||||||
@ -2732,12 +2744,12 @@ void Configuration::impl::handle_transceiver_update (TransceiverState const& sta
|
|||||||
{
|
{
|
||||||
TransceiverState reported_state {state};
|
TransceiverState reported_state {state};
|
||||||
// take off calibration & offset
|
// take off calibration & offset
|
||||||
reported_state.frequency (remove_calibration (reported_state.frequency ()) - current_offset_);
|
reported_state.frequency (remove_calibration (reported_state.frequency ()));
|
||||||
|
|
||||||
if (reported_state.tx_frequency ())
|
if (reported_state.tx_frequency ())
|
||||||
{
|
{
|
||||||
// take off calibration & offset
|
// take off calibration & offset
|
||||||
reported_state.tx_frequency (remove_calibration (reported_state.tx_frequency ()) - current_tx_offset_);
|
reported_state.tx_frequency (remove_calibration (reported_state.tx_frequency ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EMIT self_->transceiver_update (reported_state);
|
Q_EMIT self_->transceiver_update (reported_state);
|
||||||
|
@ -162,6 +162,7 @@ public:
|
|||||||
FrequencyList_v2 const * frequencies () const;
|
FrequencyList_v2 const * frequencies () const;
|
||||||
StationList * stations ();
|
StationList * stations ();
|
||||||
StationList const * stations () const;
|
StationList const * stations () const;
|
||||||
|
bool auto_switch_bands() const;
|
||||||
QStringListModel * macros ();
|
QStringListModel * macros ();
|
||||||
QStringListModel const * macros () const;
|
QStringListModel const * macros () const;
|
||||||
QDir save_directory () const;
|
QDir save_directory () const;
|
||||||
|
@ -556,15 +556,15 @@
|
|||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="visible">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="visible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Periodic CW ID Inter&val:</string>
|
<string>Periodic CW ID Inter&val:</string>
|
||||||
</property>
|
</property>
|
||||||
@ -578,15 +578,15 @@
|
|||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="visible">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="visible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Send a CW ID periodically every few minutes.
|
<string>Send a CW ID periodically every few minutes.
|
||||||
This might be required under your countries licence regulations.
|
This might be required under your countries licence regulations.
|
||||||
@ -2339,11 +2339,21 @@ for assessing propagation and system performance.</string>
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Station Information</string>
|
<string>Frequency Schedule</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_13">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="auto_switch_bands_check_box">
|
||||||
|
<property name="text">
|
||||||
|
<string>Automatically switch bands / frequencies at specific times of day</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableView" name="stations_table_view">
|
<widget class="QTableView" name="stations_table_view">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::ActionsContextMenu</enum>
|
<enum>Qt::ActionsContextMenu</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -2693,7 +2703,7 @@ Right click for insert and delete options.</string>
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" native="true">
|
<widget class="QWidget" name="widget" native="true">
|
||||||
<property name="visible">
|
<property name="visible">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -2953,7 +2963,6 @@ Right click for insert and delete options.</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -3135,11 +3144,11 @@ soundcard changes</string>
|
|||||||
</connections>
|
</connections>
|
||||||
<buttongroups>
|
<buttongroups>
|
||||||
<buttongroup name="TX_audio_source_button_group"/>
|
<buttongroup name="TX_audio_source_button_group"/>
|
||||||
<buttongroup name="TX_mode_button_group"/>
|
|
||||||
<buttongroup name="CAT_handshake_button_group"/>
|
|
||||||
<buttongroup name="split_mode_button_group"/>
|
|
||||||
<buttongroup name="PTT_method_button_group"/>
|
<buttongroup name="PTT_method_button_group"/>
|
||||||
<buttongroup name="CAT_stop_bits_button_group"/>
|
<buttongroup name="CAT_handshake_button_group"/>
|
||||||
<buttongroup name="CAT_data_bits_button_group"/>
|
<buttongroup name="CAT_data_bits_button_group"/>
|
||||||
|
<buttongroup name="split_mode_button_group"/>
|
||||||
|
<buttongroup name="CAT_stop_bits_button_group"/>
|
||||||
|
<buttongroup name="TX_mode_button_group"/>
|
||||||
</buttongroups>
|
</buttongroups>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -28,7 +28,8 @@ QDebug operator << (QDebug debug, StationList::Station const& station)
|
|||||||
QDebugStateSaver saver {debug};
|
QDebugStateSaver saver {debug};
|
||||||
debug.nospace () << "Station("
|
debug.nospace () << "Station("
|
||||||
<< station.band_name_ << ", "
|
<< station.band_name_ << ", "
|
||||||
<< station.offset_ << ", "
|
<< station.frequency_ << ", "
|
||||||
|
<< station.switch_at_ << ", "
|
||||||
<< station.antenna_description_ << ')';
|
<< station.antenna_description_ << ')';
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
@ -37,14 +38,16 @@ QDebug operator << (QDebug debug, StationList::Station const& station)
|
|||||||
QDataStream& operator << (QDataStream& os, StationList::Station const& station)
|
QDataStream& operator << (QDataStream& os, StationList::Station const& station)
|
||||||
{
|
{
|
||||||
return os << station.band_name_
|
return os << station.band_name_
|
||||||
<< station.offset_
|
<< station.frequency_
|
||||||
|
<< station.switch_at_
|
||||||
<< station.antenna_description_;
|
<< station.antenna_description_;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream& operator >> (QDataStream& is, StationList::Station& station)
|
QDataStream& operator >> (QDataStream& is, StationList::Station& station)
|
||||||
{
|
{
|
||||||
return is >> station.band_name_
|
return is >> station.band_name_
|
||||||
>> station.offset_
|
>> station.frequency_
|
||||||
|
>> station.switch_at_
|
||||||
>> station.antenna_description_;
|
>> station.antenna_description_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,12 +175,6 @@ bool StationList::removeDisjointRows (QModelIndexList rows)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto StationList::offset (Frequency f) const -> FrequencyDelta
|
|
||||||
{
|
|
||||||
return m_->offset (f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
auto StationList::impl::station_list (Stations stations) -> Stations
|
auto StationList::impl::station_list (Stations stations) -> Stations
|
||||||
{
|
{
|
||||||
beginResetModel ();
|
beginResetModel ();
|
||||||
@ -203,6 +200,7 @@ QModelIndex StationList::impl::add (Station s)
|
|||||||
return QModelIndex {};
|
return QModelIndex {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
auto StationList::impl::offset (Frequency f) const -> FrequencyDelta
|
auto StationList::impl::offset (Frequency f) const -> FrequencyDelta
|
||||||
{
|
{
|
||||||
// Lookup band for frequency
|
// Lookup band for frequency
|
||||||
@ -214,12 +212,13 @@ auto StationList::impl::offset (Frequency f) const -> FrequencyDelta
|
|||||||
{
|
{
|
||||||
if (stations_[i].band_name_ == band)
|
if (stations_[i].band_name_ == band)
|
||||||
{
|
{
|
||||||
return stations_[i].offset_;
|
return stations_[i].frequency_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0; // no offset
|
return 0; // no offset
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int StationList::impl::rowCount (QModelIndex const& parent) const
|
int StationList::impl::rowCount (QModelIndex const& parent) const
|
||||||
{
|
{
|
||||||
@ -300,9 +299,9 @@ QVariant StationList::impl::data (QModelIndex const& index, int role) const
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case offset_column:
|
case frequency_column:
|
||||||
{
|
{
|
||||||
auto frequency_offset = stations_.at (row).offset_;
|
auto frequency_offset = stations_.at (row).frequency_;
|
||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
case SortRole:
|
case SortRole:
|
||||||
@ -317,7 +316,7 @@ QVariant StationList::impl::data (QModelIndex const& index, int role) const
|
|||||||
|
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
case Qt::AccessibleDescriptionRole:
|
case Qt::AccessibleDescriptionRole:
|
||||||
item = tr ("Frequency offset");
|
item = tr ("Frequency");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::TextAlignmentRole:
|
case Qt::TextAlignmentRole:
|
||||||
@ -327,6 +326,27 @@ QVariant StationList::impl::data (QModelIndex const& index, int role) const
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case switch_column:
|
||||||
|
switch (role)
|
||||||
|
{
|
||||||
|
case SortRole:
|
||||||
|
case Qt::EditRole:
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
case Qt::AccessibleTextRole:
|
||||||
|
item = stations_.at (row).switch_at_.toUTC().time().toString("hh:mm");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::ToolTipRole:
|
||||||
|
case Qt::AccessibleDescriptionRole:
|
||||||
|
item = tr ("Switch at this time");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::TextAlignmentRole:
|
||||||
|
item = Qt::AlignCenter + Qt::AlignVCenter;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case description_column:
|
case description_column:
|
||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
@ -362,7 +382,8 @@ QVariant StationList::impl::headerData (int section, Qt::Orientation orientation
|
|||||||
switch (section)
|
switch (section)
|
||||||
{
|
{
|
||||||
case band_column: header = tr ("Band"); break;
|
case band_column: header = tr ("Band"); break;
|
||||||
case offset_column: header = tr ("Offset"); break;
|
case frequency_column: header = tr ("Freq. (MHz)"); break;
|
||||||
|
case switch_column: header = tr ("Switch at (UTC)"); break;
|
||||||
case description_column: header = tr ("Antenna Description"); break;
|
case description_column: header = tr ("Antenna Description"); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -402,21 +423,33 @@ bool StationList::impl::setData (QModelIndex const& model_index, QVariant const&
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case offset_column:
|
case frequency_column:
|
||||||
{
|
{
|
||||||
if (value.canConvert<FrequencyDelta> ())
|
if (value.canConvert<Frequency> ())
|
||||||
{
|
{
|
||||||
FrequencyDelta offset {qvariant_cast<Radio::FrequencyDelta> (value)};
|
Frequency offset {qvariant_cast<Radio::Frequency> (value)};
|
||||||
if (offset != stations_[row].offset_)
|
|
||||||
|
if(offset == 0){
|
||||||
|
Frequency f;
|
||||||
|
if(bands_->findFreq(stations_[row].band_name_, &f)){
|
||||||
|
offset = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offset != stations_[row].frequency_)
|
||||||
{
|
{
|
||||||
stations_[row].offset_ = offset;
|
stations_[row].frequency_ = offset;
|
||||||
Q_EMIT dataChanged (model_index, model_index, roles);
|
Q_EMIT dataChanged (model_index, model_index, roles);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case switch_column:
|
||||||
|
stations_[row].switch_at_ = value.toDateTime();
|
||||||
|
Q_EMIT dataChanged (model_index, model_index, roles);
|
||||||
|
changed = true;
|
||||||
|
break;
|
||||||
case description_column:
|
case description_column:
|
||||||
stations_[row].antenna_description_ = value.toString ();
|
stations_[row].antenna_description_ = value.toString ();
|
||||||
Q_EMIT dataChanged (model_index, model_index, roles);
|
Q_EMIT dataChanged (model_index, model_index, roles);
|
||||||
@ -527,7 +560,7 @@ bool StationList::impl::dropMimeData (QMimeData const * data, Qt::DropAction act
|
|||||||
, [&band] (Station const& s) {return s.band_name_ == band;}))
|
, [&band] (Station const& s) {return s.band_name_ == band;}))
|
||||||
{
|
{
|
||||||
// not found so add it
|
// not found so add it
|
||||||
add (Station {band, 0, QString {}});
|
add (Station {band, 0, QDateTime::currentDateTimeUtc(), QString {}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define STATION_LIST_HPP__
|
#define STATION_LIST_HPP__
|
||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <QDateTime>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
@ -52,13 +53,14 @@ public:
|
|||||||
struct Station
|
struct Station
|
||||||
{
|
{
|
||||||
QString band_name_;
|
QString band_name_;
|
||||||
FrequencyDelta offset_;
|
Frequency frequency_;
|
||||||
|
QDateTime switch_at_;
|
||||||
QString antenna_description_;
|
QString antenna_description_;
|
||||||
};
|
};
|
||||||
|
|
||||||
using Stations = QList<Station>;
|
using Stations = QList<Station>;
|
||||||
|
|
||||||
enum Column {band_column, offset_column, description_column};
|
enum Column {band_column, frequency_column, switch_column, description_column};
|
||||||
|
|
||||||
explicit StationList (Bands const * bands, QObject * parent = nullptr);
|
explicit StationList (Bands const * bands, QObject * parent = nullptr);
|
||||||
explicit StationList (Bands const * bands, Stations, QObject * parent = nullptr);
|
explicit StationList (Bands const * bands, Stations, QObject * parent = nullptr);
|
||||||
@ -74,7 +76,6 @@ public:
|
|||||||
QModelIndex add (Station); // Add a new Station
|
QModelIndex add (Station); // Add a new Station
|
||||||
bool remove (Station); // Remove a Station
|
bool remove (Station); // Remove a Station
|
||||||
bool removeDisjointRows (QModelIndexList); // Remove one or more stations
|
bool removeDisjointRows (QModelIndexList); // Remove one or more stations
|
||||||
FrequencyDelta offset (Frequency) const; // Return the offset to be used for a Frequency
|
|
||||||
|
|
||||||
// Custom sort role.
|
// Custom sort role.
|
||||||
static int constexpr SortRole = Qt::UserRole;
|
static int constexpr SortRole = Qt::UserRole;
|
||||||
@ -88,9 +89,10 @@ private:
|
|||||||
inline
|
inline
|
||||||
bool operator == (StationList::Station const& lhs, StationList::Station const& rhs)
|
bool operator == (StationList::Station const& lhs, StationList::Station const& rhs)
|
||||||
{
|
{
|
||||||
return lhs.band_name_ == rhs.band_name_
|
return lhs.band_name_ == rhs.band_name_ &&
|
||||||
&& lhs.offset_ == rhs.offset_
|
//lhs.antenna_description_ == rhs.antenna_description_ &&
|
||||||
&& lhs.antenna_description_ == rhs.antenna_description_;
|
lhs.frequency_ == rhs.frequency_ &&
|
||||||
|
lhs.switch_at_ == rhs.switch_at_;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream& operator << (QDataStream&, StationList::Station const&);
|
QDataStream& operator << (QDataStream&, StationList::Station const&);
|
||||||
|
@ -1348,6 +1348,33 @@ void MainWindow::on_the_minute ()
|
|||||||
{
|
{
|
||||||
tx_watchdog (false);
|
tx_watchdog (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// see if we need to hop bands...
|
||||||
|
auto now = QDateTime::currentDateTimeUtc().time();
|
||||||
|
Frequency dial_frequency {m_rigState.ptt () && m_rigState.split () ?
|
||||||
|
m_rigState.tx_frequency () : m_rigState.frequency ()};
|
||||||
|
auto const& band_name = m_config.bands ()->find (dial_frequency);
|
||||||
|
auto stations = m_config.stations()->station_list();
|
||||||
|
qSort(stations.begin(), stations.end(), [](StationList::Station const &a, StationList::Station const &b){
|
||||||
|
return a.switch_at_ < b.switch_at_;
|
||||||
|
});
|
||||||
|
|
||||||
|
StationList::Station prev;
|
||||||
|
foreach(auto station, stations){
|
||||||
|
if(station == stations.first()){
|
||||||
|
prev = station;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(prev.switch_at_.time() <= now && now < station.switch_at_.time()){
|
||||||
|
qDebug() << "switch to" << station.band_name_ << station.frequency_;
|
||||||
|
}
|
||||||
|
|
||||||
|
prev = station;
|
||||||
|
}
|
||||||
|
if(prev.switch_at_.time() <= now && now < QTime(11, 59)){
|
||||||
|
qDebug() << "switch to" << prev.band_name_ << prev.frequency_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------- MainWindow destructor
|
//--------------------------------------------------- MainWindow destructor
|
||||||
|
Loading…
Reference in New Issue
Block a user