libdrmconf 0.15.0
A library to program DMR radios.
Loading...
Searching...
No Matches
contact.hh
1#ifndef CONTACT_HH
2#define CONTACT_HH
3
4#include "configobject.hh"
5#include <QVector>
6#include <QAbstractTableModel>
7
8#include "anytone_extension.hh"
9#include "opengd77_extension.hh"
10
11class Config;
12
13
17class Contact: public ConfigObject
18{
19 Q_OBJECT
20 Q_CLASSINFO("IdPrefix", "cont")
21
22
23 Q_PROPERTY(bool ring READ ring WRITE setRing)
24
25protected:
27 explicit Contact(QObject *parent=nullptr);
32 Contact(const QString &name, bool ring=true, QObject *parent=nullptr);
33
34public:
35 void clear();
36
37public:
39 bool ring() const;
41 void setRing(bool enable);
42
46 template <class T>
47 bool is() const {
48 return 0 != dynamic_cast<const T *>(this);
49 }
50
51 template<class T>
52 T *as() {
53 return dynamic_cast<T *>(this);
54 }
55
56 template<class T>
57 const T *as() const {
58 return dynamic_cast<const T *>(this);
59 }
60
61public:
62 bool parse(const YAML::Node &node, Context &ctx, const ErrorStack &err=ErrorStack());
63 bool link(const YAML::Node &node, const Context &ctx, const ErrorStack &err=ErrorStack());
64
65protected:
67 bool _ring;
68};
69
70
74{
75 Q_OBJECT
76
77protected:
79 explicit AnalogContact(QObject *parent=nullptr);
80
82 AnalogContact(const QString &name, bool rxTone, QObject *parent=nullptr);
83};
84
85
89{
90 Q_OBJECT
91
93 Q_PROPERTY(QString number READ number WRITE setNumber)
94
95public:
97 Q_INVOKABLE explicit DTMFContact(QObject *parent=nullptr);
103 DTMFContact(const QString &name, const QString &number, bool ring=false, QObject *parent=nullptr);
104
105 ConfigItem *clone() const;
106 void clear();
107
110 const QString &number() const;
112 bool setNumber(const QString &number);
113
114public:
115 YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack());
116
117protected:
119 QString _number;
120};
121
122
126{
127 Q_OBJECT
128
129protected:
131 explicit DigitalContact(QObject *parent=nullptr);
132
134 DigitalContact(const QString &name, bool ring, QObject *parent=nullptr);
135};
136
137
141{
142 Q_OBJECT
143
145 Q_PROPERTY(Type type READ type WRITE setType)
147 Q_PROPERTY(unsigned number READ number WRITE setNumber)
152
153public:
160 Q_ENUM(Type)
161
162public:
164 Q_INVOKABLE explicit DMRContact(QObject *parent=nullptr);
165
172 DMRContact(Type type, const QString &name, unsigned number, bool ring=false, QObject *parent=nullptr);
173
174 ConfigItem *clone() const;
175 void clear();
176
178 Type type() const;
180 void setType(Type type);
182 unsigned number() const;
184 bool setNumber(unsigned number);
185
190
195
196public:
197 YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack());
198
199protected:
203 unsigned _number;
208};
209
210
214{
215 Q_OBJECT
216
218 Q_PROPERTY(QString call READ call WRITE setCall)
220 Q_PROPERTY(bool isBroadcast READ isBroadcast WRITE setBroadcast)
221
222public:
224 explicit M17Contact(QObject *parent=nullptr);
230 M17Contact(const QString &name, bool ring, const QString &call, QObject *parent=nullptr);
231
232 ConfigItem *clone() const;
233 void clear();
234
236 const QString &call() const;
238 void setCall(const QString &call);
240 bool isBroadcast() const;
242 void setBroadcast(bool enable);
243
244public:
245 YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack());
246
248 static QString normalizeCall(const QString call);
249
250protected:
254 QString _call;
255};
256
257
270{
271 Q_OBJECT
272
273public:
275 explicit ContactList(QObject *parent=nullptr);
276
277 int add(ConfigObject *obj, int row=-1, bool unique=true);
278
280 [[deprecated("Use indexing instead.")]] int digitalCount() const;
282 [[deprecated("Use indexing instead.")]] int dtmfCount() const;
283
285 Contact *contact(int idx) const;
287 [[deprecated("Use indexing instead.")]] DMRContact *digitalContact(int idx) const;
289 [[deprecated("Use indexing instead.")]] DTMFContact *dtmfContact(int idx) const;
290
291public:
292 ConfigItem *allocateChild(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack());
293};
294
295#endif // CONTACT_HH
AnalogContact(QObject *parent=nullptr)
Hidden constructor.
Definition contact.cc:64
Implements the AnyTone contact extension.
Definition anytone_extension.hh:274
Parse context for config objects.
Definition configobject.hh:43
Base class for all configuration objects (channels, zones, contacts, etc).
Definition configobject.hh:35
virtual ConfigItem * allocateChild(QMetaProperty &prop, const YAML::Node &node, const Context &ctx, const ErrorStack &err=ErrorStack())
Allocates an instance for the given property on the given YAML node.
Definition configobject.cc:542
ConfigObjectList(const QMetaObject &elementTypes=ConfigItem::staticMetaObject, QObject *parent=nullptr)
Hidden constructor.
Definition configobject.cc:1511
Base class of all labeled and named objects.
Definition configobject.hh:192
ConfigObject(QObject *parent=nullptr)
Specifies the prefix for every ID assigned to every object during serialization.
Definition configobject.cc:1141
QString name
The name of the object.
Definition configobject.hh:196
The config class, representing the codeplug configuration.
Definition config.hh:70
Contact * contact(int idx) const
Returns the contact at index idx.
Definition contact.cc:345
int dtmfCount() const
Returns the number of DTMF contacts.
int digitalCount() const
Returns the number of digital contacts.
DMRContact * digitalContact(int idx) const
Returns the digital contact at index idx among digital contacts.
DTMFContact * dtmfContact(int idx) const
Returns the DTMF contact at index idx among DTMF contacts.
ContactList(QObject *parent=nullptr)
Constructs an empty contact list.
Definition contact.cc:331
int add(ConfigObject *obj, int row=-1, bool unique=true)
Adds an element to the list.
Definition contact.cc:338
Represents the base-class for all contact types, analog (DTMF) or digital (DMR, M17).
Definition contact.hh:18
bool link(const YAML::Node &node, const Context &ctx, const ErrorStack &err=ErrorStack())
Links the given object to the rest of the codeplug using the given context.
Definition contact.cc:56
void setRing(bool enable)
Enables/disables the ring-tone for this contact.
Definition contact.cc:35
bool parse(const YAML::Node &node, Context &ctx, const ErrorStack &err=ErrorStack())
Parses the given YAML node, updates the given object and updates the given context (IDs).
Definition contact.cc:41
const T * as() const
Typecast contact.
Definition contact.hh:57
Contact(QObject *parent=nullptr)
Default constructor.
Definition contact.cc:12
void clear()
Clears the config object.
Definition contact.cc:25
T * as()
Typecast contact.
Definition contact.hh:52
bool is() const
Typecheck contact.
Definition contact.hh:47
bool _ring
Ringtone enabled?
Definition contact.hh:67
bool ring
If true and supported by radio, ring on call from this contact.
Definition contact.hh:23
Represents a digital contact, that is a DMR number.
Definition contact.hh:141
void setAnytoneExtension(AnytoneContactExtension *ext)
Sets the AnyTone extension.
Definition contact.cc:245
void clear()
Clears the config object.
Definition contact.cc:176
AnytoneContactExtension * anytone
The AnyTone extension to the digital contact.
Definition contact.hh:149
OpenGD77ContactExtension * openGD77ContactExtension() const
Returns the OpenGD77 extension, or nullptr if not set.
Definition contact.cc:223
OpenGD77ContactExtension * _openGD77
Owns the OpenGD77 extensions to the digital contacts.
Definition contact.hh:207
ConfigItem * clone() const
Clones this item.
Definition contact.cc:166
Type type
The type of the contact.
Definition contact.hh:145
void setOpenGD77ContactExtension(OpenGD77ContactExtension *ext)
Sets the OpenGD77 extension.
Definition contact.cc:228
Q_INVOKABLE DMRContact(QObject *parent=nullptr)
Default constructor.
Definition contact.cc:153
AnytoneContactExtension * anytoneExtension() const
Returns the AnyTone extension, or nullptr if not set.
Definition contact.cc:240
OpenGD77ContactExtension * openGD77
The OpenGD77 extension to the digital contact.
Definition contact.hh:151
unsigned _number
The DMR number of the contact.
Definition contact.hh:203
void setType(Type type)
(Re-)Sets the call-type.
Definition contact.cc:194
bool setNumber(unsigned number)
(Re-)Sets the DMR number of the contact.
Definition contact.cc:204
unsigned number
The number of the contact.
Definition contact.hh:147
Type _type
The call type.
Definition contact.hh:201
Type
Possible call types for a contact.
Definition contact.hh:155
@ AllCall
An all-call.
Definition contact.hh:158
@ PrivateCall
A private call.
Definition contact.hh:156
@ GroupCall
A group call.
Definition contact.hh:157
AnytoneContactExtension * _anytone
Owns the AnytoneContactextension to the digital contacts.
Definition contact.hh:205
YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack())
Recursively serializes the configuration to YAML nodes.
Definition contact.cc:211
Represents an analog contact, that is a DTMF number.
Definition contact.hh:89
YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack())
Recursively serializes the configuration to YAML nodes.
Definition contact.cc:123
bool setNumber(const QString &number)
(Re-)Sets the DTMF number of this contact.
Definition contact.cc:114
ConfigItem * clone() const
Clones this item.
Definition contact.cc:93
QString number
The contact number.
Definition contact.hh:93
Q_INVOKABLE DTMFContact(QObject *parent=nullptr)
Default constructor.
Definition contact.cc:80
void clear()
Clears the config object.
Definition contact.cc:103
QString _number
The DTMF number.
Definition contact.hh:119
DigitalContact(QObject *parent=nullptr)
Hidden constructor.
Definition contact.cc:137
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition errorstack.hh:43
static QString normalizeCall(const QString call)
Helper function to normalize a call.
Definition contact.cc:321
void setBroadcast(bool enable)
Sets/Resets the broadcast flag.
Definition contact.cc:305
YAML::Node serialize(const Context &context, const ErrorStack &err=ErrorStack())
Recursively serializes the configuration to YAML nodes.
Definition contact.cc:310
void clear()
Clears the config object.
Definition contact.cc:283
bool _isBroadcast
If true, the contact is the M17 broadcast contact.
Definition contact.hh:252
M17Contact(QObject *parent=nullptr)
Empty constructor.
Definition contact.cc:260
QString _call
Holds the normalized call/ID of the contact.
Definition contact.hh:254
QString call
The call of the contact.
Definition contact.hh:218
ConfigItem * clone() const
Clones this item.
Definition contact.cc:273
bool isBroadcast
If true, the contact is the M17 broadcast destination.
Definition contact.hh:220
void setCall(const QString &call)
Sets the call/ID of the contact.
Definition contact.cc:295
Implements the contact extensions for the OpenGD77 radios.
Definition opengd77_extension.hh:121