mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-24 05:08:38 -05:00
Fix issue with v1.8.0 trashing v1.7 working frequencies
Note that reverting to v1.7 will invalidate any saved working frequencies from v1.8 but proceeding to v1.8 again will present a reset set of working frequencies i.e. any user defined entries in v1.8 will be lost of a v1.8 -> v1.7 -> v1.8 transition is made. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@8018 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
3b74de89f2
commit
9f1cd9defd
@ -208,7 +208,7 @@ class FrequencyDialog final
|
||||
: public QDialog
|
||||
{
|
||||
public:
|
||||
using Item = FrequencyList::Item;
|
||||
using Item = FrequencyList_v2::Item;
|
||||
|
||||
explicit FrequencyDialog (IARURegions * regions_model, Modes * modes_model, QWidget * parent = nullptr)
|
||||
: QDialog {parent}
|
||||
@ -407,7 +407,7 @@ private:
|
||||
void save_frequencies ();
|
||||
void reset_frequencies ();
|
||||
void insert_frequency ();
|
||||
FrequencyList::FrequencyItems read_frequencies_file (QString const&);
|
||||
FrequencyList_v2::FrequencyItems read_frequencies_file (QString const&);
|
||||
|
||||
void delete_stations ();
|
||||
void insert_station ();
|
||||
@ -491,8 +491,8 @@ private:
|
||||
IARURegions regions_;
|
||||
IARURegions::Region region_;
|
||||
Modes modes_;
|
||||
FrequencyList frequencies_;
|
||||
FrequencyList next_frequencies_;
|
||||
FrequencyList_v2 frequencies_;
|
||||
FrequencyList_v2 next_frequencies_;
|
||||
StationList stations_;
|
||||
StationList next_stations_;
|
||||
FrequencyDelta current_offset_;
|
||||
@ -666,8 +666,8 @@ Bands const * Configuration::bands () const {return &m_->bands_;}
|
||||
StationList * Configuration::stations () {return &m_->stations_;}
|
||||
StationList const * Configuration::stations () const {return &m_->stations_;}
|
||||
IARURegions::Region Configuration::region () const {return m_->region_;}
|
||||
FrequencyList * Configuration::frequencies () {return &m_->frequencies_;}
|
||||
FrequencyList const * Configuration::frequencies () const {return &m_->frequencies_;}
|
||||
FrequencyList_v2 * Configuration::frequencies () {return &m_->frequencies_;}
|
||||
FrequencyList_v2 const * Configuration::frequencies () const {return &m_->frequencies_;}
|
||||
QStringListModel * Configuration::macros () {return &m_->macros_;}
|
||||
QStringListModel const * Configuration::macros () const {return &m_->macros_;}
|
||||
QDir Configuration::save_directory () const {return m_->save_directory_;}
|
||||
@ -952,18 +952,18 @@ Configuration::impl::impl (Configuration * self, QDir const& temp_directory,
|
||||
//
|
||||
// setup working frequencies table model & view
|
||||
//
|
||||
frequencies_.sort (FrequencyList::frequency_column);
|
||||
frequencies_.sort (FrequencyList_v2::frequency_column);
|
||||
|
||||
ui_->frequencies_table_view->setModel (&next_frequencies_);
|
||||
ui_->frequencies_table_view->sortByColumn (FrequencyList::frequency_column, Qt::AscendingOrder);
|
||||
ui_->frequencies_table_view->setColumnHidden (FrequencyList::frequency_mhz_column, true);
|
||||
ui_->frequencies_table_view->sortByColumn (FrequencyList_v2::frequency_column, Qt::AscendingOrder);
|
||||
ui_->frequencies_table_view->setColumnHidden (FrequencyList_v2::frequency_mhz_column, true);
|
||||
|
||||
// delegates
|
||||
auto frequencies_item_delegate = new QStyledItemDelegate {this};
|
||||
frequencies_item_delegate->setItemEditorFactory (item_editor_factory ());
|
||||
ui_->frequencies_table_view->setItemDelegate (frequencies_item_delegate);
|
||||
ui_->frequencies_table_view->setItemDelegateForColumn (FrequencyList::region_column, new ForeignKeyDelegate {®ions_, 0, this});
|
||||
ui_->frequencies_table_view->setItemDelegateForColumn (FrequencyList::mode_column, new ForeignKeyDelegate {&modes_, 0, this});
|
||||
ui_->frequencies_table_view->setItemDelegateForColumn (FrequencyList_v2::region_column, new ForeignKeyDelegate {®ions_, 0, this});
|
||||
ui_->frequencies_table_view->setItemDelegateForColumn (FrequencyList_v2::mode_column, new ForeignKeyDelegate {&modes_, 0, this});
|
||||
|
||||
// actions
|
||||
frequency_delete_action_ = new QAction {tr ("&Delete"), ui_->frequencies_table_view};
|
||||
@ -1278,7 +1278,7 @@ void Configuration::impl::read_settings ()
|
||||
auto const& v = settings_->value ("FrequenciesForRegionModes");
|
||||
if (v.isValid ())
|
||||
{
|
||||
frequencies_.frequency_list (v.value<FrequencyList::FrequencyItems> ());
|
||||
frequencies_.frequency_list (v.value<FrequencyList_v2::FrequencyItems> ());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1854,7 +1854,7 @@ void Configuration::impl::accept ()
|
||||
if (frequencies_.frequency_list () != next_frequencies_.frequency_list ())
|
||||
{
|
||||
frequencies_.frequency_list (next_frequencies_.frequency_list ());
|
||||
frequencies_.sort (FrequencyList::frequency_column);
|
||||
frequencies_.sort (FrequencyList_v2::frequency_column);
|
||||
}
|
||||
|
||||
if (stations_.station_list () != next_stations_.station_list ())
|
||||
@ -2121,7 +2121,7 @@ void Configuration::impl::delete_frequencies ()
|
||||
auto selection_model = ui_->frequencies_table_view->selectionModel ();
|
||||
selection_model->select (selection_model->selection (), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
||||
next_frequencies_.removeDisjointRows (selection_model->selectedRows ());
|
||||
ui_->frequencies_table_view->resizeColumnToContents (FrequencyList::mode_column);
|
||||
ui_->frequencies_table_view->resizeColumnToContents (FrequencyList_v2::mode_column);
|
||||
}
|
||||
|
||||
void Configuration::impl::load_frequencies ()
|
||||
@ -2152,12 +2152,12 @@ void Configuration::impl::merge_frequencies ()
|
||||
}
|
||||
}
|
||||
|
||||
FrequencyList::FrequencyItems Configuration::impl::read_frequencies_file (QString const& file_name)
|
||||
FrequencyList_v2::FrequencyItems Configuration::impl::read_frequencies_file (QString const& file_name)
|
||||
{
|
||||
QFile frequencies_file {file_name};
|
||||
frequencies_file.open (QFile::ReadOnly);
|
||||
QDataStream ids {&frequencies_file};
|
||||
FrequencyList::FrequencyItems list;
|
||||
FrequencyList_v2::FrequencyItems list;
|
||||
quint32 magic;
|
||||
ids >> magic;
|
||||
if (qrg_magic != magic)
|
||||
@ -2231,7 +2231,7 @@ void Configuration::impl::insert_frequency ()
|
||||
if (QDialog::Accepted == frequency_dialog_->exec ())
|
||||
{
|
||||
ui_->frequencies_table_view->setCurrentIndex (next_frequencies_.add (frequency_dialog_->item ()));
|
||||
ui_->frequencies_table_view->resizeColumnToContents (FrequencyList::mode_column);
|
||||
ui_->frequencies_table_view->resizeColumnToContents (FrequencyList_v2::mode_column);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ class QAudioDeviceInfo;
|
||||
class QString;
|
||||
class QDir;
|
||||
class Bands;
|
||||
class FrequencyList;
|
||||
class FrequencyList_v2;
|
||||
class StationList;
|
||||
class QStringListModel;
|
||||
class QHostAddress;
|
||||
@ -141,8 +141,8 @@ public:
|
||||
Bands * bands ();
|
||||
Bands const * bands () const;
|
||||
IARURegions::Region region () const;
|
||||
FrequencyList * frequencies ();
|
||||
FrequencyList const * frequencies () const;
|
||||
FrequencyList_v2 * frequencies ();
|
||||
FrequencyList_v2 const * frequencies () const;
|
||||
StationList * stations ();
|
||||
StationList const * stations () const;
|
||||
QStringListModel * macros ();
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
FrequencyList::FrequencyItems const default_frequency_list =
|
||||
FrequencyList_v2::FrequencyItems const default_frequency_list =
|
||||
{
|
||||
{198000, Modes::FreqCal, IARURegions::R1}, // BBC Radio 4 Droitwich
|
||||
{4996000, Modes::FreqCal, IARURegions::R1}, // RWM time signal
|
||||
@ -178,7 +178,7 @@ namespace
|
||||
}
|
||||
|
||||
#if !defined (QT_NO_DEBUG_STREAM)
|
||||
QDebug operator << (QDebug debug, FrequencyList::Item const& item)
|
||||
QDebug operator << (QDebug debug, FrequencyList_v2::Item const& item)
|
||||
{
|
||||
QDebugStateSaver saver {debug};
|
||||
debug.nospace () << "FrequencyItem("
|
||||
@ -189,21 +189,21 @@ QDebug operator << (QDebug debug, FrequencyList::Item const& item)
|
||||
}
|
||||
#endif
|
||||
|
||||
QDataStream& operator << (QDataStream& os, FrequencyList::Item const& item)
|
||||
QDataStream& operator << (QDataStream& os, FrequencyList_v2::Item const& item)
|
||||
{
|
||||
return os << item.frequency_
|
||||
<< item.mode_
|
||||
<< item.region_;
|
||||
}
|
||||
|
||||
QDataStream& operator >> (QDataStream& is, FrequencyList::Item& item)
|
||||
QDataStream& operator >> (QDataStream& is, FrequencyList_v2::Item& item)
|
||||
{
|
||||
return is >> item.frequency_
|
||||
>> item.mode_
|
||||
>> item.region_;
|
||||
}
|
||||
|
||||
class FrequencyList::impl final
|
||||
class FrequencyList_v2::impl final
|
||||
: public QAbstractTableModel
|
||||
{
|
||||
public:
|
||||
@ -240,7 +240,7 @@ public:
|
||||
Mode mode_filter_;
|
||||
};
|
||||
|
||||
FrequencyList::FrequencyList (Bands const * bands, QObject * parent)
|
||||
FrequencyList_v2::FrequencyList_v2 (Bands const * bands, QObject * parent)
|
||||
: QSortFilterProxyModel {parent}
|
||||
, m_ {bands, parent}
|
||||
{
|
||||
@ -248,21 +248,21 @@ FrequencyList::FrequencyList (Bands const * bands, QObject * parent)
|
||||
setSortRole (SortRole);
|
||||
}
|
||||
|
||||
FrequencyList::~FrequencyList ()
|
||||
FrequencyList_v2::~FrequencyList_v2 ()
|
||||
{
|
||||
}
|
||||
|
||||
auto FrequencyList::frequency_list (FrequencyItems frequency_list) -> FrequencyItems
|
||||
auto FrequencyList_v2::frequency_list (FrequencyItems frequency_list) -> FrequencyItems
|
||||
{
|
||||
return m_->frequency_list (frequency_list);
|
||||
}
|
||||
|
||||
auto FrequencyList::frequency_list () const -> FrequencyItems const&
|
||||
auto FrequencyList_v2::frequency_list () const -> FrequencyItems const&
|
||||
{
|
||||
return m_->frequency_list_;
|
||||
}
|
||||
|
||||
auto FrequencyList::frequency_list (QModelIndexList const& model_index_list) const -> FrequencyItems
|
||||
auto FrequencyList_v2::frequency_list (QModelIndexList const& model_index_list) const -> FrequencyItems
|
||||
{
|
||||
FrequencyItems list;
|
||||
Q_FOREACH (auto const& index, model_index_list)
|
||||
@ -272,12 +272,12 @@ auto FrequencyList::frequency_list (QModelIndexList const& model_index_list) con
|
||||
return list;
|
||||
}
|
||||
|
||||
void FrequencyList::frequency_list_merge (FrequencyItems const& items)
|
||||
void FrequencyList_v2::frequency_list_merge (FrequencyItems const& items)
|
||||
{
|
||||
m_->add (items);
|
||||
}
|
||||
|
||||
int FrequencyList::best_working_frequency (Frequency f) const
|
||||
int FrequencyList_v2::best_working_frequency (Frequency f) const
|
||||
{
|
||||
int result {-1};
|
||||
auto const& target_band = m_->bands_->find (f);
|
||||
@ -305,7 +305,7 @@ int FrequencyList::best_working_frequency (Frequency f) const
|
||||
return result;
|
||||
}
|
||||
|
||||
int FrequencyList::best_working_frequency (QString const& target_band) const
|
||||
int FrequencyList_v2::best_working_frequency (QString const& target_band) const
|
||||
{
|
||||
int result {-1};
|
||||
if (!target_band.isEmpty ())
|
||||
@ -324,17 +324,17 @@ int FrequencyList::best_working_frequency (QString const& target_band) const
|
||||
return result;
|
||||
}
|
||||
|
||||
void FrequencyList::reset_to_defaults ()
|
||||
void FrequencyList_v2::reset_to_defaults ()
|
||||
{
|
||||
m_->frequency_list (default_frequency_list);
|
||||
}
|
||||
|
||||
QModelIndex FrequencyList::add (Item f)
|
||||
QModelIndex FrequencyList_v2::add (Item f)
|
||||
{
|
||||
return mapFromSource (m_->add (f));
|
||||
}
|
||||
|
||||
bool FrequencyList::remove (Item f)
|
||||
bool FrequencyList_v2::remove (Item f)
|
||||
{
|
||||
auto row = m_->frequency_list_.indexOf (f);
|
||||
|
||||
@ -354,7 +354,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
bool FrequencyList::removeDisjointRows (QModelIndexList rows)
|
||||
bool FrequencyList_v2::removeDisjointRows (QModelIndexList rows)
|
||||
{
|
||||
bool result {true};
|
||||
|
||||
@ -378,14 +378,14 @@ bool FrequencyList::removeDisjointRows (QModelIndexList rows)
|
||||
return result;
|
||||
}
|
||||
|
||||
void FrequencyList::filter (Region region, Mode mode)
|
||||
void FrequencyList_v2::filter (Region region, Mode mode)
|
||||
{
|
||||
m_->region_filter_ = region;
|
||||
m_->mode_filter_ = mode;
|
||||
invalidateFilter ();
|
||||
}
|
||||
|
||||
bool FrequencyList::filterAcceptsRow (int source_row, QModelIndex const& /* parent */) const
|
||||
bool FrequencyList_v2::filterAcceptsRow (int source_row, QModelIndex const& /* parent */) const
|
||||
{
|
||||
bool result {true};
|
||||
auto const& item = m_->frequency_list_[source_row];
|
||||
@ -403,7 +403,7 @@ bool FrequencyList::filterAcceptsRow (int source_row, QModelIndex const& /* pare
|
||||
}
|
||||
|
||||
|
||||
auto FrequencyList::impl::frequency_list (FrequencyItems frequency_list) -> FrequencyItems
|
||||
auto FrequencyList_v2::impl::frequency_list (FrequencyItems frequency_list) -> FrequencyItems
|
||||
{
|
||||
beginResetModel ();
|
||||
std::swap (frequency_list_, frequency_list);
|
||||
@ -411,7 +411,7 @@ auto FrequencyList::impl::frequency_list (FrequencyItems frequency_list) -> Freq
|
||||
return frequency_list;
|
||||
}
|
||||
|
||||
QModelIndex FrequencyList::impl::add (Item f)
|
||||
QModelIndex FrequencyList_v2::impl::add (Item f)
|
||||
{
|
||||
// Any Frequency that isn't in the list may be added
|
||||
if (!frequency_list_.contains (f))
|
||||
@ -427,7 +427,7 @@ QModelIndex FrequencyList::impl::add (Item f)
|
||||
return QModelIndex {};
|
||||
}
|
||||
|
||||
void FrequencyList::impl::add (FrequencyItems items)
|
||||
void FrequencyList_v2::impl::add (FrequencyItems items)
|
||||
{
|
||||
// Any Frequency that isn't in the list may be added
|
||||
for (auto p = items.begin (); p != items.end ();)
|
||||
@ -452,17 +452,17 @@ void FrequencyList::impl::add (FrequencyItems items)
|
||||
}
|
||||
}
|
||||
|
||||
int FrequencyList::impl::rowCount (QModelIndex const& parent) const
|
||||
int FrequencyList_v2::impl::rowCount (QModelIndex const& parent) const
|
||||
{
|
||||
return parent.isValid () ? 0 : frequency_list_.size ();
|
||||
}
|
||||
|
||||
int FrequencyList::impl::columnCount (QModelIndex const& parent) const
|
||||
int FrequencyList_v2::impl::columnCount (QModelIndex const& parent) const
|
||||
{
|
||||
return parent.isValid () ? 0 : num_cols;
|
||||
}
|
||||
|
||||
Qt::ItemFlags FrequencyList::impl::flags (QModelIndex const& index) const
|
||||
Qt::ItemFlags FrequencyList_v2::impl::flags (QModelIndex const& index) const
|
||||
{
|
||||
auto result = QAbstractTableModel::flags (index) | Qt::ItemIsDropEnabled;
|
||||
auto row = index.row ();
|
||||
@ -479,7 +479,7 @@ Qt::ItemFlags FrequencyList::impl::flags (QModelIndex const& index) const
|
||||
return result;
|
||||
}
|
||||
|
||||
QVariant FrequencyList::impl::data (QModelIndex const& index, int role) const
|
||||
QVariant FrequencyList_v2::impl::data (QModelIndex const& index, int role) const
|
||||
{
|
||||
QVariant item;
|
||||
|
||||
@ -594,7 +594,7 @@ QVariant FrequencyList::impl::data (QModelIndex const& index, int role) const
|
||||
return item;
|
||||
}
|
||||
|
||||
bool FrequencyList::impl::setData (QModelIndex const& model_index, QVariant const& value, int role)
|
||||
bool FrequencyList_v2::impl::setData (QModelIndex const& model_index, QVariant const& value, int role)
|
||||
{
|
||||
bool changed {false};
|
||||
|
||||
@ -654,7 +654,7 @@ bool FrequencyList::impl::setData (QModelIndex const& model_index, QVariant cons
|
||||
return changed;
|
||||
}
|
||||
|
||||
QVariant FrequencyList::impl::headerData (int section, Qt::Orientation orientation, int role) const
|
||||
QVariant FrequencyList_v2::impl::headerData (int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
QVariant header;
|
||||
if (Qt::DisplayRole == role
|
||||
@ -676,7 +676,7 @@ QVariant FrequencyList::impl::headerData (int section, Qt::Orientation orientati
|
||||
return header;
|
||||
}
|
||||
|
||||
bool FrequencyList::impl::removeRows (int row, int count, QModelIndex const& parent)
|
||||
bool FrequencyList_v2::impl::removeRows (int row, int count, QModelIndex const& parent)
|
||||
{
|
||||
if (0 < count && (row + count) <= rowCount (parent))
|
||||
{
|
||||
@ -691,7 +691,7 @@ bool FrequencyList::impl::removeRows (int row, int count, QModelIndex const& par
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FrequencyList::impl::insertRows (int row, int count, QModelIndex const& parent)
|
||||
bool FrequencyList_v2::impl::insertRows (int row, int count, QModelIndex const& parent)
|
||||
{
|
||||
if (0 < count)
|
||||
{
|
||||
@ -706,14 +706,14 @@ bool FrequencyList::impl::insertRows (int row, int count, QModelIndex const& par
|
||||
return false;
|
||||
}
|
||||
|
||||
QStringList FrequencyList::impl::mimeTypes () const
|
||||
QStringList FrequencyList_v2::impl::mimeTypes () const
|
||||
{
|
||||
QStringList types;
|
||||
types << mime_type;
|
||||
return types;
|
||||
}
|
||||
|
||||
QMimeData * FrequencyList::impl::mimeData (QModelIndexList const& items) const
|
||||
QMimeData * FrequencyList_v2::impl::mimeData (QModelIndexList const& items) const
|
||||
{
|
||||
QMimeData * mime_data = new QMimeData {};
|
||||
QByteArray encoded_data;
|
||||
@ -731,43 +731,43 @@ QMimeData * FrequencyList::impl::mimeData (QModelIndexList const& items) const
|
||||
return mime_data;
|
||||
}
|
||||
|
||||
auto FrequencyList::const_iterator::operator * () const -> Item const&
|
||||
auto FrequencyList_v2::const_iterator::operator * () const -> Item const&
|
||||
{
|
||||
return parent_->frequency_list ().at(parent_->mapToSource (parent_->index (row_, 0)).row ());
|
||||
}
|
||||
|
||||
auto FrequencyList::const_iterator::operator -> () const -> Item const *
|
||||
auto FrequencyList_v2::const_iterator::operator -> () const -> Item const *
|
||||
{
|
||||
return &parent_->frequency_list ().at(parent_->mapToSource (parent_->index (row_, 0)).row ());
|
||||
}
|
||||
|
||||
bool FrequencyList::const_iterator::operator != (const_iterator const& rhs) const
|
||||
bool FrequencyList_v2::const_iterator::operator != (const_iterator const& rhs) const
|
||||
{
|
||||
return parent_ != rhs.parent_ || row_ != rhs.row_;
|
||||
}
|
||||
|
||||
bool FrequencyList::const_iterator::operator == (const_iterator const& rhs) const
|
||||
bool FrequencyList_v2::const_iterator::operator == (const_iterator const& rhs) const
|
||||
{
|
||||
return parent_ == rhs.parent_ && row_ == rhs.row_;
|
||||
}
|
||||
|
||||
auto FrequencyList::const_iterator::operator ++ () -> const_iterator&
|
||||
auto FrequencyList_v2::const_iterator::operator ++ () -> const_iterator&
|
||||
{
|
||||
++row_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto FrequencyList::begin () const -> const_iterator
|
||||
auto FrequencyList_v2::begin () const -> const_iterator
|
||||
{
|
||||
return const_iterator (this, 0);
|
||||
}
|
||||
|
||||
auto FrequencyList::end () const -> const_iterator
|
||||
auto FrequencyList_v2::end () const -> const_iterator
|
||||
{
|
||||
return const_iterator (this, rowCount ());
|
||||
}
|
||||
|
||||
auto FrequencyList::find (Frequency f) const -> const_iterator
|
||||
auto FrequencyList_v2::find (Frequency f) const -> const_iterator
|
||||
{
|
||||
int row {0};
|
||||
for (; row < rowCount (); ++row)
|
||||
@ -780,7 +780,7 @@ auto FrequencyList::find (Frequency f) const -> const_iterator
|
||||
return const_iterator (this, row);
|
||||
}
|
||||
|
||||
auto FrequencyList::filtered_bands () const -> BandSet
|
||||
auto FrequencyList_v2::filtered_bands () const -> BandSet
|
||||
{
|
||||
BandSet result;
|
||||
for (auto const& item : *this)
|
||||
@ -790,7 +790,7 @@ auto FrequencyList::filtered_bands () const -> BandSet
|
||||
return result;
|
||||
}
|
||||
|
||||
auto FrequencyList::all_bands (Region region, Mode mode) const -> BandSet
|
||||
auto FrequencyList_v2::all_bands (Region region, Mode mode) const -> BandSet
|
||||
{
|
||||
BandSet result;
|
||||
for (auto const& item : m_->frequency_list_)
|
||||
@ -803,3 +803,19 @@ auto FrequencyList::all_bands (Region region, Mode mode) const -> BandSet
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Obsolete version of FrequencyList no longer used but needed to
|
||||
// allow loading and saving of old settings contents without damage
|
||||
//
|
||||
QDataStream& operator << (QDataStream& os, FrequencyList::Item const& item)
|
||||
{
|
||||
return os << item.frequency_
|
||||
<< item.mode_;
|
||||
}
|
||||
|
||||
QDataStream& operator >> (QDataStream& is, FrequencyList::Item& item)
|
||||
{
|
||||
return is >> item.frequency_
|
||||
>> item.mode_;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
class Bands;
|
||||
|
||||
//
|
||||
// Class FrequencyList
|
||||
// Class FrequencyList_v2
|
||||
//
|
||||
// Encapsulates a collection of frequencies with associated modes.
|
||||
// The implementation is a table containing the list of IARU region,
|
||||
@ -37,7 +37,7 @@ class Bands;
|
||||
// Implements the QSortFilterProxyModel interface for a list of spot
|
||||
// frequencies.
|
||||
//
|
||||
class FrequencyList final
|
||||
class FrequencyList_v2 final
|
||||
: public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT;
|
||||
@ -62,7 +62,7 @@ public:
|
||||
class const_iterator
|
||||
{
|
||||
public:
|
||||
const_iterator (FrequencyList const * parent, int row)
|
||||
const_iterator (FrequencyList_v2 const * parent, int row)
|
||||
: parent_ {parent}
|
||||
, row_ {row}
|
||||
{
|
||||
@ -75,12 +75,12 @@ public:
|
||||
const_iterator& operator ++ ();
|
||||
|
||||
private:
|
||||
FrequencyList const * parent_;
|
||||
FrequencyList_v2 const * parent_;
|
||||
int row_;
|
||||
};
|
||||
|
||||
explicit FrequencyList (Bands const *, QObject * parent = nullptr);
|
||||
~FrequencyList ();
|
||||
explicit FrequencyList_v2 (Bands const *, QObject * parent = nullptr);
|
||||
~FrequencyList_v2 ();
|
||||
|
||||
// Load and store underlying items
|
||||
FrequencyItems frequency_list (FrequencyItems);
|
||||
@ -137,7 +137,7 @@ private:
|
||||
};
|
||||
|
||||
inline
|
||||
bool operator == (FrequencyList::Item const& lhs, FrequencyList::Item const& rhs)
|
||||
bool operator == (FrequencyList_v2::Item const& lhs, FrequencyList_v2::Item const& rhs)
|
||||
{
|
||||
return
|
||||
lhs.frequency_ == rhs.frequency_
|
||||
@ -145,13 +145,41 @@ bool operator == (FrequencyList::Item const& lhs, FrequencyList::Item const& rhs
|
||||
&& lhs.mode_ == rhs.mode_;
|
||||
}
|
||||
|
||||
QDataStream& operator << (QDataStream&, FrequencyList::Item const&);
|
||||
QDataStream& operator >> (QDataStream&, FrequencyList::Item&);
|
||||
QDataStream& operator << (QDataStream&, FrequencyList_v2::Item const&);
|
||||
QDataStream& operator >> (QDataStream&, FrequencyList_v2::Item&);
|
||||
|
||||
#if !defined (QT_NO_DEBUG_STREAM)
|
||||
QDebug operator << (QDebug, FrequencyList::Item const&);
|
||||
QDebug operator << (QDebug, FrequencyList_v2::Item const&);
|
||||
#endif
|
||||
|
||||
Q_DECLARE_METATYPE (FrequencyList_v2::Item);
|
||||
Q_DECLARE_METATYPE (FrequencyList_v2::FrequencyItems);
|
||||
|
||||
|
||||
//
|
||||
// Obsolete version of FrequencyList no longer used but needed to
|
||||
// allow loading and saving of old settings contents without damage
|
||||
//
|
||||
class FrequencyList final
|
||||
{
|
||||
public:
|
||||
using Frequency = Radio::Frequency;
|
||||
using Mode = Modes::Mode;
|
||||
|
||||
struct Item
|
||||
{
|
||||
Frequency frequency_;
|
||||
Mode mode_;
|
||||
};
|
||||
using FrequencyItems = QList<Item>;
|
||||
|
||||
private:
|
||||
FrequencyItems frequency_list_;
|
||||
};
|
||||
|
||||
QDataStream& operator << (QDataStream&, FrequencyList::Item const&);
|
||||
QDataStream& operator >> (QDataStream&, FrequencyList::Item&);
|
||||
|
||||
Q_DECLARE_METATYPE (FrequencyList::Item);
|
||||
Q_DECLARE_METATYPE (FrequencyList::FrequencyItems);
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
LiveFrequencyValidator::LiveFrequencyValidator (QComboBox * combo_box
|
||||
, Bands const * bands
|
||||
, FrequencyList const * frequencies
|
||||
, FrequencyList_v2 const * frequencies
|
||||
, Frequency const * nominal_frequency
|
||||
, QWidget * parent)
|
||||
: QRegExpValidator {
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "Radio.hpp"
|
||||
|
||||
class Bands;
|
||||
class FrequencyList;
|
||||
class FrequencyList_v2;
|
||||
class QComboBox;
|
||||
class QWidget;
|
||||
|
||||
@ -35,9 +35,7 @@ public:
|
||||
|
||||
LiveFrequencyValidator (QComboBox * combo_box // associated combo box
|
||||
, Bands const * bands // bands model
|
||||
, FrequencyList const * frequencies // working
|
||||
// frequencies
|
||||
// model
|
||||
, FrequencyList_v2 const * frequencies // working frequencies model
|
||||
, Frequency const * nominal_frequency
|
||||
, QWidget * parent = nullptr);
|
||||
|
||||
@ -48,7 +46,7 @@ public:
|
||||
|
||||
private:
|
||||
Bands const * bands_;
|
||||
FrequencyList const * frequencies_;
|
||||
FrequencyList_v2 const * frequencies_;
|
||||
Frequency const * nominal_frequency_;
|
||||
QComboBox * combo_box_;
|
||||
};
|
||||
|
@ -36,9 +36,11 @@ void register_types ()
|
||||
item_editor_factory ()->registerEditor (qMetaTypeId<Radio::FrequencyDelta> (), new QStandardItemEditorCreator<FrequencyDeltaLineEdit> ());
|
||||
|
||||
// Frequency list model
|
||||
qRegisterMetaType<FrequencyList::Item> ("Item");
|
||||
qRegisterMetaTypeStreamOperators<FrequencyList_v2::Item> ("Item_v2");
|
||||
qRegisterMetaTypeStreamOperators<FrequencyList_v2::FrequencyItems> ("FrequencyItems_v2");
|
||||
|
||||
// defunct old versions
|
||||
qRegisterMetaTypeStreamOperators<FrequencyList::Item> ("Item");
|
||||
qRegisterMetaType<FrequencyList::FrequencyItems> ("FrequencyItems");
|
||||
qRegisterMetaTypeStreamOperators<FrequencyList::FrequencyItems> ("FrequencyItems");
|
||||
|
||||
// Audio device
|
||||
|
@ -519,7 +519,7 @@ bool StationList::impl::dropMimeData (QMimeData const * data, Qt::DropAction act
|
||||
QDataStream stream {&encoded_data, QIODevice::ReadOnly};
|
||||
while (!stream.atEnd ())
|
||||
{
|
||||
FrequencyList::Item item;
|
||||
FrequencyList_v2::Item item;
|
||||
stream >> item;
|
||||
auto const& band = bands_->find (item.frequency_);
|
||||
if (stations_.cend () == std::find_if (stations_.cbegin ()
|
||||
|
@ -431,7 +431,7 @@ auto WSPRBandHopping::next_hop (bool tx_enabled) -> Hop
|
||||
// but to be safe
|
||||
{
|
||||
// we can use the random choice
|
||||
// qDebug () << "random:" << frequencies->data (frequencies->index (frequencies_index, FrequencyList::frequency_column)).toString ();
|
||||
// qDebug () << "random:" << frequencies->data (frequencies->index (frequencies_index, FrequencyList_v2::frequency_column)).toString ();
|
||||
band_index = bands->find (band_name);
|
||||
if (band_index < 0) // this shouldn't happen
|
||||
{
|
||||
@ -444,7 +444,7 @@ auto WSPRBandHopping::next_hop (bool tx_enabled) -> Hop
|
||||
else
|
||||
{
|
||||
band_index += 3;
|
||||
// qDebug () << "scheduled:" << frequencies->data (frequencies->index (frequencies_index, FrequencyList::frequency_column)).toString ();
|
||||
// qDebug () << "scheduled:" << frequencies->data (frequencies->index (frequencies_index, FrequencyList_v2::frequency_column)).toString ();
|
||||
// remove from random permutations to stop the coordinated bands
|
||||
// getting too high a weighting - not perfect but surely helps
|
||||
m_->rx_permutation_.removeOne (band_name);
|
||||
|
@ -40,7 +40,7 @@ class QWidget;
|
||||
// storage using the provided QSettings object instance.
|
||||
//
|
||||
// A passed in Configuration object instance is used to query the
|
||||
// FrequencyList model to determine working frequencies for each
|
||||
// FrequencyList_v2 model to determine working frequencies for each
|
||||
// band. The row index of this model is returned by this classes
|
||||
// hopping scheduling method so it may be conveniently used to select
|
||||
// a new working frequency by a client.
|
||||
|
@ -601,11 +601,11 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
|
||||
|
||||
// Hook up working frequencies.
|
||||
ui->bandComboBox->setModel (m_config.frequencies ());
|
||||
ui->bandComboBox->setModelColumn (FrequencyList::frequency_mhz_column);
|
||||
ui->bandComboBox->setModelColumn (FrequencyList_v2::frequency_mhz_column);
|
||||
|
||||
// combo box drop down width defaults to the line edit + decorator width,
|
||||
// here we change that to the column width size hint of the model column
|
||||
ui->bandComboBox->view ()->setMinimumWidth (ui->bandComboBox->view ()->sizeHintForColumn (FrequencyList::frequency_mhz_column));
|
||||
ui->bandComboBox->view ()->setMinimumWidth (ui->bandComboBox->view ()->sizeHintForColumn (FrequencyList_v2::frequency_mhz_column));
|
||||
|
||||
// Enable live band combo box entry validation and action.
|
||||
auto band_validator = new LiveFrequencyValidator {ui->bandComboBox
|
||||
@ -5158,7 +5158,7 @@ void MainWindow::on_actionOpen_log_directory_triggered ()
|
||||
void MainWindow::on_bandComboBox_currentIndexChanged (int index)
|
||||
{
|
||||
auto const& frequencies = m_config.frequencies ();
|
||||
auto const& source_index = frequencies->mapToSource (frequencies->index (index, FrequencyList::frequency_column));
|
||||
auto const& source_index = frequencies->mapToSource (frequencies->index (index, FrequencyList_v2::frequency_column));
|
||||
Frequency frequency {m_freqNominal};
|
||||
if (source_index.isValid ())
|
||||
{
|
||||
@ -5183,7 +5183,7 @@ void MainWindow::on_bandComboBox_currentIndexChanged (int index)
|
||||
void MainWindow::on_bandComboBox_activated (int index)
|
||||
{
|
||||
auto const& frequencies = m_config.frequencies ();
|
||||
auto const& source_index = frequencies->mapToSource (frequencies->index (index, FrequencyList::frequency_column));
|
||||
auto const& source_index = frequencies->mapToSource (frequencies->index (index, FrequencyList_v2::frequency_column));
|
||||
Frequency frequency {m_freqNominal};
|
||||
if (source_index.isValid ())
|
||||
{
|
||||
|
@ -396,7 +396,7 @@ private:
|
||||
qint32 m_k0;
|
||||
qint32 m_kdone;
|
||||
qint32 m_nPick;
|
||||
FrequencyList::const_iterator m_frequency_list_fcal_iter;
|
||||
FrequencyList_v2::const_iterator m_frequency_list_fcal_iter;
|
||||
qint32 m_nTx73;
|
||||
qint32 m_UTCdisk;
|
||||
qint32 m_wait;
|
||||
|
Loading…
Reference in New Issue
Block a user