Add FrequencyList methods to retrieve band name sets

Start to rationalize the new WSPR code with the data models.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5475 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville
2015-05-31 11:51:40 +00:00
parent f1858dbb4f
commit 7abcef5057
6 changed files with 178 additions and 124 deletions
+40 -2
View File
@@ -173,8 +173,26 @@ int FrequencyList::best_working_frequency (Frequency f) const
auto const& target_band = m_->bands_->find (f);
if (!target_band.isEmpty ())
{
// find a frequency in the same band that is allowed for the
// target mode
// find a frequency in the same band that is allowed
for (int row = 0; row < rowCount (); ++row)
{
auto const& source_row = mapToSource (index (row, 0)).row ();
auto const& band = m_->bands_->find (m_->frequency_list_[source_row].frequency_);
if (band == target_band)
{
return row;
}
}
}
return result;
}
int FrequencyList::best_working_frequency (QString const& target_band) const
{
int result {-1};
if (!target_band.isEmpty ())
{
// find a frequency in the same band that is allowed
for (int row = 0; row < rowCount (); ++row)
{
auto const& source_row = mapToSource (index (row, 0)).row ();
@@ -553,3 +571,23 @@ auto FrequencyList::end () const -> FrequencyList::const_iterator
{
return const_iterator (this, rowCount ());
}
auto FrequencyList::all_bands () const -> BandSet
{
BandSet result;
for (auto const& item : m_->frequency_list_)
{
result << m_->bands_->find (item.frequency_);
}
return result;
}
auto FrequencyList::filtered_bands () const -> BandSet
{
BandSet result;
for (auto const& item : *this)
{
result << m_->bands_->find (item.frequency_);
}
return result;
}