libdrmconf  0.12.0
A library to program DMR radios.
scanlist.hh
1 #ifndef SCANLIST_HH
2 #define SCANLIST_HH
3 
4 #include "configobject.hh"
5 #include "configreference.hh"
6 
7 #include "tyt_extensions.hh"
8 
9 class Channel;
10 
11 
14 class ScanList : public ConfigObject
15 {
16  Q_OBJECT
17  Q_CLASSINFO("IdPrefix", "scan")
18 
19 
20  Q_PROPERTY(ChannelReference* primary READ primary)
22  Q_PROPERTY(ChannelReference* secondary READ secondary)
24  Q_PROPERTY(ChannelReference* revert READ revert)
26  Q_PROPERTY(ChannelRefList * channels READ channels)
27 
28 
30 
31 public:
33  Q_INVOKABLE explicit ScanList(QObject *parent=nullptr);
35  ScanList(const QString &name, QObject *parent=nullptr);
36 
38  ScanList &operator= (const ScanList &other);
39  ConfigItem *clone() const;
40 
42  int count() const;
44  void clear();
45 
47  bool contains(Channel *channel) const;
49  Channel *channel(int idx) const;
51  int addChannel(Channel *channel, int idx=-1);
53  bool remChannel(int idx);
55  bool remChannel(Channel *channel);
56 
58  const ChannelRefList *channels() const;
61 
63  const ChannelReference *primary() const;
67  Channel *primaryChannel() const;
70 
72  const ChannelReference *secondary() const;
76  Channel *secondaryChannel() const;
79 
81  const ChannelReference *revert() const;
85  Channel *revertChannel() const;
88 
93 
94 protected:
105 
106 };
107 
108 
112 {
113  Q_OBJECT
114 
115 public:
117  explicit ScanLists(QObject *parent = nullptr);
118 
120  ScanList *scanlist(int idx) const;
121 
122  int add(ConfigObject *obj, int row=-1, bool unique=true);
123 
124 public:
125  ConfigItem *allocateChild(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack());
126 };
127 
128 
129 #endif // SCANLIST_HH
Represents a list of weak references to channels (analog and digital).
Definition: configreference.hh:163
Represents a reference to a channel.
Definition: configreference.hh:123
The base class of all channels (analog and digital) of a codeplug configuration.
Definition: channel.hh:34
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:349
Base class of all labeled and named objects.
Definition: configobject.hh:199
QString name
The name of the object.
Definition: configobject.hh:203
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
Generic representation of a scan list.
Definition: scanlist.hh:15
ScanList & operator=(const ScanList &other)
Copies the given scan list.
Definition: scanlist.cc:38
ChannelReference * secondary
The secondary channel.
Definition: scanlist.hh:22
ConfigItem * clone() const
Clones this item.
Definition: scanlist.cc:44
void clear()
Clears the scan list.
Definition: scanlist.cc:54
Channel * channel(int idx) const
Returns the channel at the given index.
Definition: scanlist.cc:84
ChannelRefList * channels
The list of channels.
Definition: scanlist.hh:26
ChannelReference _secondary
The secondary priority channel.
Definition: scanlist.hh:100
ChannelReference _primary
The priority channel.
Definition: scanlist.hh:98
void setSecondaryChannel(Channel *channel)
Sets the secondary priority channel.
Definition: scanlist.cc:147
TyTScanListExtension * tytScanListExtension() const
Returns the TyT scan-list extension instance (if set).
Definition: scanlist.cc:175
ChannelReference * primary()
Returns the primary channel reference.
bool remChannel(int idx)
Removes the channel at the given index.
Definition: scanlist.cc:97
Channel * primaryChannel() const
Returns the priority channel.
Definition: scanlist.cc:120
Channel * revertChannel() const
Returns the TX channel.
Definition: scanlist.cc:164
int count() const
Returns the number of channels within the scanlist.
Definition: scanlist.cc:74
ChannelRefList _channels
The channel list.
Definition: scanlist.hh:96
Q_INVOKABLE ScanList(QObject *parent=nullptr)
Default constructor.
Definition: scanlist.cc:17
ChannelReference * revert
The revert channel.
Definition: scanlist.hh:24
Channel * secondaryChannel() const
Returns the secondary priority channel.
Definition: scanlist.cc:142
ChannelReference * primary
The primary channel.
Definition: scanlist.hh:20
void setPrimaryChannel(Channel *channel)
Sets the priority channel.
Definition: scanlist.cc:125
ChannelReference _revert
The transmit channel.
Definition: scanlist.hh:102
ChannelReference * revert()
Returns the revert channel reference.
bool contains(Channel *channel) const
Returns true if the given channel is part of this scanlist.
Definition: scanlist.cc:79
ChannelReference * secondary()
Returns the secondary channel reference.
int addChannel(Channel *channel, int idx=-1)
Adds a channel to the scan list.
Definition: scanlist.cc:89
void setRevertChannel(Channel *channel)
Sets the TX channel.
Definition: scanlist.cc:169
TyTScanListExtension * _tyt
TyT scan-list settings extension.
Definition: scanlist.hh:104
void setTyTScanListExtension(TyTScanListExtension *tyt)
Sets the TyT scan-list extension.
Definition: scanlist.cc:179
TyTScanListExtension * tyt
The TyT scan-list extension.
Definition: scanlist.hh:29
ChannelRefList * channels()
Returns the channels of the scan list.
Represents the list of scan lists.
Definition: scanlist.hh:112
int add(ConfigObject *obj, int row=-1, bool unique=true)
Adds an element to the list.
Definition: scanlist.cc:207
ScanList * scanlist(int idx) const
Returns the scanlist at the given index.
Definition: scanlist.cc:200
ScanLists(QObject *parent=nullptr)
Constructs an empty list.
Definition: scanlist.cc:193
ConfigItem * allocateChild(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err=ErrorStack())
Allocates a member objects for the given YAML node.
Definition: scanlist.cc:214
Represents device specific scan-list settings for TyT devices.
Definition: tyt_extensions.hh:214