mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
Ref T494, style
* removed some old "foreach" loops * fixed some CLANG warnings
This commit is contained in:
committed by
Mat Sutcliffe
parent
cb084427ec
commit
80ed972e53
@@ -12,13 +12,13 @@
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QStringBuilder>
|
||||
#include <Qt>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
|
||||
CVoiceRoom::CVoiceRoom(const QString &voiceRoomUrl, bool connected) :
|
||||
m_connected(connected), m_audioPlaying(false)
|
||||
{
|
||||
@@ -28,83 +28,61 @@ namespace BlackMisc
|
||||
CVariant CVoiceRoom::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAudioPlaying:
|
||||
return CVariant::from(this->isAudioPlaying());
|
||||
case IndexConnected:
|
||||
return CVariant::from(this->isConnected());
|
||||
case IndexChannel:
|
||||
return CVariant::from(this->getChannel());
|
||||
case IndexHostname:
|
||||
return CVariant::from(this->getHostname());
|
||||
case IndexUrl:
|
||||
return CVariant::from(this->getVoiceRoomUrl());
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
case IndexAudioPlaying: return CVariant::from(this->isAudioPlaying());
|
||||
case IndexConnected: return CVariant::from(this->isConnected());
|
||||
case IndexChannel: return CVariant::from(this->getChannel());
|
||||
case IndexHostname: return CVariant::from(this->getHostname());
|
||||
case IndexUrl: return CVariant::from(this->getVoiceRoomUrl());
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CVoiceRoom::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CVoiceRoom>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAudioPlaying:
|
||||
this->setAudioPlaying(variant.toBool());
|
||||
break;
|
||||
case IndexConnected:
|
||||
this->setConnected(variant.toBool());
|
||||
break;
|
||||
case IndexChannel:
|
||||
this->setChannel(variant.value<QString>());
|
||||
break;
|
||||
case IndexHostname:
|
||||
this->setHostName(variant.value<QString>());
|
||||
break;
|
||||
case IndexUrl:
|
||||
this->setVoiceRoomUrl(variant.value<QString>());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
case IndexAudioPlaying: this->setAudioPlaying(variant.toBool()); break;
|
||||
case IndexConnected: this->setConnected(variant.toBool()); break;
|
||||
case IndexChannel: this->setChannel(variant.value<QString>()); break;
|
||||
case IndexHostname: this->setHostName(variant.value<QString>()); break;
|
||||
case IndexUrl: this->setVoiceRoomUrl(variant.value<QString>()); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
|
||||
QString CVoiceRoom::convertToQString(bool /* i18n */) const
|
||||
QString CVoiceRoom::convertToQString(bool i18n) const
|
||||
{
|
||||
if (!this->isValid()) return "Invalid";
|
||||
QString s = this->getVoiceRoomUrl(false);
|
||||
s.append(this->isConnected() ? " connected" : " unconnected");
|
||||
if (this->m_audioPlaying) s.append(" playing");
|
||||
return s;
|
||||
Q_UNUSED(i18n);
|
||||
if (!this->isValid()) { return QStringLiteral("Invalid"); }
|
||||
return this->getVoiceRoomUrl(false) %
|
||||
(this->isConnected() ? u" connected" : u" unconnected") %
|
||||
(m_audioPlaying ? u" playing" : u"");
|
||||
}
|
||||
|
||||
QString CVoiceRoom::getVoiceRoomUrl(bool noProtocol) const
|
||||
{
|
||||
if (!this->isValid()) return {};
|
||||
QString url(noProtocol ? "" : CVoiceRoom::protocolComplete());
|
||||
url.append(this->m_hostname);
|
||||
url.append("/");
|
||||
url.append(this->m_channel);
|
||||
return url;
|
||||
if (!this->isValid()) { return {}; }
|
||||
return (noProtocol ? QStringLiteral("") : CVoiceRoom::protocolComplete()) % m_hostname % u"/" % m_channel;
|
||||
}
|
||||
|
||||
void CVoiceRoom::setVoiceRoomUrl(const QString &serverUrl)
|
||||
{
|
||||
if (serverUrl.isEmpty())
|
||||
{
|
||||
m_hostname = "";
|
||||
m_channel = "";
|
||||
m_hostname.clear();
|
||||
m_channel.clear();
|
||||
}
|
||||
else if (serverUrl.contains("/"))
|
||||
{
|
||||
QString url = serverUrl.trimmed().toLower();
|
||||
url.replace(CVoiceRoom::protocolComplete(), "");
|
||||
url.replace(CVoiceRoom::protocol(), "");
|
||||
QStringList splitParts = url.split("/");
|
||||
const QStringList splitParts = url.split("/");
|
||||
m_hostname = splitParts.at(0);
|
||||
m_channel = splitParts.at(1);
|
||||
}
|
||||
@@ -112,7 +90,7 @@ namespace BlackMisc
|
||||
|
||||
bool CVoiceRoom::isAtis() const
|
||||
{
|
||||
return (this->m_channel.contains("ATIS", Qt::CaseInsensitive));
|
||||
return (m_channel.contains("ATIS", Qt::CaseInsensitive));
|
||||
}
|
||||
} // Voice
|
||||
} // BlackMisc
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user