2
* Copyright (C) 2011 Tuomo Penttinen, all rights reserved.
4
* Author: Tuomo Penttinen <tp@herqq.org>
6
* This file is part of Herqq UPnP Av (HUPnPAv) library.
8
* Herqq UPnP Av is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
13
* Herqq UPnP Av is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with Herqq UPnP Av. If not, see <http://www.gnu.org/licenses/>.
23
#include <HUpnpCore/private/hmisc_utils_p.h>
25
#include <QtCore/QSet>
36
/*******************************************************************************
38
******************************************************************************/
39
HChannel::HChannel() :
40
m_type(), m_typeAsString()
44
HChannel::HChannel(Type type) :
45
m_type(type), m_typeAsString(toString(type))
49
HChannel::HChannel(const QString& arg) :
50
m_type(), m_typeAsString()
52
QString trimmed = arg.trimmed();
53
m_type = fromString(trimmed);
54
m_typeAsString = trimmed;
57
QString HChannel::toString(Type type)
110
HChannel::Type HChannel::fromString(const QString& type)
112
Type retVal = Undefined;
113
if (type.compare("MASTER", Qt::CaseInsensitive) == 0)
117
else if (type.compare("LF", Qt::CaseInsensitive) == 0)
121
else if (type.compare("RF", Qt::CaseInsensitive) == 0)
125
else if (type.compare("CF", Qt::CaseInsensitive) == 0)
127
retVal = CenterFront;
129
else if (type.compare("LFE", Qt::CaseInsensitive) == 0)
133
else if (type.compare("LS", Qt::CaseInsensitive) == 0)
135
retVal = LeftSurround;
137
else if (type.compare("RS", Qt::CaseInsensitive) == 0)
139
retVal = RightSurround;
141
else if (type.compare("LFC", Qt::CaseInsensitive) == 0)
143
retVal = LeftOfCenter;
145
else if (type.compare("RFC", Qt::CaseInsensitive) == 0)
147
retVal = RightOfCenter;
149
else if (type.compare("SD", Qt::CaseInsensitive) == 0)
153
else if (type.compare("SL", Qt::CaseInsensitive) == 0)
157
else if (type.compare("SR", Qt::CaseInsensitive) == 0)
161
else if (type.compare("T", Qt::CaseInsensitive) == 0)
165
else if (type.compare("B", Qt::CaseInsensitive) == 0)
169
else if (!type.isEmpty())
171
retVal = VendorDefined;
176
QSet<HChannel> HChannel::allChannels()
178
QSet<HChannel> retVal;
179
retVal.insert(Master);
180
retVal.insert(LeftFront);
181
retVal.insert(RightFront);
182
retVal.insert(CenterFront);
184
retVal.insert(LeftSurround);
185
retVal.insert(RightSurround);
186
retVal.insert(LeftOfCenter);
187
retVal.insert(RightOfCenter);
188
retVal.insert(Surround);
189
retVal.insert(SideLeft);
190
retVal.insert(SideRight);
192
retVal.insert(Bottom);
196
bool operator==(const HChannel& obj1, const HChannel& obj2)
198
return obj1.toString() == obj2.toString();
201
quint32 qHash(const HChannel& key)
203
QByteArray data = key.toString().toLocal8Bit();
204
return hash(data.constData(), data.size());