mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
Ref T565, "canTalk" utility functions
This commit is contained in:
committed by
Mat Sutcliffe
parent
a049ee7025
commit
5ac1f65756
@@ -91,5 +91,10 @@ namespace BlackMisc
|
||||
{
|
||||
return (m_channel.contains("ATIS", Qt::CaseInsensitive));
|
||||
}
|
||||
|
||||
bool CVoiceRoom::canTalkTo() const
|
||||
{
|
||||
return this->isConnected() && !this->isAtis();
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace BlackMisc
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexHostname = BlackMisc::CPropertyIndex::GlobalIndexCVoiceRoom,
|
||||
IndexHostname = CPropertyIndex::GlobalIndexCVoiceRoom,
|
||||
IndexChannel,
|
||||
IndexUrl,
|
||||
IndexConnected,
|
||||
@@ -68,23 +68,26 @@ namespace BlackMisc
|
||||
void setVoiceRoomUrl(const QString &serverUrl);
|
||||
|
||||
//! Valid voice room object?
|
||||
bool isValid() const { return !this->m_hostname.isEmpty() && !this->m_channel.isEmpty(); }
|
||||
bool isValid() const { return !m_hostname.isEmpty() && !m_channel.isEmpty(); }
|
||||
|
||||
//! Is connected?
|
||||
bool isConnected() const { return this->isValid() && this->m_connected; }
|
||||
bool isConnected() const { return this->isValid() && m_connected; }
|
||||
|
||||
//! Set connection status
|
||||
void setConnected(bool isConnected) { this->m_connected = isConnected; }
|
||||
void setConnected(bool isConnected) { m_connected = isConnected; }
|
||||
|
||||
//! Is audio playing in this room?
|
||||
bool isAudioPlaying() const { return this->m_audioPlaying; }
|
||||
bool isAudioPlaying() const { return m_audioPlaying; }
|
||||
|
||||
//! Set audio playing
|
||||
void setAudioPlaying(bool playing) { this->m_audioPlaying = playing; }
|
||||
void setAudioPlaying(bool playing) { m_audioPlaying = playing; }
|
||||
|
||||
//! Is ATIS voice channel
|
||||
bool isAtis() const;
|
||||
|
||||
//! Can talk to channel
|
||||
bool canTalkTo() const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
@@ -115,8 +118,8 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(audioPlaying)
|
||||
);
|
||||
};
|
||||
} // Voice
|
||||
} // BlackMisc
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Audio::CVoiceRoom)
|
||||
|
||||
|
||||
@@ -23,6 +23,16 @@ namespace BlackMisc
|
||||
CSequence(other)
|
||||
{ }
|
||||
|
||||
int CVoiceRoomList::countCanTalkTo() const
|
||||
{
|
||||
int c = 0;
|
||||
for (const CVoiceRoom &r : *this)
|
||||
{
|
||||
if (r.canTalkTo()) { c++; }
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
const CVoiceRoomList &CVoiceRoomList::twoEmptyRooms()
|
||||
{
|
||||
static CVoiceRoomList emptyRooms;
|
||||
|
||||
@@ -39,6 +39,9 @@ namespace BlackMisc
|
||||
//! Construct from a base class object.
|
||||
CVoiceRoomList(const CSequence &other);
|
||||
|
||||
//! Count how many rooms can be talked to
|
||||
int countCanTalkTo() const;
|
||||
|
||||
//! Frequently needed for voice room resolutions
|
||||
static const CVoiceRoomList &twoEmptyRooms();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user