summaryrefslogtreecommitdiff
path: root/validators/LiveFrequencyValidator.hpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2018-12-19 22:58:32 +0100
committerChristoph Berg <myon@debian.org>2018-12-19 22:58:32 +0100
commite0737c56c1e384e05064a0c6e1ac46979371041b (patch)
treea0123d694a2d36c43dabdf0a3907392fce11d457 /validators/LiveFrequencyValidator.hpp
parentb4aebf2d137b892f53503b13785ecae900062ff7 (diff)
New upstream version 2.0.0+repackupstream/2.0.0+repack
Diffstat (limited to 'validators/LiveFrequencyValidator.hpp')
-rw-r--r--validators/LiveFrequencyValidator.hpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/validators/LiveFrequencyValidator.hpp b/validators/LiveFrequencyValidator.hpp
new file mode 100644
index 00000000..823f8f74
--- /dev/null
+++ b/validators/LiveFrequencyValidator.hpp
@@ -0,0 +1,54 @@
+#ifndef LIVE_FREQUENCY_VALIDATOR_HPP__
+#define LIVE_FREQUENCY_VALIDATOR_HPP__
+
+#include <QObject>
+#include <QRegExpValidator>
+
+#include "Radio.hpp"
+
+class Bands;
+class FrequencyList_v2;
+class QComboBox;
+class QWidget;
+
+//
+// Class LiveFrequencyValidator
+//
+// QLineEdit validator that controls input to an editable
+// QComboBox where the user can enter a valid band or a valid
+// frequency in megahetz.
+//
+// Collabrations
+//
+// Implements the QRegExpValidator interface. Validates input
+// from the supplied QComboBox as either a valid frequency in
+// megahertz or a valid band as defined by the supplied column of
+// the supplied QAbstractItemModel.
+//
+class LiveFrequencyValidator final
+ : public QRegExpValidator
+{
+ Q_OBJECT;
+
+public:
+ using Frequency = Radio::Frequency;
+
+ LiveFrequencyValidator (QComboBox * combo_box // associated combo box
+ , Bands const * bands // bands model
+ , FrequencyList_v2 const * frequencies // working frequencies model
+ , Frequency const * nominal_frequency
+ , QWidget * parent = nullptr);
+
+ State validate (QString& input, int& pos) const override;
+ void fixup (QString& input) const override;
+
+ Q_SIGNAL void valid (Frequency) const;
+
+private:
+ Bands const * bands_;
+ FrequencyList_v2 const * frequencies_;
+ Frequency const * nominal_frequency_;
+ QComboBox * combo_box_;
+};
+
+#endif