mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Ref T190, text messages can be appended
(same sender sends one message in multiple parts)
This commit is contained in:
@@ -65,6 +65,31 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CTextMessage::canBeAppended(const CTextMessage &textMessage) const
|
||||||
|
{
|
||||||
|
if (textMessage.isEmpty()) { return false; }
|
||||||
|
if (this->getSenderCallsign() != textMessage.getSenderCallsign()) { return false; }
|
||||||
|
if (this->isRadioMessage() && textMessage.isRadioMessage())
|
||||||
|
{
|
||||||
|
if (this->getFrequency() != textMessage.getFrequency()) { return false; }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (this->isPrivateMessage() && textMessage.isPrivateMessage())
|
||||||
|
{
|
||||||
|
if (this->getRecipientCallsign() != textMessage.getRecipientCallsign()) { return false; }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CTextMessage::appendIfPossible(const CTextMessage &textMessage)
|
||||||
|
{
|
||||||
|
if (textMessage.isEmpty()) { return false; }
|
||||||
|
if (!this->canBeAppended(textMessage)) { return false; }
|
||||||
|
m_message += " " + textMessage.getMessage();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QString CTextMessage::getRecipientCallsignOrFrequency() const
|
QString CTextMessage::getRecipientCallsignOrFrequency() const
|
||||||
{
|
{
|
||||||
if (!m_recipientCallsign.isEmpty()) { return m_recipientCallsign.asString(); }
|
if (!m_recipientCallsign.isEmpty()) { return m_recipientCallsign.asString(); }
|
||||||
|
|||||||
@@ -153,6 +153,12 @@ namespace BlackMisc
|
|||||||
//! \remark also sets current timestamp if there is no valid timestamp
|
//! \remark also sets current timestamp if there is no valid timestamp
|
||||||
void markAsSent();
|
void markAsSent();
|
||||||
|
|
||||||
|
//! Can another message be appended
|
||||||
|
bool canBeAppended(const CTextMessage &textMessage) const;
|
||||||
|
|
||||||
|
//! Append if possible
|
||||||
|
bool appendIfPossible(const CTextMessage &textMessage);
|
||||||
|
|
||||||
//! Get SELCAL code (if applicable, e.g. ABCD), otherwise ""
|
//! Get SELCAL code (if applicable, e.g. ABCD), otherwise ""
|
||||||
QString getSelcalCode() const;
|
QString getSelcalCode() const;
|
||||||
|
|
||||||
|
|||||||
@@ -109,5 +109,14 @@ namespace BlackMisc
|
|||||||
std::for_each(this->begin(), this->end(), [](CTextMessage & tm) { tm.markAsSent(); });
|
std::for_each(this->begin(), this->end(), [](CTextMessage & tm) { tm.markAsSent(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CTextMessageList::addConsolidatedTextMessage(const CTextMessage &message)
|
||||||
|
{
|
||||||
|
if (message.isEmpty()) { return; }
|
||||||
|
for (CTextMessage &tm : *this)
|
||||||
|
{
|
||||||
|
if (tm.appendIfPossible(message)) { return; }
|
||||||
|
}
|
||||||
|
this->push_back(message);
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ namespace BlackMisc
|
|||||||
//! Mark all messages as sent
|
//! Mark all messages as sent
|
||||||
void markAsSent();
|
void markAsSent();
|
||||||
|
|
||||||
|
//! Add a text message, but append it to an existing message if possible
|
||||||
|
void addConsolidatedTextMessage(const CTextMessage &message);
|
||||||
};
|
};
|
||||||
} //namespace
|
} //namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user