File: LiveFrequencyValidator.hpp

package info (click to toggle)
jtdx 2.2.159%2Bimproved-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 75,336 kB
  • sloc: cpp: 38,503; f90: 31,141; python: 27,061; ansic: 11,772; sh: 409; fortran: 353; makefile: 232
file content (54 lines) | stat: -rw-r--r-- 1,485 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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