refs #396 BlackMisc: nw* goes to network/, hw* goes to hardware/

This commit is contained in:
Michał Garapich
2015-04-06 22:47:48 +02:00
committed by Roland Winklmeier
parent 2363fab8c1
commit 985a1caecf
108 changed files with 286 additions and 422 deletions

View File

@@ -0,0 +1,118 @@
/* 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 "blackmisc/network/textmessagelist.h"
#include "blackmisc/predicates.h"
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Aviation;
namespace BlackMisc
{
namespace Network
{
CTextMessageList::CTextMessageList() { }
CTextMessageList::CTextMessageList(const QString &message, const CCallsign &recipientCallsign)
{
CTextMessage pm(message, recipientCallsign);
this->push_back(pm);
}
CTextMessageList::CTextMessageList(const QString &message, const CCallsign &fromCallsign, const CCallsign &toCallsign)
{
CTextMessage pm(message, fromCallsign, toCallsign);
this->push_back(pm);
}
CTextMessageList::CTextMessageList(const QString &message, const CFrequency &frequency, const CCallsign &fromCallsign)
{
CTextMessage pm(message, frequency, fromCallsign);
this->push_back(pm);
}
CTextMessageList::CTextMessageList(const CTextMessage &message)
{
this->push_back(message);
}
CTextMessageList::CTextMessageList(const QString &message, const QList<CFrequency> &frequencies, const BlackMisc::Aviation::CCallsign &fromCallsign)
{
if (frequencies.isEmpty()) return;
foreach(CFrequency frequency, frequencies)
{
CTextMessage pm(message, frequency, fromCallsign);
this->push_back(pm);
}
}
CTextMessageList::CTextMessageList(const CSequence<CTextMessage> &other) :
CSequence<CTextMessage>(other)
{ }
CTextMessageList CTextMessageList::getPrivateMessages() const
{
return this->findBy(&CTextMessage::isPrivateMessage, true);
}
bool CTextMessageList::containsPrivateMessages() const
{
return this->contains(&CTextMessage::isPrivateMessage, true);
}
CTextMessageList CTextMessageList::containsSupervisorMessages() const
{
return this->findBy(&CTextMessage::isSupervisorMessage, true);
}
CTextMessageList CTextMessageList::getRadioMessages() const
{
return this->findBy(&CTextMessage::isRadioMessage, true);
}
CTextMessageList CTextMessageList::getSupervisorMessages() const
{
return this->findBy(&CTextMessage::isSupervisorMessage, true);
}
bool CTextMessageList::containsRadioMessages() const
{
return this->contains(&CTextMessage::isRadioMessage, true);
}
void CTextMessageList::registerMetadata()
{
qRegisterMetaType<BlackMisc::CSequence<CTextMessage>>();
qDBusRegisterMetaType<BlackMisc::CSequence<CTextMessage>>();
qRegisterMetaType<BlackMisc::CCollection<CTextMessage>>();
qDBusRegisterMetaType<BlackMisc::CCollection<CTextMessage>>();
qRegisterMetaType<CTextMessageList>();
qDBusRegisterMetaType<CTextMessageList>();
registerMetaValueType<CTextMessageList>();
}
CTextMessageList CTextMessageList::findByFrequency(const CFrequency &frequency) const
{
return this->findBy(&CTextMessage::getFrequency, frequency);
}
void CTextMessageList::toggleSenderRecipients()
{
if (this->isEmpty()) { return; }
std::for_each(this->begin(), this->end(), [](CTextMessage & tm) { tm.toggleSenderRecipient(); });
}
void CTextMessageList::markAsSent()
{
std::for_each(this->begin(), this->end(), [](CTextMessage & tm) { tm.markAsSent(); });
}
} // namespace
} // namespace