libdrmconf  0.11.3
A library to program DMR radios.
roamingzone.hh
1 #ifndef ROAMINGZONE_HH
2 #define ROAMINGZONE_HH
3 
4 #include <QAbstractListModel>
5 #include "configreference.hh"
6 #include "roamingchannel.hh"
7 
14 class RoamingZone : public ConfigObject
15 {
16  Q_OBJECT
17  Q_CLASSINFO("IdPrefix", "roam")
18 
19 
22  Q_PROPERTY(RoamingChannelRefList * channels READ channels SCRIPTABLE false)
23 
24 public:
26  explicit RoamingZone(QObject *parent=nullptr);
27 
31  RoamingZone(const QString &name, QObject *parent = nullptr);
32 
34  RoamingZone &operator =(const RoamingZone &other);
35  ConfigItem *clone() const;
36 
38  int count() const;
39 
41  void clear();
42 
45  RoamingChannel *channel(int idx) const;
50  int addChannel(RoamingChannel *ch, int row=-1);
52  bool remChannel(int row);
54  bool remChannel(RoamingChannel *ch);
55 
57  const RoamingChannelRefList *channels() const;
60 
63  bool link(const YAML::Node &node, const Context &ctx, const ErrorStack &err);
66  bool populate(YAML::Node &node, const Context &context, const ErrorStack &err);
67 
68 protected:
71 };
72 
73 
79 {
80  Q_OBJECT
81 
82 protected:
85  explicit DefaultRoamingZone(QObject *parent=nullptr);
86 
87 public:
89  static DefaultRoamingZone *get();
90 
91 protected:
94 };
95 
96 
101 {
102  Q_OBJECT
103 
104 public:
106  explicit RoamingZoneList(QObject *parent=nullptr);
107 
109  RoamingZone *zone(int idx) const;
110 
111  int add(ConfigObject *obj, int row=-1);
112 
113 public:
114  ConfigItem *allocateChild(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack());
115 };
116 
117 #endif // ROAMINGZONE_HH
Parse context for config objects.
Definition: configobject.hh:48
Base class for all configuration objects (channels, zones, contacts, etc).
Definition: configobject.hh:40
List class for config objects.
Definition: configobject.hh:341
Base class of all labeled and named objects.
Definition: configobject.hh:199
QString name
The name of the object.
Definition: configobject.hh:203
Dummy roaming zone class that represents the default roaming zone.
Definition: roamingzone.hh:79
DefaultRoamingZone(QObject *parent=nullptr)
Hidden constructor.
Definition: roamingzone.cc:158
static DefaultRoamingZone * _instance
Holds a reference to the singleton instance of this class.
Definition: roamingzone.hh:93
static DefaultRoamingZone * get()
Returns the singleton instance of this class.
Definition: roamingzone.cc:165
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
Represents a list of references to some roaming channels.
Definition: configreference.hh:191
Represents a roaming channel.
Definition: roamingchannel.hh:16
Represents the list of roaming zones within the abstract device configuration.
Definition: roamingzone.hh:101
RoamingZoneList(QObject *parent=nullptr)
Constructor.
Definition: roamingzone.cc:175
RoamingZone * zone(int idx) const
Returns the roaming zone at the given index.
Definition: roamingzone.cc:182
int add(ConfigObject *obj, int row=-1)
Adds an element to the list.
Definition: roamingzone.cc:189
ConfigItem * allocateChild(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack())
Allocates a member objects for the given YAML node.
Definition: roamingzone.cc:196
Represents a RoamingZone within the abstract device configuration.
Definition: roamingzone.hh:15
ConfigItem * clone() const
Clones this item.
Definition: roamingzone.cc:28
RoamingChannelRefList * channels()
Returns the list of digital channels in this roaming zone.
void clear()
Clears the zone list.
Definition: roamingzone.cc:43
int addChannel(RoamingChannel *ch, int row=-1)
Adds a channel to the roaming zone.
Definition: roamingzone.cc:55
RoamingZone(QObject *parent=nullptr)
Default constructor.
Definition: roamingzone.cc:9
bool link(const YAML::Node &node, const Context &ctx, const ErrorStack &err)
Links the channel reference list.
Definition: roamingzone.cc:84
bool remChannel(int row)
Removes the channel from the roaming zone at index row.
Definition: roamingzone.cc:64
RoamingChannelRefList _channel
Holds the actual channels of the roaming zone.
Definition: roamingzone.hh:70
RoamingChannelRefList * channels
The channels in the roaming zone.
Definition: roamingzone.hh:22
RoamingZone & operator=(const RoamingZone &other)
Copies the given zone.
Definition: roamingzone.cc:22
bool populate(YAML::Node &node, const Context &context, const ErrorStack &err)
Serializes the channel reference list.
Definition: roamingzone.cc:135
int count() const
Returns the number of zones.
Definition: roamingzone.cc:38
RoamingChannel * channel(int idx) const
Returns the roaming channel, which is the member at index idx (0-based).
Definition: roamingzone.cc:48