mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-12 07:06:17 -05:00
Allow for HRD on rigs where more than one mode maps to Tranceiver::MODE.
Some rigs like the FT-857(D) have multiple modes that only have one representation in the Transceiver class, e.g. FM, FM(N) and WFM. The HRDTransceiver class now allows multiple modes to be mapped to one Transceiver::MODE, the last match in the HRD mode dropdown is used when mapping a Tranceiver::MODE to a HRD mode setting which is normally the most suitable mode. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4135 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
d7471d2876
commit
54a2f51d38
@ -303,9 +303,22 @@ int HRDTransceiver::find_dropdown (QRegExp const& re) const
|
|||||||
return dropdown_names_.indexOf (re);
|
return dropdown_names_.indexOf (re);
|
||||||
}
|
}
|
||||||
|
|
||||||
int HRDTransceiver::find_dropdown_selection (int dropdown, QRegExp const& re) const
|
std::vector<int> HRDTransceiver::find_dropdown_selection (int dropdown, QRegExp const& re) const
|
||||||
{
|
{
|
||||||
return dropdowns_.value (dropdown_names_.value (dropdown)).lastIndexOf (re); // backwards because more specialised modes tend to be later in list
|
std::vector<int> indices;
|
||||||
|
auto list = dropdowns_.value (dropdown_names_.value (dropdown));
|
||||||
|
int index {0};
|
||||||
|
while (-1 != (index = list.lastIndexOf (re, index - 1)))
|
||||||
|
{
|
||||||
|
// search backwards because more specialized modes tend to be later in
|
||||||
|
// list
|
||||||
|
indices.push_back (index);
|
||||||
|
if (!index)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return indices;
|
||||||
}
|
}
|
||||||
|
|
||||||
int HRDTransceiver::lookup_dropdown_selection (int dropdown, QString const& selection) const
|
int HRDTransceiver::lookup_dropdown_selection (int dropdown, QString const& selection) const
|
||||||
@ -335,8 +348,8 @@ void HRDTransceiver::map_modes (int dropdown, ModeMap *map)
|
|||||||
|
|
||||||
std::for_each (map->begin (), map->end (), [this, dropdown] (ModeMap::value_type const& item)
|
std::for_each (map->begin (), map->end (), [this, dropdown] (ModeMap::value_type const& item)
|
||||||
{
|
{
|
||||||
auto rhs = std::get<1> (item);
|
auto const& rhs = std::get<1> (item);
|
||||||
qDebug () << '\t' << std::get<0> (item) << "<->" << (rhs >= 0 ? dropdowns_[dropdown_names_[dropdown]][rhs] : "None");
|
qDebug () << '\t' << std::get<0> (item) << "<->" << (rhs.size () ? dropdowns_[dropdown_names_[dropdown]][rhs.front ()] : "None");
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -348,12 +361,16 @@ int HRDTransceiver::lookup_mode (MODE mode, ModeMap const& map) const
|
|||||||
{
|
{
|
||||||
throw error {tr ("Ham Radio Deluxe: rig doesn't support mode")};
|
throw error {tr ("Ham Radio Deluxe: rig doesn't support mode")};
|
||||||
}
|
}
|
||||||
return std::get<1> (*it);
|
return std::get<1> (*it).front ();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto HRDTransceiver::lookup_mode (int mode, ModeMap const& map) const -> MODE
|
auto HRDTransceiver::lookup_mode (int mode, ModeMap const& map) const -> MODE
|
||||||
{
|
{
|
||||||
auto it = std::find_if (map.begin (), map.end (), [mode] (ModeMap::value_type const& item) {return std::get<1> (item) == mode;});
|
auto it = std::find_if (map.begin (), map.end (), [mode] (ModeMap::value_type const& item)
|
||||||
|
{
|
||||||
|
auto const& indices = std::get<1> (item);
|
||||||
|
return indices.cend () != std::find (indices.cbegin (), indices.cend (), mode);
|
||||||
|
});
|
||||||
if (map.end () == it)
|
if (map.end () == it)
|
||||||
{
|
{
|
||||||
throw error {tr ("Ham Radio Deluxe: sent an unrecognised mode")};
|
throw error {tr ("Ham Radio Deluxe: sent an unrecognised mode")};
|
||||||
@ -503,7 +520,7 @@ void HRDTransceiver::do_tx_frequency (Frequency tx, bool rationalise_mode)
|
|||||||
}
|
}
|
||||||
else if (split_mode_dropdown_ >= 0)
|
else if (split_mode_dropdown_ >= 0)
|
||||||
{
|
{
|
||||||
set_dropdown (split_mode_dropdown_, split ? split_mode_dropdown_selection_on_ : split_mode_dropdown_selection_off_);
|
set_dropdown (split_mode_dropdown_, split ? split_mode_dropdown_selection_on_.front () : split_mode_dropdown_selection_off_.front ());
|
||||||
}
|
}
|
||||||
else if (vfo_A_button_ >= 0 && vfo_B_button_ >= 0 && tx_A_button_ >= 0 && tx_B_button_ >= 0)
|
else if (vfo_A_button_ >= 0 && vfo_B_button_ >= 0 && tx_A_button_ >= 0 && tx_B_button_ >= 0)
|
||||||
{
|
{
|
||||||
@ -586,7 +603,7 @@ void HRDTransceiver::poll ()
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
update_split (get_dropdown (split_mode_dropdown_, quiet) == split_mode_dropdown_selection_on_);
|
update_split (get_dropdown (split_mode_dropdown_, quiet) == split_mode_dropdown_selection_on_.front ());
|
||||||
}
|
}
|
||||||
catch (error const&)
|
catch (error const&)
|
||||||
{
|
{
|
||||||
|
@ -50,14 +50,14 @@ private:
|
|||||||
void sync_impl ();
|
void sync_impl ();
|
||||||
int find_button (QRegExp const&) const;
|
int find_button (QRegExp const&) const;
|
||||||
int find_dropdown (QRegExp const&) const;
|
int find_dropdown (QRegExp const&) const;
|
||||||
int find_dropdown_selection (int dropdown, QRegExp const&) const;
|
std::vector<int> find_dropdown_selection (int dropdown, QRegExp const&) const;
|
||||||
int lookup_dropdown_selection (int dropdown, QString const&) const;
|
int lookup_dropdown_selection (int dropdown, QString const&) const;
|
||||||
int get_dropdown (int, bool no_debug = false);
|
int get_dropdown (int, bool no_debug = false);
|
||||||
void set_dropdown (int, int);
|
void set_dropdown (int, int);
|
||||||
void set_button (int button_index, bool checked = true);
|
void set_button (int button_index, bool checked = true);
|
||||||
bool is_button_checked (int button_index, bool no_debug = false);
|
bool is_button_checked (int button_index, bool no_debug = false);
|
||||||
|
|
||||||
using ModeMap = std::vector<std::tuple<MODE, int> >;
|
using ModeMap = std::vector<std::tuple<MODE, std::vector<int> > >;
|
||||||
void map_modes (int dropdown, ModeMap *);
|
void map_modes (int dropdown, ModeMap *);
|
||||||
int lookup_mode (MODE, ModeMap const&) const;
|
int lookup_mode (MODE, ModeMap const&) const;
|
||||||
MODE lookup_mode (int, ModeMap const&) const;
|
MODE lookup_mode (int, ModeMap const&) const;
|
||||||
@ -84,8 +84,8 @@ private:
|
|||||||
int split_mode_button_;
|
int split_mode_button_;
|
||||||
int split_mode_dropdown_;
|
int split_mode_dropdown_;
|
||||||
bool split_mode_dropdown_write_only_;
|
bool split_mode_dropdown_write_only_;
|
||||||
int split_mode_dropdown_selection_on_;
|
std::vector<int> split_mode_dropdown_selection_on_;
|
||||||
int split_mode_dropdown_selection_off_;
|
std::vector<int> split_mode_dropdown_selection_off_;
|
||||||
int split_off_button_;
|
int split_off_button_;
|
||||||
int tx_A_button_;
|
int tx_A_button_;
|
||||||
int tx_B_button_;
|
int tx_B_button_;
|
||||||
|
Loading…
Reference in New Issue
Block a user