diff options
Diffstat (limited to 'validators')
| -rwxr-xr-x | validators/LiveFrequencyValidator.cpp | 8 | ||||
| -rwxr-xr-x | validators/LiveFrequencyValidator.hpp | 3 |
2 files changed, 8 insertions, 3 deletions
diff --git a/validators/LiveFrequencyValidator.cpp b/validators/LiveFrequencyValidator.cpp index 01034c54..6bd826d7 100755 --- a/validators/LiveFrequencyValidator.cpp +++ b/validators/LiveFrequencyValidator.cpp @@ -14,6 +14,7 @@ LiveFrequencyValidator::LiveFrequencyValidator (QComboBox * combo_box , Bands const * bands
, FrequencyList_v2_101 const * frequencies
, Frequency const * nominal_frequency
+ , bool kHz_without_k
, QWidget * parent)
: QRegExpValidator {
QRegExp { // frequency in MHz or band
@@ -33,6 +34,7 @@ LiveFrequencyValidator::LiveFrequencyValidator (QComboBox * combo_box , frequencies_ {frequencies}
, nominal_frequency_ {nominal_frequency}
, combo_box_ {combo_box}
+ , kHz_without_k_ {kHz_without_k}
{
}
@@ -49,7 +51,7 @@ void LiveFrequencyValidator::fixup (QString& input) const QRegExpValidator::fixup (input);
if (!bands_->oob ().startsWith (input))
{
- if (input.contains ('m', Qt::CaseInsensitive))
+ if (input.contains ('m', Qt::CaseSensitive))
{
input = input.toLower ();
@@ -70,7 +72,7 @@ void LiveFrequencyValidator::fixup (QString& input) const input = QString {};
}
}
- else if (input.contains (QChar {'k'}, Qt::CaseInsensitive))
+ else if ((input.contains (QChar {'k'}, Qt::CaseInsensitive)) or (kHz_without_k_ && !input.contains (QChar {'M'}, Qt::CaseSensitive)))
{
// kHz in current MHz input
auto f = Radio::frequency (input.remove (QChar {'k'}, Qt::CaseInsensitive), 3);
@@ -81,7 +83,7 @@ void LiveFrequencyValidator::fixup (QString& input) const else
{
// frequency input
- auto f = Radio::frequency (input, 6);
+ auto f = Radio::frequency (input.remove (QChar {'M'}, Qt::CaseSensitive), 6);
input = bands_->find (f);
Q_EMIT valid (f);
}
diff --git a/validators/LiveFrequencyValidator.hpp b/validators/LiveFrequencyValidator.hpp index 48c78dc1..7f19c25a 100755 --- a/validators/LiveFrequencyValidator.hpp +++ b/validators/LiveFrequencyValidator.hpp @@ -5,6 +5,7 @@ #include <QRegExpValidator>
#include "Radio.hpp"
+#include "Configuration.hpp"
class Bands;
class FrequencyList_v2_101;
@@ -37,6 +38,7 @@ public: , Bands const * bands // bands model
, FrequencyList_v2_101 const * frequencies // working frequencies model
, Frequency const * nominal_frequency
+ , bool kHz_without_k
, QWidget * parent = nullptr);
State validate (QString& input, int& pos) const override;
@@ -49,6 +51,7 @@ private: FrequencyList_v2_101 const * frequencies_;
Frequency const * nominal_frequency_;
QComboBox * combo_box_;
+ bool kHz_without_k_ = false;
};
#endif
|
