mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-19 20:25:29 +08:00
CTextMessage: fromCallsign and toCallsign become sender and recipient (to and from looked like conversion methods)
refs #81
This commit is contained in:
@@ -64,7 +64,7 @@ QWidget *MainWindow::addNewTextMessageTab(const QString &tabName)
|
|||||||
void MainWindow::addPrivateChannelTextMessage(const CTextMessage &textMessage, bool sending)
|
void MainWindow::addPrivateChannelTextMessage(const CTextMessage &textMessage, bool sending)
|
||||||
{
|
{
|
||||||
if (!textMessage.isPrivateMessage()) return;
|
if (!textMessage.isPrivateMessage()) return;
|
||||||
CCallsign cs = sending ? textMessage.getToCallsign() : textMessage.getFromCallsign();
|
CCallsign cs = sending ? textMessage.getRecipient() : textMessage.getSender();
|
||||||
if (cs.isEmpty()) return;
|
if (cs.isEmpty()) return;
|
||||||
QWidget *tab = this->findTextMessageTabByName(cs.getStringAsSet());
|
QWidget *tab = this->findTextMessageTabByName(cs.getStringAsSet());
|
||||||
if (tab == nullptr) tab = this->findTextMessageTabByName(cs.asString());
|
if (tab == nullptr) tab = this->findTextMessageTabByName(cs.asString());
|
||||||
@@ -104,7 +104,7 @@ CTextMessage MainWindow::getTextMessageStubForChannel()
|
|||||||
if (index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesAll)) return tm;
|
if (index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesAll)) return tm;
|
||||||
|
|
||||||
// from
|
// from
|
||||||
tm.setFromCallsign(this->m_ownAircraft.getCallsign());
|
tm.setSender(this->m_ownAircraft.getCallsign());
|
||||||
|
|
||||||
if (index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesCOM1) ||
|
if (index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesCOM1) ||
|
||||||
index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesCOM2) ||
|
index == this->ui->tw_TextMessages->indexOf(this->ui->tb_TextMessagesCOM2) ||
|
||||||
@@ -138,14 +138,14 @@ CTextMessage MainWindow::getTextMessageStubForChannel()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CCallsign toCallsign(selectedTabText);
|
CCallsign recipient(selectedTabText);
|
||||||
tm.setToCallsign(toCallsign);
|
tm.setRecipient(recipient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CCallsign toCallsign(selectedTabText);
|
CCallsign recipient(selectedTabText);
|
||||||
tm.setToCallsign(toCallsign);
|
tm.setRecipient(recipient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tm; // now valid message stub with receiver
|
return tm; // now valid message stub with receiver
|
||||||
@@ -215,7 +215,7 @@ void MainWindow::commandEntered()
|
|||||||
this->ui->tw_TextMessages->setCurrentWidget(tab);
|
this->ui->tw_TextMessages->setCurrentWidget(tab);
|
||||||
}
|
}
|
||||||
CTextMessage tm = this->getTextMessageStubForChannel();
|
CTextMessage tm = this->getTextMessageStubForChannel();
|
||||||
int index = cmdLine.indexOf(tm.getToCallsign().getStringAsSet(), 0, Qt::CaseInsensitive);
|
int index = cmdLine.indexOf(tm.getRecipient().getStringAsSet(), 0, Qt::CaseInsensitive);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
{
|
{
|
||||||
this->displayStatusMessage(
|
this->displayStatusMessage(
|
||||||
@@ -224,7 +224,7 @@ void MainWindow::commandEntered()
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString msg(cmdLine.mid(index + tm.getToCallsign().asString().length() + 1));
|
QString msg(cmdLine.mid(index + tm.getRecipient().asString().length() + 1));
|
||||||
tm.setMessage(msg);
|
tm.setMessage(msg);
|
||||||
if (tm.isEmpty()) return;
|
if (tm.isEmpty()) return;
|
||||||
if (!this->isContextNetworkAvailableCheck()) return;
|
if (!this->isContextNetworkAvailableCheck()) return;
|
||||||
|
|||||||
@@ -269,8 +269,8 @@ namespace BlackCore
|
|||||||
CTextMessageList privateMessages = messages.getPrivateMessages();
|
CTextMessageList privateMessages = messages.getPrivateMessages();
|
||||||
foreach(BlackMisc::Network::CTextMessage message, privateMessages)
|
foreach(BlackMisc::Network::CTextMessage message, privateMessages)
|
||||||
{
|
{
|
||||||
if (message.getToCallsign().isEmpty()) continue;
|
if (message.getRecipient().isEmpty()) continue;
|
||||||
m_net->SendPrivateTextMessage(toFSD(message.getToCallsign()), toFSD(message.getMessage()));
|
m_net->SendPrivateTextMessage(toFSD(message.getRecipient()), toFSD(message.getMessage()));
|
||||||
}
|
}
|
||||||
CTextMessageList radioMessages = messages.getRadioMessages();
|
CTextMessageList radioMessages = messages.getRadioMessages();
|
||||||
if (radioMessages.isEmpty()) return;
|
if (radioMessages.isEmpty()) return;
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ namespace BlackMisc
|
|||||||
QString s(this->m_message);
|
QString s(this->m_message);
|
||||||
if (this->isPrivateMessage())
|
if (this->isPrivateMessage())
|
||||||
{
|
{
|
||||||
s.append(" ").append(this->m_fromCallsign.toQString(i18n));
|
s.append(" ").append(this->m_sender.toQString(i18n));
|
||||||
s.append(" ").append(this->m_toCallsign.toQString(i18n));
|
s.append(" ").append(this->m_recipient.toQString(i18n));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -30,8 +30,8 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
void CTextMessage::marshallToDbus(QDBusArgument &argument) const
|
void CTextMessage::marshallToDbus(QDBusArgument &argument) const
|
||||||
{
|
{
|
||||||
argument << this->m_fromCallsign;
|
argument << this->m_sender;
|
||||||
argument << this->m_toCallsign;
|
argument << this->m_recipient;
|
||||||
argument << this->m_message;
|
argument << this->m_message;
|
||||||
argument << this->m_frequency;
|
argument << this->m_frequency;
|
||||||
}
|
}
|
||||||
@@ -41,8 +41,8 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
void CTextMessage::unmarshallFromDbus(const QDBusArgument &argument)
|
void CTextMessage::unmarshallFromDbus(const QDBusArgument &argument)
|
||||||
{
|
{
|
||||||
argument >> this->m_fromCallsign;
|
argument >> this->m_sender;
|
||||||
argument >> this->m_toCallsign;
|
argument >> this->m_recipient;
|
||||||
argument >> this->m_message;
|
argument >> this->m_message;
|
||||||
argument >> this->m_frequency;
|
argument >> this->m_frequency;
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
bool CTextMessage::isPrivateMessage() const
|
bool CTextMessage::isPrivateMessage() const
|
||||||
{
|
{
|
||||||
return !this->m_fromCallsign.isEmpty() && !this->m_toCallsign.isEmpty();
|
return !this->m_sender.isEmpty() && !this->m_recipient.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -75,9 +75,9 @@ namespace BlackMisc
|
|||||||
/*
|
/*
|
||||||
* Valid receiver?
|
* Valid receiver?
|
||||||
*/
|
*/
|
||||||
bool CTextMessage::hasValidReceiver() const
|
bool CTextMessage::hasValidRecipient() const
|
||||||
{
|
{
|
||||||
if (!this->m_toCallsign.isEmpty()) return true;
|
if (!this->m_recipient.isEmpty()) return true;
|
||||||
return BlackMisc::Aviation::CComSystem::isValidCivilAviationFrequency(this->m_frequency);
|
return BlackMisc::Aviation::CComSystem::isValidCivilAviationFrequency(this->m_frequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,21 +92,23 @@ namespace BlackMisc
|
|||||||
/*
|
/*
|
||||||
* Formatted string
|
* Formatted string
|
||||||
*/
|
*/
|
||||||
QString CTextMessage::asString(bool withFrom, bool withTo, const QString separator) const
|
QString CTextMessage::asString(bool withSender, bool withRecipient, const QString separator) const
|
||||||
{
|
{
|
||||||
QString s;
|
QString s;
|
||||||
if (withFrom)
|
if (withSender)
|
||||||
{
|
{
|
||||||
if (!this->m_fromCallsign.isEmpty())
|
if (!this->m_sender.isEmpty())
|
||||||
s.append(this->m_fromCallsign.getStringAsSet());
|
{
|
||||||
|
s.append(this->m_sender.getStringAsSet());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (withTo)
|
if (withRecipient)
|
||||||
{
|
{
|
||||||
if (!this->m_toCallsign.isEmpty())
|
if (!this->m_recipient.isEmpty())
|
||||||
{
|
{
|
||||||
if (!s.isEmpty()) s.append(separator);
|
if (!s.isEmpty()) s.append(separator);
|
||||||
s.append(this->m_toCallsign.getStringAsSet());
|
s.append(this->m_recipient.getStringAsSet());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -115,9 +117,8 @@ namespace BlackMisc
|
|||||||
if (!s.isEmpty()) s.append(separator);
|
if (!s.isEmpty()) s.append(separator);
|
||||||
s.append(this->m_frequency.valueRoundedWithUnit(3, true));
|
s.append(this->m_frequency.valueRoundedWithUnit(3, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} // to
|
}
|
||||||
|
|
||||||
if (this->m_message.isEmpty()) return s;
|
if (this->m_message.isEmpty()) return s;
|
||||||
if (!s.isEmpty()) s.append(separator);
|
if (!s.isEmpty()) s.append(separator);
|
||||||
@@ -128,11 +129,9 @@ namespace BlackMisc
|
|||||||
/*
|
/*
|
||||||
* Toggle sender / receiver
|
* Toggle sender / receiver
|
||||||
*/
|
*/
|
||||||
void CTextMessage::toggleSenderReceiver()
|
void CTextMessage::toggleSenderRecipient()
|
||||||
{
|
{
|
||||||
BlackMisc::Aviation::CCallsign csOldFrom(this->getFromCallsign());
|
qSwap(this->m_sender, this->m_recipient);
|
||||||
this->setFromCallsign(this->getToCallsign());
|
|
||||||
this->setToCallsign(csOldFrom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -158,8 +157,8 @@ namespace BlackMisc
|
|||||||
uint CTextMessage::getValueHash() const
|
uint CTextMessage::getValueHash() const
|
||||||
{
|
{
|
||||||
QList<uint> hashs;
|
QList<uint> hashs;
|
||||||
hashs << qHash(this->m_fromCallsign);
|
hashs << qHash(this->m_sender);
|
||||||
hashs << qHash(this->m_toCallsign);
|
hashs << qHash(this->m_recipient);
|
||||||
hashs << qHash(this->m_frequency);
|
hashs << qHash(this->m_frequency);
|
||||||
hashs << qHash(this->m_message);
|
hashs << qHash(this->m_message);
|
||||||
return BlackMisc::calculateHash(hashs, "CTextMessage");
|
return BlackMisc::calculateHash(hashs, "CTextMessage");
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ namespace BlackMisc
|
|||||||
* Constructor, radio message
|
* Constructor, radio message
|
||||||
* \param message
|
* \param message
|
||||||
* \param frequency
|
* \param frequency
|
||||||
* \param fromCallsign
|
* \param sender
|
||||||
*/
|
*/
|
||||||
CTextMessage(const QString &message, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const BlackMisc::Aviation::CCallsign &fromCallsign = BlackMisc::Aviation::CCallsign())
|
CTextMessage(const QString &message, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const BlackMisc::Aviation::CCallsign &sender = BlackMisc::Aviation::CCallsign())
|
||||||
: m_message(message), m_fromCallsign(fromCallsign), m_frequency(frequency)
|
: m_message(message), m_sender(sender), m_frequency(frequency)
|
||||||
{
|
{
|
||||||
this->m_frequency.switchUnit(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
this->m_frequency.switchUnit(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||||
}
|
}
|
||||||
@@ -44,11 +44,11 @@ namespace BlackMisc
|
|||||||
/*!
|
/*!
|
||||||
* Constructor, private message
|
* Constructor, private message
|
||||||
* \param message
|
* \param message
|
||||||
* \param fromCallsign
|
* \param sender
|
||||||
* \param toCallsign
|
* \param recipient
|
||||||
*/
|
*/
|
||||||
CTextMessage(const QString &message, const BlackMisc::Aviation::CCallsign &fromCallsign, const BlackMisc::Aviation::CCallsign &toCallsign = BlackMisc::Aviation::CCallsign())
|
CTextMessage(const QString &message, const BlackMisc::Aviation::CCallsign &sender, const BlackMisc::Aviation::CCallsign &recipient = BlackMisc::Aviation::CCallsign())
|
||||||
: m_message(message), m_fromCallsign(fromCallsign), m_toCallsign(toCallsign), m_frequency(-1.0, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()) {}
|
: m_message(message), m_sender(sender), m_recipient(recipient), m_frequency(-1.0, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()) {}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief QVariant, required for DBus QVariant lists
|
* \brief QVariant, required for DBus QVariant lists
|
||||||
@@ -63,25 +63,25 @@ namespace BlackMisc
|
|||||||
* Get callsign (from)
|
* Get callsign (from)
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
const BlackMisc::Aviation::CCallsign &getFromCallsign() const { return m_fromCallsign; }
|
const BlackMisc::Aviation::CCallsign &getSender() const { return m_sender; }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Set callsign (from)
|
* Set callsign (from)
|
||||||
* \param
|
* \param
|
||||||
*/
|
*/
|
||||||
void setFromCallsign(const BlackMisc::Aviation::CCallsign &callsign) { m_fromCallsign = callsign; }
|
void setSender(const BlackMisc::Aviation::CCallsign &sender) { m_sender = sender; }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Get callsign (to)
|
* Get callsign (to)
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
const BlackMisc::Aviation::CCallsign &getToCallsign() const { return m_toCallsign; }
|
const BlackMisc::Aviation::CCallsign &getRecipient() const { return m_recipient; }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Set callsign (to)
|
* Set callsign (to)
|
||||||
* \param
|
* \param
|
||||||
*/
|
*/
|
||||||
void setToCallsign(const BlackMisc::Aviation::CCallsign &callsign) { m_toCallsign = callsign; }
|
void setRecipient(const BlackMisc::Aviation::CCallsign &recipient) { m_recipient = recipient; }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send to frequency?
|
* Send to frequency?
|
||||||
@@ -97,10 +97,10 @@ namespace BlackMisc
|
|||||||
bool isSendToUnicom() const;
|
bool isSendToUnicom() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Valid receviver?
|
* \brief Valid recipient?
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
bool hasValidReceiver() const;
|
bool hasValidRecipient() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Get message
|
* Get message
|
||||||
@@ -147,17 +147,17 @@ namespace BlackMisc
|
|||||||
/*!
|
/*!
|
||||||
* Whole message as formatted string.
|
* Whole message as formatted string.
|
||||||
* Used to display message in a console window.
|
* Used to display message in a console window.
|
||||||
* \param withFrom
|
* \param withSender
|
||||||
* \param withTo
|
* \param withRecipient
|
||||||
* \param separator
|
* \param separator
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
QString asString(bool withFrom, bool withTo, const QString separator = ", ") const;
|
QString asString(bool withSender, bool withRecipient, QString separator = ", ") const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Toggle sender receiver, can be used to ping my own message
|
* Toggle sender receiver, can be used to ping my own message
|
||||||
*/
|
*/
|
||||||
void toggleSenderReceiver();
|
void toggleSenderRecipient();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Equal operator ==
|
* \brief Equal operator ==
|
||||||
@@ -205,8 +205,8 @@ namespace BlackMisc
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_message;
|
QString m_message;
|
||||||
BlackMisc::Aviation::CCallsign m_fromCallsign;
|
BlackMisc::Aviation::CCallsign m_sender;
|
||||||
BlackMisc::Aviation::CCallsign m_toCallsign;
|
BlackMisc::Aviation::CCallsign m_recipient;
|
||||||
BlackMisc::PhysicalQuantities::CFrequency m_frequency;
|
BlackMisc::PhysicalQuantities::CFrequency m_frequency;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -121,9 +121,9 @@ namespace BlackMisc
|
|||||||
/*
|
/*
|
||||||
* Find by callsign
|
* Find by callsign
|
||||||
*/
|
*/
|
||||||
CTextMessageList CTextMessageList::findByToCallsign(const CCallsign &callsign) const
|
CTextMessageList CTextMessageList::findByRecipient(const CCallsign &callsign) const
|
||||||
{
|
{
|
||||||
return CTextMessageList(this->findBy(&CTextMessage::getToCallsign, callsign));
|
return CTextMessageList(this->findBy(&CTextMessage::getRecipient, callsign));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -143,7 +143,7 @@ namespace BlackMisc
|
|||||||
for (int i = 0; i < this->size(); i++)
|
for (int i = 0; i < this->size(); i++)
|
||||||
{
|
{
|
||||||
CTextMessage tm = (*this)[i];
|
CTextMessage tm = (*this)[i];
|
||||||
tm.toggleSenderReceiver();
|
tm.toggleSenderRecipient();
|
||||||
(*this)[i] = tm;
|
(*this)[i] = tm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,24 +35,25 @@ namespace BlackMisc
|
|||||||
/*!
|
/*!
|
||||||
* \brief Constructor, single private message
|
* \brief Constructor, single private message
|
||||||
* \param message
|
* \param message
|
||||||
* \param frequency
|
* \param recipient
|
||||||
*/
|
*/
|
||||||
CTextMessageList(const QString &message, const BlackMisc::Aviation::CCallsign &toCallsign);
|
CTextMessageList(const QString &message, const BlackMisc::Aviation::CCallsign &recipient);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructor, single private message
|
* \brief Constructor, single private message
|
||||||
* \param message
|
* \param message
|
||||||
* \param fromCallsign
|
* \param sender
|
||||||
* \param toCallsign
|
* \param recipient
|
||||||
*/
|
*/
|
||||||
CTextMessageList(const QString &message, const BlackMisc::Aviation::CCallsign &fromCallsign, const BlackMisc::Aviation::CCallsign &toCallsign);
|
CTextMessageList(const QString &message, const BlackMisc::Aviation::CCallsign &sender, const BlackMisc::Aviation::CCallsign &recipient);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructor, single radio message
|
* \brief Constructor, single radio message
|
||||||
* \param message
|
* \param message
|
||||||
* \param frequency
|
* \param frequency
|
||||||
|
* \param sender
|
||||||
*/
|
*/
|
||||||
CTextMessageList(const QString &message, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const BlackMisc::Aviation::CCallsign &fromCallsign = BlackMisc::Aviation::CCallsign());
|
CTextMessageList(const QString &message, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const BlackMisc::Aviation::CCallsign &sender = BlackMisc::Aviation::CCallsign());
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructor, single message
|
* \brief Constructor, single message
|
||||||
@@ -64,8 +65,9 @@ namespace BlackMisc
|
|||||||
* \brief Constructor, multi-frequency radio messages
|
* \brief Constructor, multi-frequency radio messages
|
||||||
* \param message
|
* \param message
|
||||||
* \param frequencies
|
* \param frequencies
|
||||||
|
* \param sender
|
||||||
*/
|
*/
|
||||||
CTextMessageList(const QString &message, const QList<BlackMisc::PhysicalQuantities::CFrequency> &frequencies, const BlackMisc::Aviation::CCallsign &fromCallsign = BlackMisc::Aviation::CCallsign());
|
CTextMessageList(const QString &message, const QList<BlackMisc::PhysicalQuantities::CFrequency> &frequencies, const BlackMisc::Aviation::CCallsign &sender = BlackMisc::Aviation::CCallsign());
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Construct from a base class object.
|
* \brief Construct from a base class object.
|
||||||
@@ -111,7 +113,7 @@ namespace BlackMisc
|
|||||||
* \param callsign
|
* \param callsign
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
CTextMessageList findByToCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
CTextMessageList findByRecipient(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Find by frequency
|
* \brief Find by frequency
|
||||||
|
|||||||
Reference in New Issue
Block a user