diff options
| author | Iain R. Learmonth <irl@debian.org> | 2015-10-18 18:51:00 +0100 |
|---|---|---|
| committer | Iain R. Learmonth <irl@debian.org> | 2015-10-18 18:51:00 +0100 |
| commit | d63dd8d081a6fcd0715cd13f26df59fb831769d2 (patch) | |
| tree | b9c1f6245147a310aac3762630bad389bbb57335 /LiveFrequencyValidator.hpp | |
| parent | c720a3d55c5ec832c29cb7ce50b6fb4b70c55b11 (diff) | |
Imported Upstream version 1.5.0upstream/1.5.0
Diffstat (limited to 'LiveFrequencyValidator.hpp')
| -rw-r--r-- | LiveFrequencyValidator.hpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/LiveFrequencyValidator.hpp b/LiveFrequencyValidator.hpp new file mode 100644 index 00000000..d4d6cc69 --- /dev/null +++ b/LiveFrequencyValidator.hpp @@ -0,0 +1,52 @@ +#ifndef LIVE_FREQUENCY_VALIDATOR_HPP__
+#define LIVE_FREQUENCY_VALIDATOR_HPP__
+
+#include <QObject>
+#include <QRegExpValidator>
+
+#include "Radio.hpp"
+
+class Bands;
+class FrequencyList;
+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 const * frequencies // working frequencies model
+ , 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 const * frequencies_;
+ QComboBox * combo_box_;
+};
+
+#endif
|
