JS8Call-Improved master
Loading...
Searching...
No Matches
IARURegions.h
1#ifndef IARU_REGIONS_HPP__
2#define IARU_REGIONS_HPP__
3
4#include "qt_helpers.h"
5
6#include <QAbstractListModel>
7
8class QString;
9class QVariant;
10class QModelIndex;
11
12//
13// Class IARURegions - Qt model that implements the list of IARU regions
14//
15//
16// Responsibilities
17//
18// Provides a single column list model that contains the human
19// readable string version of the data region in the display
20// role. Also provided is a translatable column header string and
21// tool tip string.
22//
23//
24// Collaborations
25//
26// Implements a concrete sub-class of the QAbstractListModel class.
27//
28class IARURegions final : public QAbstractListModel {
29 Q_OBJECT
30
31 public:
32 //
33 // This enumeration contains the supported regions, to complement
34 // this an array of human readable strings in the implementation
35 // (IARURegions.cpp) must be maintained in parallel.
36 //
37 enum Region {
38 ALL, // matches with all regions
39 R1,
40 R2,
41 R3,
42 SENTINAL // this must be last
43 };
44 Q_ENUM(Region)
45
46 explicit IARURegions(QObject *parent = nullptr);
47
48 // translate between enumeration and human readable strings
49 static char const *name(Region);
50 static Region value(QString const &);
51
52 // Implement the QAbstractListModel interface
53 int rowCount(QModelIndex const &parent = QModelIndex{}) const override {
54 return parent.isValid()
55 ? 0
56 : SENTINAL; // Number of regionss in Region enumeration class
57 }
58 QVariant data(QModelIndex const &,
59 int role = Qt::DisplayRole) const override;
60 QVariant headerData(int section, Qt::Orientation,
61 int = Qt::DisplayRole) const override;
62};
63
64// Qt boilerplate to make the IARURegions::region enumeration a type
65// that can be streamed and queued as a signal argument as well as
66// showing the human readable string when output to debug streams.
67
68#if !defined(QT_NO_DEBUG_STREAM)
69ENUM_QDEBUG_OPS_DECL(IARURegions, Region);
70#endif
71
72ENUM_QDATASTREAM_OPS_DECL(IARURegions, Region);
73ENUM_CONVERSION_OPS_DECL(IARURegions, Region);
74
75#endif
Definition IARURegions.h:28