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:
Bill Somerville 2017-08-09 16:06:17 +00:00
parent 3b74de89f2
commit 9f1cd9defd
12 changed files with 133 additions and 89 deletions

View File

@ -208,7 +208,7 @@ class FrequencyDialog final
: public QDialog : public QDialog
{ {
public: public:
using Item = FrequencyList::Item; using Item = FrequencyList_v2::Item;
explicit FrequencyDialog (IARURegions * regions_model, Modes * modes_model, QWidget * parent = nullptr) explicit FrequencyDialog (IARURegions * regions_model, Modes * modes_model, QWidget * parent = nullptr)
: QDialog {parent} : QDialog {parent}
@ -407,7 +407,7 @@ private:
void save_frequencies (); void save_frequencies ();
void reset_frequencies (); void reset_frequencies ();
void insert_frequency (); void insert_frequency ();
FrequencyList::FrequencyItems read_frequencies_file (QString const&); FrequencyList_v2::FrequencyItems read_frequencies_file (QString const&);
void delete_stations (); void delete_stations ();
void insert_station (); void insert_station ();
@ -491,8 +491,8 @@ private:
IARURegions regions_; IARURegions regions_;
IARURegions::Region region_; IARURegions::Region region_;
Modes modes_; Modes modes_;
FrequencyList frequencies_; FrequencyList_v2 frequencies_;
FrequencyList next_frequencies_; FrequencyList_v2 next_frequencies_;
StationList stations_; StationList stations_;
StationList next_stations_; StationList next_stations_;
FrequencyDelta current_offset_; FrequencyDelta current_offset_;
@ -666,8 +666,8 @@ 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_;}
IARURegions::Region Configuration::region () const {return m_->region_;} IARURegions::Region Configuration::region () const {return m_->region_;}
FrequencyList * Configuration::frequencies () {return &m_->frequencies_;} FrequencyList_v2 * Configuration::frequencies () {return &m_->frequencies_;}
FrequencyList const * Configuration::frequencies () const {return &m_->frequencies_;} FrequencyList_v2 const * Configuration::frequencies () const {return &m_->frequencies_;}
QStringListModel * Configuration::macros () {return &m_->macros_;} QStringListModel * Configuration::macros () {return &m_->macros_;}
QStringListModel const * Configuration::macros () const {return &m_->macros_;} QStringListModel const * Configuration::macros () const {return &m_->macros_;}
QDir Configuration::save_directory () const {return m_->save_directory_;} 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 // 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->setModel (&next_frequencies_);
ui_->frequencies_table_view->sortByColumn (FrequencyList::frequency_column, Qt::AscendingOrder); ui_->frequencies_table_view->sortByColumn (FrequencyList_v2::frequency_column, Qt::AscendingOrder);
ui_->frequencies_table_view->setColumnHidden (FrequencyList::frequency_mhz_column, true); ui_->frequencies_table_view->setColumnHidden (FrequencyList_v2::frequency_mhz_column, true);
// delegates // delegates
auto frequencies_item_delegate = new QStyledItemDelegate {this}; auto frequencies_item_delegate = new QStyledItemDelegate {this};
frequencies_item_delegate->setItemEditorFactory (item_editor_factory ()); frequencies_item_delegate->setItemEditorFactory (item_editor_factory ());
ui_->frequencies_table_view->setItemDelegate (frequencies_item_delegate); ui_->frequencies_table_view->setItemDelegate (frequencies_item_delegate);
ui_->frequencies_table_view->setItemDelegateForColumn (FrequencyList::region_column, new ForeignKeyDelegate {&regions_, 0, this}); ui_->frequencies_table_view->setItemDelegateForColumn (FrequencyList_v2::region_column, new ForeignKeyDelegate {&regions_, 0, this});
ui_->frequencies_table_view->setItemDelegateForColumn (FrequencyList::mode_column, new ForeignKeyDelegate {&modes_, 0, this}); ui_->frequencies_table_view->setItemDelegateForColumn (FrequencyList_v2::mode_column, new ForeignKeyDelegate {&modes_, 0, this});
// actions // actions
frequency_delete_action_ = new QAction {tr ("&Delete"), ui_->frequencies_table_view}; 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"); auto const& v = settings_->value ("FrequenciesForRegionModes");
if (v.isValid ()) if (v.isValid ())
{ {
frequencies_.frequency_list (v.value<FrequencyList::FrequencyItems> ()); frequencies_.frequency_list (v.value<FrequencyList_v2::FrequencyItems> ());
} }
else else
{ {
@ -1854,7 +1854,7 @@ void Configuration::impl::accept ()
if (frequencies_.frequency_list () != next_frequencies_.frequency_list ()) if (frequencies_.frequency_list () != next_frequencies_.frequency_list ())
{ {
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 ()) 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 (); auto selection_model = ui_->frequencies_table_view->selectionModel ();
selection_model->select (selection_model->selection (), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); selection_model->select (selection_model->selection (), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
next_frequencies_.removeDisjointRows (selection_model->selectedRows ()); 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 () 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}; QFile frequencies_file {file_name};
frequencies_file.open (QFile::ReadOnly); frequencies_file.open (QFile::ReadOnly);
QDataStream ids {&frequencies_file}; QDataStream ids {&frequencies_file};
FrequencyList::FrequencyItems list; FrequencyList_v2::FrequencyItems list;
quint32 magic; quint32 magic;
ids >> magic; ids >> magic;
if (qrg_magic != magic) if (qrg_magic != magic)
@ -2231,7 +2231,7 @@ void Configuration::impl::insert_frequency ()
if (QDialog::Accepted == frequency_dialog_->exec ()) if (QDialog::Accepted == frequency_dialog_->exec ())
{ {
ui_->frequencies_table_view->setCurrentIndex (next_frequencies_.add (frequency_dialog_->item ())); 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);
} }
} }

View File

@ -17,7 +17,7 @@ class QAudioDeviceInfo;
class QString; class QString;
class QDir; class QDir;
class Bands; class Bands;
class FrequencyList; class FrequencyList_v2;
class StationList; class StationList;
class QStringListModel; class QStringListModel;
class QHostAddress; class QHostAddress;
@ -141,8 +141,8 @@ public:
Bands * bands (); Bands * bands ();
Bands const * bands () const; Bands const * bands () const;
IARURegions::Region region () const; IARURegions::Region region () const;
FrequencyList * frequencies (); FrequencyList_v2 * frequencies ();
FrequencyList const * frequencies () const; FrequencyList_v2 const * frequencies () const;
StationList * stations (); StationList * stations ();
StationList const * stations () const; StationList const * stations () const;
QStringListModel * macros (); QStringListModel * macros ();

View File

@ -24,7 +24,7 @@
namespace namespace
{ {
FrequencyList::FrequencyItems const default_frequency_list = FrequencyList_v2::FrequencyItems const default_frequency_list =
{ {
{198000, Modes::FreqCal, IARURegions::R1}, // BBC Radio 4 Droitwich {198000, Modes::FreqCal, IARURegions::R1}, // BBC Radio 4 Droitwich
{4996000, Modes::FreqCal, IARURegions::R1}, // RWM time signal {4996000, Modes::FreqCal, IARURegions::R1}, // RWM time signal
@ -178,7 +178,7 @@ namespace
} }
#if !defined (QT_NO_DEBUG_STREAM) #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}; QDebugStateSaver saver {debug};
debug.nospace () << "FrequencyItem(" debug.nospace () << "FrequencyItem("
@ -189,21 +189,21 @@ QDebug operator << (QDebug debug, FrequencyList::Item const& item)
} }
#endif #endif
QDataStream& operator << (QDataStream& os, FrequencyList::Item const& item) QDataStream& operator << (QDataStream& os, FrequencyList_v2::Item const& item)
{ {
return os << item.frequency_ return os << item.frequency_
<< item.mode_ << item.mode_
<< item.region_; << item.region_;
} }
QDataStream& operator >> (QDataStream& is, FrequencyList::Item& item) QDataStream& operator >> (QDataStream& is, FrequencyList_v2::Item& item)
{ {
return is >> item.frequency_ return is >> item.frequency_
>> item.mode_ >> item.mode_
>> item.region_; >> item.region_;
} }
class FrequencyList::impl final class FrequencyList_v2::impl final
: public QAbstractTableModel : public QAbstractTableModel
{ {
public: public:
@ -240,7 +240,7 @@ public:
Mode mode_filter_; Mode mode_filter_;
}; };
FrequencyList::FrequencyList (Bands const * bands, QObject * parent) FrequencyList_v2::FrequencyList_v2 (Bands const * bands, QObject * parent)
: QSortFilterProxyModel {parent} : QSortFilterProxyModel {parent}
, m_ {bands, parent} , m_ {bands, parent}
{ {
@ -248,21 +248,21 @@ FrequencyList::FrequencyList (Bands const * bands, QObject * parent)
setSortRole (SortRole); 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); 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_; 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; FrequencyItems list;
Q_FOREACH (auto const& index, model_index_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; return list;
} }
void FrequencyList::frequency_list_merge (FrequencyItems const& items) void FrequencyList_v2::frequency_list_merge (FrequencyItems const& items)
{ {
m_->add (items); m_->add (items);
} }
int FrequencyList::best_working_frequency (Frequency f) const int FrequencyList_v2::best_working_frequency (Frequency f) const
{ {
int result {-1}; int result {-1};
auto const& target_band = m_->bands_->find (f); auto const& target_band = m_->bands_->find (f);
@ -305,7 +305,7 @@ int FrequencyList::best_working_frequency (Frequency f) const
return result; 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}; int result {-1};
if (!target_band.isEmpty ()) if (!target_band.isEmpty ())
@ -324,17 +324,17 @@ int FrequencyList::best_working_frequency (QString const& target_band) const
return result; return result;
} }
void FrequencyList::reset_to_defaults () void FrequencyList_v2::reset_to_defaults ()
{ {
m_->frequency_list (default_frequency_list); m_->frequency_list (default_frequency_list);
} }
QModelIndex FrequencyList::add (Item f) QModelIndex FrequencyList_v2::add (Item f)
{ {
return mapFromSource (m_->add (f)); return mapFromSource (m_->add (f));
} }
bool FrequencyList::remove (Item f) bool FrequencyList_v2::remove (Item f)
{ {
auto row = m_->frequency_list_.indexOf (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}; bool result {true};
@ -378,14 +378,14 @@ bool FrequencyList::removeDisjointRows (QModelIndexList rows)
return result; return result;
} }
void FrequencyList::filter (Region region, Mode mode) void FrequencyList_v2::filter (Region region, Mode mode)
{ {
m_->region_filter_ = region; m_->region_filter_ = region;
m_->mode_filter_ = mode; m_->mode_filter_ = mode;
invalidateFilter (); 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}; bool result {true};
auto const& item = m_->frequency_list_[source_row]; 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 (); beginResetModel ();
std::swap (frequency_list_, frequency_list); std::swap (frequency_list_, frequency_list);
@ -411,7 +411,7 @@ auto FrequencyList::impl::frequency_list (FrequencyItems frequency_list) -> Freq
return frequency_list; 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 // Any Frequency that isn't in the list may be added
if (!frequency_list_.contains (f)) if (!frequency_list_.contains (f))
@ -427,7 +427,7 @@ QModelIndex FrequencyList::impl::add (Item f)
return QModelIndex {}; 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 // Any Frequency that isn't in the list may be added
for (auto p = items.begin (); p != items.end ();) 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 (); 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; 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 result = QAbstractTableModel::flags (index) | Qt::ItemIsDropEnabled;
auto row = index.row (); auto row = index.row ();
@ -479,7 +479,7 @@ Qt::ItemFlags FrequencyList::impl::flags (QModelIndex const& index) const
return result; 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; QVariant item;
@ -594,7 +594,7 @@ QVariant FrequencyList::impl::data (QModelIndex const& index, int role) const
return item; 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}; bool changed {false};
@ -654,7 +654,7 @@ bool FrequencyList::impl::setData (QModelIndex const& model_index, QVariant cons
return changed; 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; QVariant header;
if (Qt::DisplayRole == role if (Qt::DisplayRole == role
@ -676,7 +676,7 @@ QVariant FrequencyList::impl::headerData (int section, Qt::Orientation orientati
return header; 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)) if (0 < count && (row + count) <= rowCount (parent))
{ {
@ -691,7 +691,7 @@ bool FrequencyList::impl::removeRows (int row, int count, QModelIndex const& par
return false; 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) if (0 < count)
{ {
@ -706,14 +706,14 @@ bool FrequencyList::impl::insertRows (int row, int count, QModelIndex const& par
return false; return false;
} }
QStringList FrequencyList::impl::mimeTypes () const QStringList FrequencyList_v2::impl::mimeTypes () const
{ {
QStringList types; QStringList types;
types << mime_type; types << mime_type;
return types; return types;
} }
QMimeData * FrequencyList::impl::mimeData (QModelIndexList const& items) const QMimeData * FrequencyList_v2::impl::mimeData (QModelIndexList const& items) const
{ {
QMimeData * mime_data = new QMimeData {}; QMimeData * mime_data = new QMimeData {};
QByteArray encoded_data; QByteArray encoded_data;
@ -731,43 +731,43 @@ QMimeData * FrequencyList::impl::mimeData (QModelIndexList const& items) const
return mime_data; 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 ()); 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 ()); 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_; 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_; return parent_ == rhs.parent_ && row_ == rhs.row_;
} }
auto FrequencyList::const_iterator::operator ++ () -> const_iterator& auto FrequencyList_v2::const_iterator::operator ++ () -> const_iterator&
{ {
++row_; ++row_;
return *this; return *this;
} }
auto FrequencyList::begin () const -> const_iterator auto FrequencyList_v2::begin () const -> const_iterator
{ {
return const_iterator (this, 0); return const_iterator (this, 0);
} }
auto FrequencyList::end () const -> const_iterator auto FrequencyList_v2::end () const -> const_iterator
{ {
return const_iterator (this, rowCount ()); 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}; int row {0};
for (; row < rowCount (); ++row) for (; row < rowCount (); ++row)
@ -780,7 +780,7 @@ auto FrequencyList::find (Frequency f) const -> const_iterator
return const_iterator (this, row); return const_iterator (this, row);
} }
auto FrequencyList::filtered_bands () const -> BandSet auto FrequencyList_v2::filtered_bands () const -> BandSet
{ {
BandSet result; BandSet result;
for (auto const& item : *this) for (auto const& item : *this)
@ -790,7 +790,7 @@ auto FrequencyList::filtered_bands () const -> BandSet
return result; 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; BandSet result;
for (auto const& item : m_->frequency_list_) for (auto const& item : m_->frequency_list_)
@ -803,3 +803,19 @@ auto FrequencyList::all_bands (Region region, Mode mode) const -> BandSet
} }
return result; 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_;
}

View File

@ -13,7 +13,7 @@
class Bands; class Bands;
// //
// Class FrequencyList // Class FrequencyList_v2
// //
// Encapsulates a collection of frequencies with associated modes. // Encapsulates a collection of frequencies with associated modes.
// The implementation is a table containing the list of IARU region, // 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 // Implements the QSortFilterProxyModel interface for a list of spot
// frequencies. // frequencies.
// //
class FrequencyList final class FrequencyList_v2 final
: public QSortFilterProxyModel : public QSortFilterProxyModel
{ {
Q_OBJECT; Q_OBJECT;
@ -62,7 +62,7 @@ public:
class const_iterator class const_iterator
{ {
public: public:
const_iterator (FrequencyList const * parent, int row) const_iterator (FrequencyList_v2 const * parent, int row)
: parent_ {parent} : parent_ {parent}
, row_ {row} , row_ {row}
{ {
@ -75,12 +75,12 @@ public:
const_iterator& operator ++ (); const_iterator& operator ++ ();
private: private:
FrequencyList const * parent_; FrequencyList_v2 const * parent_;
int row_; int row_;
}; };
explicit FrequencyList (Bands const *, QObject * parent = nullptr); explicit FrequencyList_v2 (Bands const *, QObject * parent = nullptr);
~FrequencyList (); ~FrequencyList_v2 ();
// Load and store underlying items // Load and store underlying items
FrequencyItems frequency_list (FrequencyItems); FrequencyItems frequency_list (FrequencyItems);
@ -137,7 +137,7 @@ private:
}; };
inline inline
bool operator == (FrequencyList::Item const& lhs, FrequencyList::Item const& rhs) bool operator == (FrequencyList_v2::Item const& lhs, FrequencyList_v2::Item const& rhs)
{ {
return return
lhs.frequency_ == rhs.frequency_ lhs.frequency_ == rhs.frequency_
@ -145,13 +145,41 @@ bool operator == (FrequencyList::Item const& lhs, FrequencyList::Item const& rhs
&& lhs.mode_ == rhs.mode_; && lhs.mode_ == rhs.mode_;
} }
QDataStream& operator << (QDataStream&, FrequencyList::Item const&); QDataStream& operator << (QDataStream&, FrequencyList_v2::Item const&);
QDataStream& operator >> (QDataStream&, FrequencyList::Item&); QDataStream& operator >> (QDataStream&, FrequencyList_v2::Item&);
#if !defined (QT_NO_DEBUG_STREAM) #if !defined (QT_NO_DEBUG_STREAM)
QDebug operator << (QDebug, FrequencyList::Item const&); QDebug operator << (QDebug, FrequencyList_v2::Item const&);
#endif #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::Item);
Q_DECLARE_METATYPE (FrequencyList::FrequencyItems); Q_DECLARE_METATYPE (FrequencyList::FrequencyItems);

View File

@ -12,7 +12,7 @@
LiveFrequencyValidator::LiveFrequencyValidator (QComboBox * combo_box LiveFrequencyValidator::LiveFrequencyValidator (QComboBox * combo_box
, Bands const * bands , Bands const * bands
, FrequencyList const * frequencies , FrequencyList_v2 const * frequencies
, Frequency const * nominal_frequency , Frequency const * nominal_frequency
, QWidget * parent) , QWidget * parent)
: QRegExpValidator { : QRegExpValidator {

View File

@ -7,7 +7,7 @@
#include "Radio.hpp" #include "Radio.hpp"
class Bands; class Bands;
class FrequencyList; class FrequencyList_v2;
class QComboBox; class QComboBox;
class QWidget; class QWidget;
@ -35,9 +35,7 @@ public:
LiveFrequencyValidator (QComboBox * combo_box // associated combo box LiveFrequencyValidator (QComboBox * combo_box // associated combo box
, Bands const * bands // bands model , Bands const * bands // bands model
, FrequencyList const * frequencies // working , FrequencyList_v2 const * frequencies // working frequencies model
// frequencies
// model
, Frequency const * nominal_frequency , Frequency const * nominal_frequency
, QWidget * parent = nullptr); , QWidget * parent = nullptr);
@ -48,7 +46,7 @@ public:
private: private:
Bands const * bands_; Bands const * bands_;
FrequencyList const * frequencies_; FrequencyList_v2 const * frequencies_;
Frequency const * nominal_frequency_; Frequency const * nominal_frequency_;
QComboBox * combo_box_; QComboBox * combo_box_;
}; };

View File

@ -36,9 +36,11 @@ void register_types ()
item_editor_factory ()->registerEditor (qMetaTypeId<Radio::FrequencyDelta> (), new QStandardItemEditorCreator<FrequencyDeltaLineEdit> ()); item_editor_factory ()->registerEditor (qMetaTypeId<Radio::FrequencyDelta> (), new QStandardItemEditorCreator<FrequencyDeltaLineEdit> ());
// Frequency list model // 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"); qRegisterMetaTypeStreamOperators<FrequencyList::Item> ("Item");
qRegisterMetaType<FrequencyList::FrequencyItems> ("FrequencyItems");
qRegisterMetaTypeStreamOperators<FrequencyList::FrequencyItems> ("FrequencyItems"); qRegisterMetaTypeStreamOperators<FrequencyList::FrequencyItems> ("FrequencyItems");
// Audio device // Audio device

View File

@ -519,7 +519,7 @@ bool StationList::impl::dropMimeData (QMimeData const * data, Qt::DropAction act
QDataStream stream {&encoded_data, QIODevice::ReadOnly}; QDataStream stream {&encoded_data, QIODevice::ReadOnly};
while (!stream.atEnd ()) while (!stream.atEnd ())
{ {
FrequencyList::Item item; FrequencyList_v2::Item item;
stream >> item; stream >> item;
auto const& band = bands_->find (item.frequency_); auto const& band = bands_->find (item.frequency_);
if (stations_.cend () == std::find_if (stations_.cbegin () if (stations_.cend () == std::find_if (stations_.cbegin ()

View File

@ -431,7 +431,7 @@ auto WSPRBandHopping::next_hop (bool tx_enabled) -> Hop
// but to be safe // but to be safe
{ {
// we can use the random choice // 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); band_index = bands->find (band_name);
if (band_index < 0) // this shouldn't happen if (band_index < 0) // this shouldn't happen
{ {
@ -444,7 +444,7 @@ auto WSPRBandHopping::next_hop (bool tx_enabled) -> Hop
else else
{ {
band_index += 3; 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 // remove from random permutations to stop the coordinated bands
// getting too high a weighting - not perfect but surely helps // getting too high a weighting - not perfect but surely helps
m_->rx_permutation_.removeOne (band_name); m_->rx_permutation_.removeOne (band_name);

View File

@ -40,7 +40,7 @@ class QWidget;
// storage using the provided QSettings object instance. // storage using the provided QSettings object instance.
// //
// A passed in Configuration object instance is used to query the // 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 // band. The row index of this model is returned by this classes
// hopping scheduling method so it may be conveniently used to select // hopping scheduling method so it may be conveniently used to select
// a new working frequency by a client. // a new working frequency by a client.

View File

@ -601,11 +601,11 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
// Hook up working frequencies. // Hook up working frequencies.
ui->bandComboBox->setModel (m_config.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, // 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 // 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. // Enable live band combo box entry validation and action.
auto band_validator = new LiveFrequencyValidator {ui->bandComboBox 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) void MainWindow::on_bandComboBox_currentIndexChanged (int index)
{ {
auto const& frequencies = m_config.frequencies (); 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}; Frequency frequency {m_freqNominal};
if (source_index.isValid ()) if (source_index.isValid ())
{ {
@ -5183,7 +5183,7 @@ void MainWindow::on_bandComboBox_currentIndexChanged (int index)
void MainWindow::on_bandComboBox_activated (int index) void MainWindow::on_bandComboBox_activated (int index)
{ {
auto const& frequencies = m_config.frequencies (); 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}; Frequency frequency {m_freqNominal};
if (source_index.isValid ()) if (source_index.isValid ())
{ {

View File

@ -396,7 +396,7 @@ private:
qint32 m_k0; qint32 m_k0;
qint32 m_kdone; qint32 m_kdone;
qint32 m_nPick; 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_nTx73;
qint32 m_UTCdisk; qint32 m_UTCdisk;
qint32 m_wait; qint32 m_wait;