1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
|
#include "scanlist.hh"
#include "channel.hh"
#include "config.hh"
/* ********************************************************************************************* *
* Implementation of ScanList
* ********************************************************************************************* */
ScanList::ScanList(QObject *parent)
: ConfigObject(parent), _channels(), _primary(), _secondary(), _revert(), _tyt(nullptr)
{
// Register "selected" channel tags for primary, secondary, revert and the channel list.
Context::setTag(staticMetaObject.className(), "primary", "!selected", SelectedChannel::get());
Context::setTag(staticMetaObject.className(), "secondary", "!selected", SelectedChannel::get());
Context::setTag(staticMetaObject.className(), "revert", "!selected", SelectedChannel::get());
Context::setTag(staticMetaObject.className(), "channels", "!selected", SelectedChannel::get());
}
ScanList::ScanList(const QString &name, QObject *parent)
: ConfigObject(name, parent), _channels(), _primary(), _secondary(), _revert(), _tyt(nullptr)
{
// Register "selected" channel tags for primary, secondary, revert and the channel list.
Context::setTag(staticMetaObject.className(), "primary", "!selected", SelectedChannel::get());
Context::setTag(staticMetaObject.className(), "secondary", "!selected", SelectedChannel::get());
Context::setTag(staticMetaObject.className(), "revert", "!selected", SelectedChannel::get());
Context::setTag(staticMetaObject.className(), "channels", "!selected", SelectedChannel::get());
}
ScanList &
ScanList::operator =(const ScanList &other) {
copy(other);
return *this;
}
ConfigItem *
ScanList::clone() const {
ScanList *list = new ScanList();
if (! list->copy(*this)) {
list->deleteLater();
return nullptr;
}
return list;
}
void
ScanList::clear() {
_name.clear();
_primary.clear();
_secondary.clear();
_revert.clear();
_channels.clear();
emit modified(this);
}
const ChannelRefList *
ScanList::channels() const {
return &_channels;
}
ChannelRefList *
ScanList::channels() {
return &_channels;
}
int
ScanList::count() const {
return _channels.count();
}
bool
ScanList::contains(Channel *channel) const {
return (0 <= _channels.indexOf(channel));
}
Channel *
ScanList::channel(int idx) const {
return _channels.get(idx)->as<Channel>();
}
int
ScanList::addChannel(Channel *channel, int idx) {
idx = _channels.add(channel, idx);
if (0 > idx)
return idx;
return idx;
}
bool
ScanList::remChannel(int idx) {
return _channels.del(_channels.get(idx));
emit modified(this);
return true;
}
bool
ScanList::remChannel(Channel *channel) {
return _channels.del(channel);
}
const ChannelReference *
ScanList::primary() const {
return &_primary;
}
ChannelReference *
ScanList::primary() {
return &_primary;
}
Channel *
ScanList::primaryChannel() const {
return _primary.as<Channel>();
}
void
ScanList::setPrimaryChannel(Channel *channel) {
_primary.set(channel);
emit modified(this);
}
const ChannelReference *
ScanList::secondary() const {
return &_secondary;
}
ChannelReference *
ScanList::secondary() {
return &_secondary;
}
Channel *
ScanList::secondaryChannel() const {
return _secondary.as<Channel>();
}
void
ScanList::setSecondaryChannel(Channel *channel) {
_secondary.set(channel);
emit modified(this);
}
const ChannelReference *
ScanList::revert() const {
return &_revert;
}
ChannelReference *
ScanList::revert() {
return &_revert;
}
Channel *
ScanList::revertChannel() const {
return _revert.as<Channel>();
}
void
ScanList::setRevertChannel(Channel *channel) {
_revert.set(channel);
emit modified(this);
}
TyTScanListExtension *
ScanList::tytScanListExtension() const {
return _tyt;
}
void
ScanList::setTyTScanListExtension(TyTScanListExtension *tyt) {
if (_tyt) {
_tyt->deleteLater();
_tyt = nullptr;
}
_tyt = tyt;
if (_tyt)
_tyt->setParent(this);
}
/* ********************************************************************************************* *
* Implementation of ScanLists
* ********************************************************************************************* */
ScanLists::ScanLists(QObject *parent)
: ConfigObjectList(ScanList::staticMetaObject, parent)
{
// pass...
}
ScanList *
ScanLists::scanlist(int idx) const {
if (ConfigItem *obj = get(idx))
return obj->as<ScanList>();
return nullptr;
}
int
ScanLists::add(ConfigObject *obj, int row, bool unique) {
if (obj && obj->is<ScanList>())
return ConfigObjectList::add(obj, row, unique);
return -1;
}
ConfigItem *
ScanLists::allocateChild(const YAML::Node &node, ConfigItem::Context &ctx, const ErrorStack &err) {
Q_UNUSED(ctx);
if (! node)
return nullptr;
if (! node.IsMap()) {
errMsg(err) << node.Mark().line << ":" << node.Mark().column
<< ": Cannot create scan list: Expected object.";
return nullptr;
}
return new ScanList();
}
|