Fix an issue with editing IARU regions in the working frequencies table

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@8166 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2017-10-13 22:34:10 +00:00
parent ac1378daa9
commit a9a1ac1d7a
4 changed files with 27 additions and 25 deletions

View File

@ -237,7 +237,7 @@ public:
{
return {frequency_line_edit_.frequency ()
, Modes::value (mode_combo_box_.currentText ())
, IARURegions::value (region_combo_box_.currentIndex ())};
, IARURegions::value (region_combo_box_.currentText ())};
}
private:
@ -1851,7 +1851,7 @@ void Configuration::impl::accept ()
macros_.setStringList (next_macros_.stringList ());
}
region_ = IARURegions::value (ui_->region_combo_box->currentIndex ());
region_ = IARURegions::value (ui_->region_combo_box->currentText ());
if (frequencies_.frequency_list () != next_frequencies_.frequency_list ())
{

View File

@ -610,9 +610,8 @@ bool FrequencyList_v2::impl::setData (QModelIndex const& model_index, QVariant c
switch (model_index.column ())
{
case region_column:
if (value.canConvert<Region> ())
{
auto region = static_cast<Region> (value.toUInt ());
auto region = IARURegions::value (value.toString ());
if (region != item.region_)
{
item.region_ = region;
@ -623,7 +622,6 @@ bool FrequencyList_v2::impl::setData (QModelIndex const& model_index, QVariant c
break;
case mode_column:
if (value.canConvert<Mode> ())
{
auto mode = Modes::value (value.toString ());
if (mode != item.mode_)

View File

@ -34,10 +34,14 @@ char const * IARURegions::name (Region r)
return region_names[static_cast<int> (r)];
}
auto IARURegions::value (int r) -> Region
auto IARURegions::value (QString const& s) -> Region
{
if (r < 0 || r + 1 >= SENTINAL) return ALL;
return static_cast<Region> (r);
auto end = region_names + region_names_size;
auto p = std::find_if (region_names, end
, [&s] (char const * const name) {
return name == s;
});
return p != end ? static_cast<Region> (p - region_names) : ALL;
}
QVariant IARURegions::data (QModelIndex const& index, int role) const

View File

@ -51,7 +51,7 @@ public:
// translate between enumeration and human readable strings
static char const * name (Region);
static Region value (int);
static Region value (QString const&);
// Implement the QAbstractListModel interface
int rowCount (QModelIndex const& parent = QModelIndex {}) const override