mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 15:45:42 +08:00
refs #396 subfolders and renamed callsign list to callsign set
* subfolder audio * subfolder geo * adjusted samples, tests ....
This commit is contained in:
committed by
Roland Winklmeier
parent
32f60722c8
commit
0ab755d510
25
src/blackmisc/audio/audio.h
Normal file
25
src/blackmisc/audio/audio.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_AUDIO_AUDIO_H
|
||||
#define BLACKMISC_AUDIO_AUDIO_H
|
||||
|
||||
/*!
|
||||
* \namespace BlackMisc::Audio
|
||||
* \brief Audio classes such as audio devices and voice rooms.
|
||||
*/
|
||||
|
||||
#include "blackmisc/audio/audiodeviceinfo.h"
|
||||
#include "blackmisc/audio/audiodeviceinfolist.h"
|
||||
#include "blackmisc/audio/voiceroom.h"
|
||||
#include "blackmisc/audio/voiceroomlist.h"
|
||||
|
||||
#endif // guard
|
||||
41
src/blackmisc/audio/audiodeviceinfo.cpp
Normal file
41
src/blackmisc/audio/audiodeviceinfo.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "audiodeviceinfo.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include <tuple>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
|
||||
CAudioDeviceInfo::CAudioDeviceInfo() :
|
||||
m_type(Unknown), m_deviceIndex(invalidDeviceIndex()),
|
||||
m_deviceName(""), m_hostName(BlackMisc::localHostName())
|
||||
{ }
|
||||
|
||||
CAudioDeviceInfo::CAudioDeviceInfo(DeviceType type, const int index, const QString &name) :
|
||||
m_type(type), m_deviceIndex(index),
|
||||
m_deviceName(name), m_hostName(BlackMisc::localHostName())
|
||||
{ }
|
||||
|
||||
QString CAudioDeviceInfo::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
if (this->m_hostName.isEmpty()) return m_deviceName;
|
||||
QString s(this->m_deviceName);
|
||||
s.append(" [");
|
||||
s.append(this->getHostName());
|
||||
s.append("]");
|
||||
return s;
|
||||
}
|
||||
|
||||
} // Voice
|
||||
} // BlackMisc
|
||||
106
src/blackmisc/audio/audiodeviceinfo.h
Normal file
106
src/blackmisc/audio/audiodeviceinfo.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_AUDIO_AUDIODEVICE_H
|
||||
#define BLACKMISC_AUDIO_AUDIODEVICE_H
|
||||
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
/*!
|
||||
* Value object encapsulating information of a audio device.
|
||||
* If you want to safe this object, use the name instead of the index, since the index can change after
|
||||
* a restart.
|
||||
*/
|
||||
class CAudioDeviceInfo : public CValueObject<CAudioDeviceInfo>
|
||||
{
|
||||
public:
|
||||
//! Type
|
||||
enum DeviceType
|
||||
{
|
||||
InputDevice,
|
||||
OutputDevice,
|
||||
Unknown
|
||||
};
|
||||
|
||||
/*!
|
||||
* Default constructor.
|
||||
* If m_deviceIndex is -1, default should be used. However on Windows this doesnt work. Needs
|
||||
* to be checked in Vatlib.
|
||||
*/
|
||||
CAudioDeviceInfo();
|
||||
|
||||
//! Constructor.
|
||||
CAudioDeviceInfo(DeviceType type, const int index, const QString &getName);
|
||||
|
||||
//! Get the device index
|
||||
int getIndex() const { return m_deviceIndex; }
|
||||
|
||||
//! Get the device name
|
||||
const QString &getName() const { return m_deviceName; }
|
||||
|
||||
//! Host name
|
||||
const QString &getHostName() const { return m_hostName; }
|
||||
|
||||
//! Type
|
||||
DeviceType getType() const { return m_type; }
|
||||
|
||||
//! Valid audio device object?
|
||||
bool isValid() const { return m_deviceIndex >= -1 && !m_deviceName.isEmpty(); }
|
||||
|
||||
//! Device index for default device
|
||||
static int defaultDeviceIndex() {return -1;}
|
||||
|
||||
//! Invalid device index
|
||||
static int invalidDeviceIndex() {return -2;}
|
||||
|
||||
//! Default output device
|
||||
static CAudioDeviceInfo getDefaultOutputDevice()
|
||||
{
|
||||
return CAudioDeviceInfo(OutputDevice, defaultDeviceIndex(), "default");
|
||||
}
|
||||
|
||||
//! Default input device
|
||||
static CAudioDeviceInfo getDefaultInputDevice()
|
||||
{
|
||||
return CAudioDeviceInfo(InputDevice, defaultDeviceIndex(), "default");
|
||||
}
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
virtual QString convertToQString(bool i18n = false) const override;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CAudioDeviceInfo)
|
||||
//! Device type, @see CAudioDeviceInfo::DeviceType
|
||||
DeviceType m_type;
|
||||
/*!
|
||||
* deviceIndex is the number is the reference for the VVL. The device is selected by this index.
|
||||
* The managing class needs to take care, that indexes are valid.
|
||||
*/
|
||||
int m_deviceIndex;
|
||||
//! Device name
|
||||
QString m_deviceName;
|
||||
//! We use a DBus based system. Hence an audio device can reside on a differen computers, this here is its name
|
||||
QString m_hostName;
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Audio::CAudioDeviceInfo, (o.m_type, o.m_deviceIndex, o.m_deviceName, o.m_hostName))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Audio::CAudioDeviceInfo)
|
||||
|
||||
#endif // guard
|
||||
50
src/blackmisc/audio/audiodeviceinfolist.cpp
Normal file
50
src/blackmisc/audio/audiodeviceinfolist.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "audiodeviceinfolist.h"
|
||||
#include "blackmisc/predicates.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
|
||||
CAudioDeviceInfoList::CAudioDeviceInfoList() { }
|
||||
|
||||
CAudioDeviceInfoList::CAudioDeviceInfoList(const CSequence &other) :
|
||||
CSequence(other)
|
||||
{ }
|
||||
|
||||
CAudioDeviceInfoList CAudioDeviceInfoList::getOutputDevices() const
|
||||
{
|
||||
return this->findBy(&CAudioDeviceInfo::getType, CAudioDeviceInfo::OutputDevice);
|
||||
}
|
||||
|
||||
CAudioDeviceInfoList CAudioDeviceInfoList::getInputDevices() const
|
||||
{
|
||||
return this->findBy(&CAudioDeviceInfo::getType, CAudioDeviceInfo::InputDevice);
|
||||
}
|
||||
|
||||
int CAudioDeviceInfoList::count(CAudioDeviceInfo::DeviceType type) const
|
||||
{
|
||||
return std::count_if(this->begin(), this->end(), [type](const CAudioDeviceInfo &device)
|
||||
{
|
||||
return device.getType() == type;
|
||||
});
|
||||
}
|
||||
|
||||
void CAudioDeviceInfoList::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<CAudioDeviceInfoList>();
|
||||
qDBusRegisterMetaType<CAudioDeviceInfoList>();
|
||||
registerMetaValueType<CAudioDeviceInfoList>();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
62
src/blackmisc/audio/audiodeviceinfolist.h
Normal file
62
src/blackmisc/audio/audiodeviceinfolist.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_AUDIO_AUDIODEVICELIST_H
|
||||
#define BLACKMISC_AUDIO_AUDIODEVICELIST_H
|
||||
|
||||
#include "blackmisc/audio/audiodeviceinfo.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
//! Value object encapsulating a list of audio devices.
|
||||
class CAudioDeviceInfoList : public CSequence<CAudioDeviceInfo>
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
CAudioDeviceInfoList();
|
||||
|
||||
//! Construct from a base class object.
|
||||
CAudioDeviceInfoList(const CSequence &other);
|
||||
|
||||
//! Get output devices in that list
|
||||
CAudioDeviceInfoList getOutputDevices() const;
|
||||
|
||||
//! Get output devices in that list
|
||||
CAudioDeviceInfoList getInputDevices() const;
|
||||
|
||||
//! Count (as of type)
|
||||
int count(CAudioDeviceInfo::DeviceType type) const;
|
||||
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||
|
||||
//! \copydoc CValueObject::convertFromQVariant
|
||||
virtual void convertFromQVariant(const QVariant &variant) override { BlackMisc::setFromQVariant(this, variant); }
|
||||
|
||||
//! Register metadata
|
||||
static void registerMetadata();
|
||||
};
|
||||
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Audio::CAudioDeviceInfoList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Audio::CAudioDeviceInfo>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Audio::CAudioDeviceInfo>)
|
||||
|
||||
#endif //guard
|
||||
124
src/blackmisc/audio/voiceroom.cpp
Normal file
124
src/blackmisc/audio/voiceroom.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "voiceroom.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include <QChar>
|
||||
#include <QStringList>
|
||||
#include <tuple>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
|
||||
CVoiceRoom::CVoiceRoom(const QString &voiceRoomUrl, bool connected) :
|
||||
m_connected(connected), m_audioPlaying(false)
|
||||
{
|
||||
this->setVoiceRoomUrl(voiceRoomUrl);
|
||||
}
|
||||
|
||||
CVariant CVoiceRoom::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->toCVariant(); }
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void CVoiceRoom::setPropertyByIndex(const CVariant &variant, const CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
|
||||
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(variant, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void CVoiceRoom::setVoiceRoomUrl(const QString &serverUrl)
|
||||
{
|
||||
if (serverUrl.isEmpty())
|
||||
{
|
||||
m_hostname = "";
|
||||
m_channel = "";
|
||||
}
|
||||
else if (serverUrl.contains("/"))
|
||||
{
|
||||
QString url = serverUrl.trimmed().toLower();
|
||||
url.replace(CVoiceRoom::protocolComplete(), "");
|
||||
url.replace(CVoiceRoom::protocol(), "");
|
||||
QStringList splitParts = url.split("/");
|
||||
m_hostname = splitParts.at(0);
|
||||
m_channel = splitParts.at(1);
|
||||
}
|
||||
}
|
||||
|
||||
bool CVoiceRoom::isAtis() const
|
||||
{
|
||||
return (this->m_channel.contains("ATIS", Qt::CaseInsensitive));
|
||||
}
|
||||
} // Voice
|
||||
} // BlackMisc
|
||||
119
src/blackmisc/audio/voiceroom.h
Normal file
119
src/blackmisc/audio/voiceroom.h
Normal file
@@ -0,0 +1,119 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include <QString>
|
||||
|
||||
#ifndef BLACKMISC_AUDIO_VOICEROOM_H
|
||||
#define BLACKMISC_AUDIO_VOICEROOM_H
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
//! Value object encapsulating information of a voice room
|
||||
class CVoiceRoom : public CValueObject<CVoiceRoom>
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexHostname = BlackMisc::CPropertyIndex::GlobalIndexCVoiceRoom,
|
||||
IndexChannel,
|
||||
IndexUrl,
|
||||
IndexConnected,
|
||||
IndexAudioPlaying
|
||||
};
|
||||
|
||||
//! Default constructor.
|
||||
CVoiceRoom() : m_connected(false), m_audioPlaying(false) {}
|
||||
|
||||
//! Constructor.
|
||||
CVoiceRoom(const QString &hostname, const QString &channel) :
|
||||
m_hostname(hostname), m_channel(channel), m_connected(false), m_audioPlaying(false) {}
|
||||
|
||||
//! Constructor.
|
||||
CVoiceRoom(const QString &voiceRoomUrl, bool connected = false);
|
||||
|
||||
//! Get the host name
|
||||
const QString &getHostname() const { return m_hostname; }
|
||||
|
||||
//! Get the voice room channel
|
||||
const QString &getChannel() const { return m_channel; }
|
||||
|
||||
//! Set the host name
|
||||
void setHostName(const QString &hostName) { m_hostname = hostName; }
|
||||
|
||||
//! Set the voice channel
|
||||
void setChannel(const QString &channel) { m_channel = channel; }
|
||||
|
||||
/*!
|
||||
* Server URL
|
||||
* \param noProtocol either with (pseudo) protocol prefix or without
|
||||
* \return
|
||||
*/
|
||||
QString getVoiceRoomUrl(bool noProtocol = true) const;
|
||||
|
||||
//! Set voice room URL
|
||||
void setVoiceRoomUrl(const QString &serverUrl);
|
||||
|
||||
//! Valid voice room object?
|
||||
bool isValid() const { return !this->m_hostname.isEmpty() && !this->m_channel.isEmpty(); }
|
||||
|
||||
//! Is connected?
|
||||
bool isConnected() const { return this->isValid() && this->m_connected; }
|
||||
|
||||
//! Set connection status
|
||||
void setConnected(bool isConnected) { this->m_connected = isConnected; }
|
||||
|
||||
//! Is audio playing in this room?
|
||||
bool isAudioPlaying() const { return this->m_audioPlaying; }
|
||||
|
||||
//! Set audio playing
|
||||
void setAudioPlaying(bool playing) { this->m_audioPlaying = playing; }
|
||||
|
||||
//! Is ATIS voice channel
|
||||
bool isAtis() const;
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
virtual void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
//! Protocol prefix "vvl"
|
||||
static const QString &protocol() { static QString p("vvl"); return p; }
|
||||
|
||||
/*!
|
||||
* Protocol
|
||||
* \return with protocol prefix or without
|
||||
*/
|
||||
static const QString &protocolComplete() { static QString p("vvl://"); return p; }
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
virtual QString convertToQString(bool i18n = false) const override;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CVoiceRoom)
|
||||
QString m_hostname;
|
||||
QString m_channel;
|
||||
bool m_connected;
|
||||
bool m_audioPlaying;
|
||||
};
|
||||
} // Voice
|
||||
} // BlackMisc
|
||||
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Audio::CVoiceRoom, (o.m_hostname, o.m_channel, o.m_connected, o.m_audioPlaying))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Audio::CVoiceRoom)
|
||||
|
||||
#endif // guard
|
||||
43
src/blackmisc/audio/voiceroomlist.cpp
Normal file
43
src/blackmisc/audio/voiceroomlist.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "voiceroomlist.h"
|
||||
#include "blackmisc/predicates.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
|
||||
CVoiceRoomList::CVoiceRoomList() { }
|
||||
|
||||
CVoiceRoomList::CVoiceRoomList(const CSequence &other) :
|
||||
CSequence(other)
|
||||
{ }
|
||||
|
||||
void CVoiceRoomList::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<CVoiceRoomList>();
|
||||
qDBusRegisterMetaType<CVoiceRoomList>();
|
||||
registerMetaValueType<CVoiceRoomList>();
|
||||
}
|
||||
|
||||
const CVoiceRoomList &CVoiceRoomList::twoEmptyRooms()
|
||||
{
|
||||
static CVoiceRoomList emptyRooms;
|
||||
if (emptyRooms.isEmpty())
|
||||
{
|
||||
emptyRooms.push_back(CVoiceRoom());
|
||||
emptyRooms.push_back(CVoiceRoom());
|
||||
}
|
||||
return emptyRooms;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
58
src/blackmisc/audio/voiceroomlist.h
Normal file
58
src/blackmisc/audio/voiceroomlist.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_AUDIO_VOICEROOMLIST_H
|
||||
#define BLACKMISC_AUDIO_VOICEROOMLIST_H
|
||||
|
||||
#include "voiceroom.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
/*!
|
||||
* Value object encapsulating a list of voice rooms.
|
||||
*/
|
||||
class CVoiceRoomList : public CSequence<CVoiceRoom>
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
CVoiceRoomList();
|
||||
|
||||
//! Construct from a base class object.
|
||||
CVoiceRoomList(const CSequence &other);
|
||||
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||
|
||||
//! \copydoc CValueObject::convertFromQVariant
|
||||
virtual void convertFromQVariant(const QVariant &variant) override { BlackMisc::setFromQVariant(this, variant); }
|
||||
|
||||
//! \brief Register metadata
|
||||
static void registerMetadata();
|
||||
|
||||
//! Frequently needed for voice room resolutions
|
||||
static const CVoiceRoomList &twoEmptyRooms();
|
||||
};
|
||||
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Audio::CVoiceRoomList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Audio::CVoiceRoom>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Audio::CVoiceRoom>)
|
||||
|
||||
#endif //guard
|
||||
Reference in New Issue
Block a user