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 Q_ENUMS(Region)
31
32 public:
33 //
34 // This enumeration contains the supported regions, to complement
35 // this an array of human readable strings in the implementation
36 // (IARURegions.cpp) must be maintained in parallel.
37 //
38 enum Region {
39 ALL, // matches with all regions
40 R1,
41 R2,
42 R3,
43 SENTINAL // this must be last
44 };
45 Q_ENUM(Region)
46
47 explicit IARURegions(QObject *parent = nullptr);
48
49 // translate between enumeration and human readable strings
50 static char const *name(Region);
51 static Region value(QString const &);
52
53 // Implement the QAbstractListModel interface
54 int rowCount(QModelIndex const &parent = QModelIndex{}) const override {
55 return parent.isValid()
56 ? 0
57 : SENTINAL; // Number of regionss in Region enumeration class
58 }
59 QVariant data(QModelIndex const &,
60 int role = Qt::DisplayRole) const override;
61 QVariant headerData(int section, Qt::Orientation,
62 int = Qt::DisplayRole) const override;
63};
64
65// Qt boilerplate to make the IARURegions::region enumeration a type
66// that can be streamed and queued as a signal argument as well as
67// showing the human readable string when output to debug streams.
68#if QT_VERSION < 0x050500
69// Qt 5.5 introduces the Q_ENUM macro which automatically registers
70// the meta-type
71Q_DECLARE_METATYPE(IARURegions::Region);
72#endif
73
74#if !defined(QT_NO_DEBUG_STREAM)
75ENUM_QDEBUG_OPS_DECL(IARURegions, Region);
76#endif
77
78ENUM_QDATASTREAM_OPS_DECL(IARURegions, Region);
79ENUM_CONVERSION_OPS_DECL(IARURegions, Region);
80
81#endif
Definition IARURegions.h:28