WSJT-X/LiveFrequencyValidator.hpp
Bill Somerville 858829c184 Merged from trunk:
------------------------------------------------------------------------
r8018 | bsomervi | 2017-08-09 17:06:17 +0100 (Wed, 09 Aug 2017) | 6 lines

Fix issue with v1.8.0 trashing v1.7 working frequencies

Note  that  reverting  to  v1.7  will  invalidate  any  saved  working
frequencies  from v1.8  but proceeding  to v1.8  again will  present a
reset set of working frequencies i.e. any user defined entries in v1.8
will be lost of a v1.8 -> v1.7 -> v1.8 transition is made.
------------------------------------------------------------------------



git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx-1.8@8019 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2017-08-09 16:10:08 +00:00

55 lines
1.4 KiB
C++

#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