mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T172, formatting
* this->m_ => m_ * formatting * comments / doxygen
This commit is contained in:
@@ -29,7 +29,7 @@ namespace BlackGui
|
||||
QComboBox(parent)
|
||||
{ }
|
||||
|
||||
void CServerListSelector::setServers(const BlackMisc::Network::CServerList &servers, bool nameIsCountry)
|
||||
void CServerListSelector::setServers(const CServerList &servers, bool nameIsCountry)
|
||||
{
|
||||
if (m_servers == servers) { return; }
|
||||
this->setServerItems(servers, nameIsCountry);
|
||||
|
||||
@@ -32,75 +32,75 @@ namespace BlackGui
|
||||
CManagedStatusBar::~CManagedStatusBar()
|
||||
{
|
||||
// we are not necessarily the owner of the status bar
|
||||
this->m_statusBar->removeWidget(this->m_statusBarLabel);
|
||||
this->m_statusBar->removeWidget(this->m_statusBarIcon);
|
||||
m_statusBar->removeWidget(m_statusBarLabel);
|
||||
m_statusBar->removeWidget(m_statusBarIcon);
|
||||
|
||||
// labels will be deleted with status bar
|
||||
if (this->m_ownStatusBar) { delete m_statusBar; }
|
||||
if (m_ownStatusBar) { delete m_statusBar; }
|
||||
}
|
||||
|
||||
void CManagedStatusBar::initStatusBar(QStatusBar *statusBar)
|
||||
{
|
||||
if (this->m_statusBar) { return; }
|
||||
this->m_ownStatusBar = statusBar ? false : true;
|
||||
this->m_statusBar = statusBar ? statusBar : new QStatusBar();
|
||||
if (this->m_statusBar->objectName().isEmpty()) { this->m_statusBar->setObjectName("sb_ManagedStatusBar"); }
|
||||
if (this->m_ownStatusBar) { m_statusBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);}
|
||||
if (m_statusBar) { return; }
|
||||
m_ownStatusBar = statusBar ? false : true;
|
||||
m_statusBar = statusBar ? statusBar : new QStatusBar();
|
||||
if (m_statusBar->objectName().isEmpty()) { m_statusBar->setObjectName("sb_ManagedStatusBar"); }
|
||||
if (m_ownStatusBar) { m_statusBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);}
|
||||
|
||||
this->m_statusBarIcon = new QLabel(this->m_statusBar);
|
||||
this->m_statusBarLabel = new QLabel(this->m_statusBar);
|
||||
this->m_statusBarLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
this->m_statusBarIcon->setObjectName(QString("lbl_StatusBarIcon").append(this->m_statusBar->objectName()));
|
||||
this->m_statusBarLabel->setObjectName(QString("lbl_StatusBarLabel").append(this->m_statusBar->objectName()));
|
||||
m_statusBarIcon = new QLabel(m_statusBar);
|
||||
m_statusBarLabel = new QLabel(m_statusBar);
|
||||
m_statusBarLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
m_statusBarIcon->setObjectName(QString("lbl_StatusBarIcon").append(m_statusBar->objectName()));
|
||||
m_statusBarLabel->setObjectName(QString("lbl_StatusBarLabel").append(m_statusBar->objectName()));
|
||||
|
||||
// use insert to insert from left to right
|
||||
// this keeps any grip on the right size
|
||||
this->m_statusBar->insertPermanentWidget(0, this->m_statusBarIcon, 0); // status icon
|
||||
this->m_statusBar->insertPermanentWidget(1, this->m_statusBarLabel, 1); // status text
|
||||
m_statusBar->insertPermanentWidget(0, m_statusBarIcon, 0); // status icon
|
||||
m_statusBar->insertPermanentWidget(1, m_statusBarLabel, 1); // status text
|
||||
|
||||
// timer
|
||||
this->m_timerStatusBar = new QTimer(this);
|
||||
this->m_timerStatusBar->setObjectName(this->objectName().append(":m_timerStatusBar"));
|
||||
this->m_timerStatusBar->setSingleShot(true);
|
||||
connect(this->m_timerStatusBar, &QTimer::timeout, this, &CManagedStatusBar::ps_clearStatusBar);
|
||||
m_timerStatusBar = new QTimer(this);
|
||||
m_timerStatusBar->setObjectName(this->objectName().append(":m_timerStatusBar"));
|
||||
m_timerStatusBar->setSingleShot(true);
|
||||
connect(m_timerStatusBar, &QTimer::timeout, this, &CManagedStatusBar::clearStatusBar);
|
||||
|
||||
// done when injected status bar
|
||||
if (this->m_ownStatusBar)
|
||||
if (m_ownStatusBar)
|
||||
{
|
||||
// self created status bar
|
||||
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
sizePolicy.setHorizontalStretch(0);
|
||||
sizePolicy.setVerticalStretch(0);
|
||||
sizePolicy.setHeightForWidth(this->m_statusBar->sizePolicy().hasHeightForWidth());
|
||||
sizePolicy.setHeightForWidth(m_statusBar->sizePolicy().hasHeightForWidth());
|
||||
|
||||
this->m_statusBar->setMinimumHeight(24); // with no minimum height the layout always adjustes when displaying a status message
|
||||
this->m_statusBar->setSizePolicy(sizePolicy);
|
||||
this->m_statusBar->setSizeGripEnabled(false);
|
||||
m_statusBar->setMinimumHeight(24); // with no minimum height the layout always adjustes when displaying a status message
|
||||
m_statusBar->setSizePolicy(sizePolicy);
|
||||
m_statusBar->setSizeGripEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CManagedStatusBar::show()
|
||||
{
|
||||
if (!this->m_statusBar) { return; }
|
||||
this->m_statusBar->show();
|
||||
if (!m_statusBar) { return; }
|
||||
m_statusBar->show();
|
||||
}
|
||||
|
||||
void CManagedStatusBar::hide()
|
||||
{
|
||||
if (!this->m_statusBar) { return; }
|
||||
this->m_statusBar->hide();
|
||||
if (!m_statusBar) { return; }
|
||||
m_statusBar->hide();
|
||||
|
||||
// reset minimum width
|
||||
if (this->m_ownStatusBar)
|
||||
if (m_ownStatusBar)
|
||||
{
|
||||
this->m_statusBar->setMinimumWidth(50);
|
||||
m_statusBar->setMinimumWidth(50);
|
||||
}
|
||||
}
|
||||
|
||||
void CManagedStatusBar::displayStatusMessage(const CStatusMessage &statusMessage)
|
||||
{
|
||||
Q_ASSERT_X(this->m_statusBarIcon, Q_FUNC_INFO, "Missing status bar icon");
|
||||
Q_ASSERT_X(this->m_statusBar, Q_FUNC_INFO, "Missing status bar");
|
||||
Q_ASSERT_X(m_statusBarIcon, Q_FUNC_INFO, "Missing status bar icon");
|
||||
Q_ASSERT_X(m_statusBar, Q_FUNC_INFO, "Missing status bar");
|
||||
|
||||
// already displaying a message with severity higher than this one?
|
||||
if (!statusMessage.isSeverityHigherOrEqual(m_currentSeverity)) { return; }
|
||||
@@ -110,17 +110,17 @@ namespace BlackGui
|
||||
statusMessage.markAsHandledBy(this);
|
||||
|
||||
this->show();
|
||||
this->m_timerStatusBar->start(3000); // start / restart
|
||||
this->m_statusBarIcon->setPixmap(statusMessage.toPixmap());
|
||||
this->m_statusBarLabel->setText(statusMessage.getMessage());
|
||||
m_timerStatusBar->start(3000); // start / restart
|
||||
m_statusBarIcon->setPixmap(statusMessage.toPixmap());
|
||||
m_statusBarLabel->setText(statusMessage.getMessage());
|
||||
m_currentSeverity = statusMessage.getSeverity();
|
||||
|
||||
// restrict size for own status bars
|
||||
if (this->m_ownStatusBar)
|
||||
if (m_ownStatusBar)
|
||||
{
|
||||
QSize size = this->m_statusBar->window()->size();
|
||||
QSize size = m_statusBar->window()->size();
|
||||
int w = qRound(0.95 * size.width());
|
||||
this->m_statusBar->setMaximumWidth(w);
|
||||
m_statusBar->setMaximumWidth(w);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,12 +132,12 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CManagedStatusBar::ps_clearStatusBar()
|
||||
void CManagedStatusBar::clearStatusBar()
|
||||
{
|
||||
m_currentSeverity = StatusSeverity::SeverityDebug;
|
||||
if (!this->m_statusBar) { return; }
|
||||
this->m_statusBarIcon->clear();
|
||||
this->m_statusBarLabel->clear();
|
||||
if (!m_statusBar) { return; }
|
||||
m_statusBarIcon->clear();
|
||||
m_statusBarLabel->clear();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class QLabel;
|
||||
@@ -24,7 +23,6 @@ class QTimer;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
|
||||
//! Managed status bar
|
||||
class BLACKGUI_EXPORT CManagedStatusBar : public QObject
|
||||
{
|
||||
@@ -35,7 +33,7 @@ namespace BlackGui
|
||||
explicit CManagedStatusBar(QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CManagedStatusBar();
|
||||
virtual ~CManagedStatusBar();
|
||||
|
||||
//! Get the status bar
|
||||
QStatusBar *getStatusBar() const { return m_statusBar; }
|
||||
@@ -56,11 +54,10 @@ namespace BlackGui
|
||||
//! Display status messages
|
||||
void displayStatusMessages(const BlackMisc::CStatusMessageList &statusMessages);
|
||||
|
||||
private slots:
|
||||
//! Clear status bar
|
||||
void ps_clearStatusBar();
|
||||
|
||||
private:
|
||||
//! Clear status bar
|
||||
void clearStatusBar();
|
||||
|
||||
QStatusBar *m_statusBar = nullptr; //!< the status bar itself
|
||||
QLabel *m_statusBarIcon = nullptr; //!< status bar icon
|
||||
QLabel *m_statusBarLabel = nullptr; //!< status bar label
|
||||
@@ -68,7 +65,6 @@ namespace BlackGui
|
||||
bool m_ownStatusBar = false;
|
||||
BlackMisc::StatusSeverity m_currentSeverity = BlackMisc::StatusSeverity::SeverityDebug; // severity currently displayed
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
class QObject;
|
||||
|
||||
namespace BlackMisc { namespace Network { class CServer; } }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
|
||||
@@ -21,13 +21,12 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Network
|
||||
{
|
||||
|
||||
QString CClient::convertToQString(bool i18n) const
|
||||
{
|
||||
QString s = this->m_user.toQString(i18n);
|
||||
QString s = m_user.toQString(i18n);
|
||||
s.append(" capabilites: ").append(this->getCapabilitiesAsString());
|
||||
s.append(" model: ").append(this->m_modelString);
|
||||
if (!this->m_server.isEmpty()) { s.append(" server:").append(this->m_server); }
|
||||
s.append(" model: ").append(m_modelString);
|
||||
if (!m_server.isEmpty()) { s.append(" server:").append(m_server); }
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -36,17 +35,17 @@ namespace BlackMisc
|
||||
|
||||
bool CClient::isValid() const
|
||||
{
|
||||
return this->m_user.hasValidCallsign();
|
||||
return m_user.hasValidCallsign();
|
||||
}
|
||||
|
||||
void CClient::setCapability(bool hasCapability, CClient::Capabilities capability)
|
||||
{
|
||||
this->m_capabilities.addValue(static_cast<int>(capability), hasCapability);
|
||||
m_capabilities.addValue(static_cast<int>(capability), hasCapability);
|
||||
}
|
||||
|
||||
void CClient::setCapabilities(const CPropertyIndexVariantMap &capabilities)
|
||||
{
|
||||
this->m_capabilities = capabilities;
|
||||
m_capabilities = capabilities;
|
||||
}
|
||||
|
||||
QString CClient::getCapabilitiesAsString() const
|
||||
@@ -62,9 +61,9 @@ namespace BlackMisc
|
||||
|
||||
bool CClient::hasCapability(CClient::Capabilities capability) const
|
||||
{
|
||||
if (this->m_capabilities.contains(capability))
|
||||
if (m_capabilities.contains(capability))
|
||||
{
|
||||
return this->m_capabilities.value(capability).toBool();
|
||||
return m_capabilities.value(capability).toBool();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -74,17 +73,17 @@ namespace BlackMisc
|
||||
|
||||
void CClient::setUserCallsign(const Aviation::CCallsign &callsign)
|
||||
{
|
||||
this->m_user.setCallsign(callsign);
|
||||
m_user.setCallsign(callsign);
|
||||
}
|
||||
|
||||
CVariant CClient::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CClient::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCapabilities:
|
||||
return CVariant::fromValue(this->m_capabilities);
|
||||
return CVariant::fromValue(m_capabilities);
|
||||
case IndexCapabilitiesString:
|
||||
return CVariant(this->getCapabilitiesAsString());
|
||||
case IndexCallsign:
|
||||
@@ -92,17 +91,17 @@ namespace BlackMisc
|
||||
case IndexUser:
|
||||
return this->getUser().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexModelString:
|
||||
return CVariant(this->m_modelString);
|
||||
return CVariant(m_modelString);
|
||||
case IndexServer:
|
||||
return CVariant(this->m_server);
|
||||
return CVariant(m_server);
|
||||
case IndexVoiceCapabilities:
|
||||
return this->m_voiceCapabilities.propertyByIndex(index.copyFrontRemoved());
|
||||
return m_voiceCapabilities.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexVoiceCapabilitiesPixmap:
|
||||
return CVariant::from(this->m_voiceCapabilities.toPixmap());
|
||||
return CVariant::from(m_voiceCapabilities.toPixmap());
|
||||
case IndexVoiceCapabilitiesIcon:
|
||||
return CVariant::fromValue(this->m_voiceCapabilities.toIcon());
|
||||
return CVariant::fromValue(m_voiceCapabilities.toIcon());
|
||||
case IndexVoiceCapabilitiesString:
|
||||
return CVariant(this->m_voiceCapabilities.toQString(true));
|
||||
return CVariant(m_voiceCapabilities.toQString(true));
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
@@ -111,26 +110,26 @@ namespace BlackMisc
|
||||
void CClient::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CClient>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCapabilities:
|
||||
this->m_capabilities = variant.value<CPropertyIndexVariantMap>();
|
||||
m_capabilities = variant.value<CPropertyIndexVariantMap>();
|
||||
break;
|
||||
case IndexModelString:
|
||||
this->m_modelString = variant.toQString();
|
||||
m_modelString = variant.toQString();
|
||||
break;
|
||||
case IndexServer:
|
||||
this->m_server = variant.toQString();
|
||||
m_server = variant.toQString();
|
||||
break;
|
||||
case IndexUser:
|
||||
this->m_user.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
m_user.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexCallsign:
|
||||
this->m_user.setCallsign(variant.value<BlackMisc::Aviation::CCallsign>());
|
||||
m_user.setCallsign(variant.value<BlackMisc::Aviation::CCallsign>());
|
||||
break;
|
||||
case IndexVoiceCapabilities:
|
||||
this->m_voiceCapabilities.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
m_voiceCapabilities.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace BlackMisc
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexCapabilities = BlackMisc::CPropertyIndex::GlobalIndexCClient,
|
||||
IndexCapabilities = CPropertyIndex::GlobalIndexCClient,
|
||||
IndexCapabilitiesString,
|
||||
IndexModelString,
|
||||
IndexServer,
|
||||
@@ -53,7 +53,7 @@ namespace BlackMisc
|
||||
//! The Capabilities enum
|
||||
enum Capabilities
|
||||
{
|
||||
FsdWithInterimPositions = BlackMisc::CPropertyIndex::GlobalIndexClientCapabilities, //!< interim positions
|
||||
FsdWithInterimPositions = CPropertyIndex::GlobalIndexClientCapabilities, //!< interim positions
|
||||
FsdWithIcaoCodes, //!< basically means it is a pilot client handling ICAO code pacakages
|
||||
FsdAtisCanBeReceived, //!< ATIS
|
||||
FsdWithAircraftConfig //!< Aircraft parts
|
||||
@@ -69,7 +69,7 @@ namespace BlackMisc
|
||||
CClient(const CUser &user) : m_user(user) {}
|
||||
|
||||
//! Callsign used with other client
|
||||
const BlackMisc::Aviation::CCallsign &getCallsign() const { return this->m_user.getCallsign(); }
|
||||
const BlackMisc::Aviation::CCallsign &getCallsign() const { return m_user.getCallsign(); }
|
||||
|
||||
//! ATC client
|
||||
bool isAtc() const { return getCallsign().isAtcAlikeCallsign(); }
|
||||
@@ -78,7 +78,7 @@ namespace BlackMisc
|
||||
bool isValid() const;
|
||||
|
||||
//! Get capabilities
|
||||
CPropertyIndexVariantMap getCapabilities() const { return this->m_capabilities; }
|
||||
CPropertyIndexVariantMap getCapabilities() const { return m_capabilities; }
|
||||
|
||||
//! Set capability
|
||||
void setCapability(bool hasCapability, Capabilities capability);
|
||||
@@ -105,31 +105,31 @@ namespace BlackMisc
|
||||
void setVoiceCapabilities(const QString &flightPlanRemarks) { m_voiceCapabilities = CVoiceCapabilities(flightPlanRemarks);}
|
||||
|
||||
//! User
|
||||
const CUser &getUser() const { return this->m_user; }
|
||||
const CUser &getUser() const { return m_user; }
|
||||
|
||||
//! User
|
||||
void setUser(const CUser &user) { this->m_user = user;}
|
||||
void setUser(const CUser &user) { m_user = user;}
|
||||
|
||||
//! User's callsign
|
||||
void setUserCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! Server
|
||||
const QString &getServer() const { return this->m_server; }
|
||||
const QString &getServer() const { return m_server; }
|
||||
|
||||
//! Server
|
||||
void setServer(const QString &server) { this->m_server = server;}
|
||||
void setServer(const QString &server) { m_server = server;}
|
||||
|
||||
//! Model
|
||||
const QString &getQueriedModelString() const { return this->m_modelString; }
|
||||
const QString &getQueriedModelString() const { return m_modelString; }
|
||||
|
||||
//! \copydoc Simulation::CAircraftModel::hasQueriedModelString
|
||||
bool hasQueriedModelString() const { return !this->m_modelString.isEmpty(); }
|
||||
bool hasQueriedModelString() const { return !m_modelString.isEmpty(); }
|
||||
|
||||
//! Set model
|
||||
void setQueriedModelString(const QString &modelString) { this->m_modelString = modelString.trimmed(); }
|
||||
void setQueriedModelString(const QString &modelString) { m_modelString = modelString.trimmed(); }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Icon::toIcon()
|
||||
CIcon toIcon() const { return this->m_user.toIcon(); }
|
||||
CIcon toIcon() const { return m_user.toIcon(); }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
@@ -141,11 +141,11 @@ namespace BlackMisc
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
private:
|
||||
BlackMisc::Network::CUser m_user;
|
||||
BlackMisc::CPropertyIndexVariantMap m_capabilities;
|
||||
QString m_modelString;
|
||||
QString m_server;
|
||||
BlackMisc::Network::CVoiceCapabilities m_voiceCapabilities;
|
||||
CUser m_user;
|
||||
CPropertyIndexVariantMap m_capabilities;
|
||||
QString m_modelString;
|
||||
QString m_server;
|
||||
CVoiceCapabilities m_voiceCapabilities;
|
||||
|
||||
BLACK_METACLASS(
|
||||
CClient,
|
||||
|
||||
@@ -56,11 +56,11 @@ namespace BlackMisc
|
||||
QString CUser::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
if (this->m_realname.isEmpty()) return "<no realname>";
|
||||
QString s = this->m_realname;
|
||||
if (m_realname.isEmpty()) return "<no realname>";
|
||||
QString s = m_realname;
|
||||
if (this->hasValidId())
|
||||
{
|
||||
s.append(" (").append(this->m_id).append(')');
|
||||
s.append(" (").append(m_id).append(')');
|
||||
}
|
||||
if (this->hasValidCallsign())
|
||||
{
|
||||
@@ -71,12 +71,12 @@ namespace BlackMisc
|
||||
|
||||
void CUser::deriveHomeBaseFromCallsign()
|
||||
{
|
||||
if (this->m_callsign.isEmpty()) { return; }
|
||||
if (this->m_homebase.isEmpty())
|
||||
if (m_callsign.isEmpty()) { return; }
|
||||
if (m_homebase.isEmpty())
|
||||
{
|
||||
if (this->m_callsign.isAtcCallsign())
|
||||
if (m_callsign.isAtcCallsign())
|
||||
{
|
||||
this->m_homebase = this->m_callsign.getIcaoCode();
|
||||
m_homebase = m_callsign.getIcaoCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ namespace BlackMisc
|
||||
QString rn(removeAccents(realname.trimmed().simplified()));
|
||||
if (rn.isEmpty())
|
||||
{
|
||||
this->m_realname = "";
|
||||
m_realname = "";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
// do not beautify before stripping home base
|
||||
this->m_realname = beautifyRealName(rn);
|
||||
m_realname = beautifyRealName(rn);
|
||||
}
|
||||
|
||||
CStatusMessageList CUser::validate() const
|
||||
@@ -187,12 +187,12 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexEmail: return CVariant(this->m_email);
|
||||
case IndexId: return CVariant(this->m_id);
|
||||
case IndexPassword: return CVariant(this->m_password);
|
||||
case IndexRealName: return CVariant(this->m_realname);
|
||||
case IndexHomebase: return this->m_homebase.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexCallsign: return this->m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexEmail: return CVariant(m_email);
|
||||
case IndexId: return CVariant(m_id);
|
||||
case IndexPassword: return CVariant(m_password);
|
||||
case IndexRealName: return CVariant(m_realname);
|
||||
case IndexHomebase: return m_homebase.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
@@ -207,8 +207,8 @@ namespace BlackMisc
|
||||
case IndexId: this->setId(variant.value<QString>()); break;
|
||||
case IndexPassword: this->setPassword(variant.value<QString>()); break;
|
||||
case IndexRealName: this->setRealName(variant.value<QString>()); break;
|
||||
case IndexHomebase: this->m_homebase.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexCallsign: this->m_callsign.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexHomebase: m_homebase.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexCallsign: m_callsign.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
@@ -219,11 +219,11 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexEmail: return this->m_email.compare(compareValue.getEmail(), Qt::CaseInsensitive);
|
||||
case IndexId: return this->m_id.compare(compareValue.getId(), Qt::CaseInsensitive);
|
||||
case IndexRealName: return this->m_realname.compare(compareValue.getRealName(), Qt::CaseInsensitive);
|
||||
case IndexHomebase: return this->m_homebase.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getHomeBase());
|
||||
case IndexCallsign: return this->m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
||||
case IndexEmail: return m_email.compare(compareValue.getEmail(), Qt::CaseInsensitive);
|
||||
case IndexId: return m_id.compare(compareValue.getId(), Qt::CaseInsensitive);
|
||||
case IndexRealName: return m_realname.compare(compareValue.getRealName(), Qt::CaseInsensitive);
|
||||
case IndexHomebase: return m_homebase.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getHomeBase());
|
||||
case IndexCallsign: return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
||||
case IndexPassword: break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace BlackMisc
|
||||
*/
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexEmail = BlackMisc::CPropertyIndex::GlobalIndexCUser,
|
||||
IndexEmail = CPropertyIndex::GlobalIndexCUser,
|
||||
IndexId,
|
||||
IndexPassword,
|
||||
IndexRealName,
|
||||
@@ -52,13 +52,13 @@ namespace BlackMisc
|
||||
CUser() = default;
|
||||
|
||||
//! Constructor by callsign
|
||||
CUser(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
CUser(const Aviation::CCallsign &callsign);
|
||||
|
||||
//! Constructor.
|
||||
CUser(const QString &id, const QString &realname, const BlackMisc::Aviation::CCallsign &callsign);
|
||||
CUser(const QString &id, const QString &realname, const Aviation::CCallsign &callsign);
|
||||
|
||||
//! Constructor.
|
||||
CUser(const QString &id, const QString &realname, const QString &email = "", const QString &password = "", const BlackMisc::Aviation::CCallsign &callsign = {});
|
||||
CUser(const QString &id, const QString &realname, const QString &email = "", const QString &password = "", const Aviation::CCallsign &callsign = {});
|
||||
|
||||
//! Get full name.
|
||||
QString getRealName() const { return m_realname; }
|
||||
@@ -73,16 +73,16 @@ namespace BlackMisc
|
||||
void setPassword(const QString &pw) { m_password = pw.trimmed(); }
|
||||
|
||||
//! Valid user object?
|
||||
bool isValid() const { return !this->m_realname.isEmpty() && !this->m_id.isEmpty(); }
|
||||
bool isValid() const { return !m_realname.isEmpty() && !m_id.isEmpty(); }
|
||||
|
||||
//! Valid credentials?
|
||||
bool hasValidCredentials() const { return this->isValid() && !this->m_password.isEmpty(); }
|
||||
bool hasValidCredentials() const { return this->isValid() && !m_password.isEmpty(); }
|
||||
|
||||
//! Valid real name?
|
||||
bool hasValidRealName() const { return !this->m_realname.isEmpty(); }
|
||||
bool hasValidRealName() const { return !m_realname.isEmpty(); }
|
||||
|
||||
//! Valid id?
|
||||
bool hasValidId() const { return !this->m_id.isEmpty(); }
|
||||
bool hasValidId() const { return !m_id.isEmpty(); }
|
||||
|
||||
//! Has associated callsign?
|
||||
bool hasValidCallsign() const { return !m_callsign.isEmpty(); }
|
||||
@@ -91,7 +91,7 @@ namespace BlackMisc
|
||||
bool hasValidHomebase() const { return !m_homebase.isEmpty(); }
|
||||
|
||||
//! Validate, provide details about issues
|
||||
BlackMisc::CStatusMessageList validate() const;
|
||||
CStatusMessageList validate() const;
|
||||
|
||||
//! Get email.
|
||||
QString getEmail() const { return m_email; }
|
||||
@@ -100,7 +100,7 @@ namespace BlackMisc
|
||||
void setEmail(const QString &email) { m_email = email.trimmed(); }
|
||||
|
||||
//! Valid email?
|
||||
bool hasValidEmail() const { return !this->m_email.isEmpty(); }
|
||||
bool hasValidEmail() const { return !m_email.isEmpty(); }
|
||||
|
||||
//! Get id.
|
||||
QString getId() const { return m_id; }
|
||||
@@ -109,28 +109,28 @@ namespace BlackMisc
|
||||
void setId(const QString &id) { m_id = id.trimmed(); }
|
||||
|
||||
//! Homebase
|
||||
const BlackMisc::Aviation::CAirportIcaoCode &getHomeBase() const { return this->m_homebase; }
|
||||
const Aviation::CAirportIcaoCode &getHomeBase() const { return m_homebase; }
|
||||
|
||||
//! Set homebase
|
||||
void setHomeBase(const BlackMisc::Aviation::CAirportIcaoCode &homebase) { this->m_homebase = homebase; }
|
||||
void setHomeBase(const Aviation::CAirportIcaoCode &homebase) { m_homebase = homebase; }
|
||||
|
||||
//! Has home base?
|
||||
bool hasHomeBase() const { return !this->m_homebase.isEmpty(); }
|
||||
bool hasHomeBase() const { return !m_homebase.isEmpty(); }
|
||||
|
||||
//! Get associated callsign.
|
||||
const BlackMisc::Aviation::CCallsign &getCallsign() const { return m_callsign; }
|
||||
const Aviation::CCallsign &getCallsign() const { return m_callsign; }
|
||||
|
||||
//! Set associated callsign
|
||||
void setCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
void setCallsign(const Aviation::CCallsign &callsign);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Icon::toIcon()
|
||||
BlackMisc::CIcon toIcon() const { return this->getCallsign().toIcon(); }
|
||||
CIcon toIcon() const { return this->getCallsign().toIcon(); }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Compare by index
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const CUser &compareValue) const;
|
||||
@@ -158,8 +158,8 @@ namespace BlackMisc
|
||||
QString m_realname;
|
||||
QString m_email;
|
||||
QString m_password;
|
||||
BlackMisc::Aviation::CCallsign m_callsign;
|
||||
BlackMisc::Aviation::CAirportIcaoCode m_homebase;
|
||||
Aviation::CCallsign m_callsign;
|
||||
Aviation::CAirportIcaoCode m_homebase;
|
||||
|
||||
BLACK_METACLASS(
|
||||
CUser,
|
||||
|
||||
@@ -44,17 +44,17 @@ namespace BlackMisc
|
||||
template <class MU, class PQ>
|
||||
MU CPhysicalQuantity<MU, PQ>::getUnit() const
|
||||
{
|
||||
return this->m_unit;
|
||||
return m_unit;
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::setUnitBySymbol(const QString &unitName)
|
||||
{
|
||||
this->m_unit = CMeasurementUnit::unitFromSymbol<MU>(unitName);
|
||||
m_unit = CMeasurementUnit::unitFromSymbol<MU>(unitName);
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
QString CPhysicalQuantity<MU, PQ>::getUnitSymbol() const { return this->m_unit.getSymbol(true); }
|
||||
QString CPhysicalQuantity<MU, PQ>::getUnitSymbol() const { return m_unit.getSymbol(true); }
|
||||
|
||||
template <class MU, class PQ>
|
||||
CPhysicalQuantity<MU, PQ>::CPhysicalQuantity(double value, MU unit) :
|
||||
@@ -76,8 +76,8 @@ namespace BlackMisc
|
||||
if (this->isNull()) return other.isNull();
|
||||
if (other.isNull()) return false;
|
||||
|
||||
double diff = std::abs(this->m_value - other.value(this->m_unit));
|
||||
return diff <= this->m_unit.getEpsilon();
|
||||
double diff = std::abs(m_value - other.value(m_unit));
|
||||
return diff <= m_unit.getEpsilon();
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
@@ -89,7 +89,7 @@ namespace BlackMisc
|
||||
template <class MU, class PQ>
|
||||
CPhysicalQuantity<MU, PQ> &CPhysicalQuantity<MU, PQ>::operator +=(const CPhysicalQuantity<MU, PQ> &other)
|
||||
{
|
||||
this->m_value += other.value(this->m_unit);
|
||||
m_value += other.value(m_unit);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -104,19 +104,19 @@ namespace BlackMisc
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::addValueSameUnit(double value)
|
||||
{
|
||||
this->m_value += value;
|
||||
m_value += value;
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::substractValueSameUnit(double value)
|
||||
{
|
||||
this->m_value -= value;
|
||||
m_value -= value;
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
CPhysicalQuantity<MU, PQ> &CPhysicalQuantity<MU, PQ>::operator -=(const CPhysicalQuantity<MU, PQ> &other)
|
||||
{
|
||||
this->m_value -= other.value(this->m_unit);
|
||||
m_value -= other.value(m_unit);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -131,31 +131,31 @@ namespace BlackMisc
|
||||
template <class MU, class PQ>
|
||||
bool CPhysicalQuantity<MU, PQ>::isZeroEpsilonConsidered() const
|
||||
{
|
||||
return this->m_unit.isEpsilon(this->m_value);
|
||||
return m_unit.isEpsilon(m_value);
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
bool CPhysicalQuantity<MU, PQ>::isPositiveWithEpsilonConsidered() const
|
||||
{
|
||||
return !this->isZeroEpsilonConsidered() && this->m_value > 0;
|
||||
return !this->isZeroEpsilonConsidered() && m_value > 0;
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
bool CPhysicalQuantity<MU, PQ>::isNegativeWithEpsilonConsidered() const
|
||||
{
|
||||
return !this->isZeroEpsilonConsidered() && this->m_value < 0;
|
||||
return !this->isZeroEpsilonConsidered() && m_value < 0;
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::makePositive()
|
||||
{
|
||||
if (this->m_value < 0) { this->m_value *= -1.0; }
|
||||
if (m_value < 0) { m_value *= -1.0; }
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::makeNegative()
|
||||
{
|
||||
if (this->m_value > 0) { this->m_value *= -1.0; }
|
||||
if (m_value > 0) { m_value *= -1.0; }
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
@@ -163,27 +163,27 @@ namespace BlackMisc
|
||||
{
|
||||
constexpr double NaN = std::numeric_limits<double>::quiet_NaN();
|
||||
argument << (this->isNull() ? NaN : this->value(UnitClass::defaultUnit()));
|
||||
// argument << this->m_value;
|
||||
// argument << this->m_unit;
|
||||
// argument << m_value;
|
||||
// argument << m_unit;
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::unmarshallFromDbus(const QDBusArgument &argument)
|
||||
{
|
||||
argument >> this->m_value;
|
||||
this->m_unit = UnitClass::defaultUnit();
|
||||
if (std::isnan(this->m_value))
|
||||
argument >> m_value;
|
||||
m_unit = UnitClass::defaultUnit();
|
||||
if (std::isnan(m_value))
|
||||
{
|
||||
this->setNull();
|
||||
}
|
||||
// argument >> this->m_value;
|
||||
// argument >> this->m_unit;
|
||||
// argument >> m_value;
|
||||
// argument >> m_unit;
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
CPhysicalQuantity<MU, PQ> &CPhysicalQuantity<MU, PQ>::operator *=(double factor)
|
||||
{
|
||||
this->m_value *= factor;
|
||||
m_value *= factor;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace BlackMisc
|
||||
template <class MU, class PQ>
|
||||
CPhysicalQuantity<MU, PQ> &CPhysicalQuantity<MU, PQ>::operator /=(double divisor)
|
||||
{
|
||||
this->m_value /= divisor;
|
||||
m_value /= divisor;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace BlackMisc
|
||||
if (*this == other) return false;
|
||||
if (this->isNull() || other.isNull()) return false;
|
||||
|
||||
return (this->m_value < other.value(this->m_unit));
|
||||
return (m_value < other.value(m_unit));
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
@@ -242,10 +242,10 @@ namespace BlackMisc
|
||||
template <class MU, class PQ>
|
||||
PQ &CPhysicalQuantity<MU, PQ>::switchUnit(MU newUnit)
|
||||
{
|
||||
if (this->m_unit != newUnit)
|
||||
if (m_unit != newUnit)
|
||||
{
|
||||
this->m_value = newUnit.convertFrom(this->m_value, this->m_unit);
|
||||
this->m_unit = newUnit;
|
||||
m_value = newUnit.convertFrom(m_value, m_unit);
|
||||
m_unit = newUnit;
|
||||
}
|
||||
return *derived();
|
||||
}
|
||||
@@ -253,21 +253,21 @@ namespace BlackMisc
|
||||
template <class MU, class PQ>
|
||||
bool CPhysicalQuantity<MU, PQ>::isNull() const
|
||||
{
|
||||
return this->m_unit.isNull();
|
||||
return m_unit.isNull();
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::setNull()
|
||||
{
|
||||
this->m_value = 0;
|
||||
this->m_unit = MU::nullUnit();
|
||||
m_value = 0;
|
||||
m_unit = MU::nullUnit();
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
double CPhysicalQuantity<MU, PQ>::value() const
|
||||
{
|
||||
if (this->isNull()) { return 0.0; }
|
||||
return this->m_value;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
@@ -275,14 +275,14 @@ namespace BlackMisc
|
||||
{
|
||||
if (!this->isNull())
|
||||
{
|
||||
this->m_value = value;
|
||||
m_value = value;
|
||||
}
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::setValueSameUnit(double baseValue)
|
||||
{
|
||||
this->m_value = baseValue;
|
||||
m_value = baseValue;
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
@@ -297,14 +297,14 @@ namespace BlackMisc
|
||||
QString CPhysicalQuantity<MU, PQ>::valueRoundedWithUnit(int digits, bool i18n) const
|
||||
{
|
||||
if (this->isNull()) { return this->convertToQString(i18n); }
|
||||
return this->valueRoundedWithUnit(this->m_unit, digits, i18n);
|
||||
return this->valueRoundedWithUnit(m_unit, digits, i18n);
|
||||
}
|
||||
|
||||
template<class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::roundToEpsilon()
|
||||
{
|
||||
if (this->isNull()) { return; }
|
||||
this->m_value = this->m_unit.roundToEpsilon(this->m_value);
|
||||
m_value = m_unit.roundToEpsilon(m_value);
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
@@ -325,14 +325,14 @@ namespace BlackMisc
|
||||
template <class MU, class PQ>
|
||||
double CPhysicalQuantity<MU, PQ>::valueRounded(int digits) const
|
||||
{
|
||||
return this->valueRounded(this->m_unit, digits);
|
||||
return this->valueRounded(m_unit, digits);
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
double CPhysicalQuantity<MU, PQ>::value(MU unit) const
|
||||
{
|
||||
Q_ASSERT_X(!unit.isNull(), Q_FUNC_INFO, "Cannot convert to null");
|
||||
return unit.convertFrom(this->m_value, this->m_unit);
|
||||
return unit.convertFrom(m_value, m_unit);
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
@@ -356,8 +356,8 @@ namespace BlackMisc
|
||||
QJsonObject CPhysicalQuantity<MU, PQ>::toJson() const
|
||||
{
|
||||
QJsonObject json;
|
||||
json.insert("value", QJsonValue(this->m_value));
|
||||
json.insert("unit", QJsonValue(this->m_unit.getSymbol()));
|
||||
json.insert("value", QJsonValue(m_value));
|
||||
json.insert("unit", QJsonValue(m_unit.getSymbol()));
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ namespace BlackMisc
|
||||
if (value.isUndefined()) { throw CJsonException("Missing 'value'"); }
|
||||
|
||||
this->setUnitBySymbol(unit.toString());
|
||||
this->m_value = value.toDouble();
|
||||
m_value = value.toDouble();
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
@@ -389,25 +389,17 @@ namespace BlackMisc
|
||||
CVariant CPhysicalQuantity<MU, PQ>::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*derived()); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexValue:
|
||||
return CVariant::from(this->m_value);
|
||||
case IndexUnit:
|
||||
return CVariant::from(this->m_unit);
|
||||
case IndexValueRounded0DigitsWithUnit:
|
||||
return CVariant::from(this->valueRoundedWithUnit(0));
|
||||
case IndexValueRounded1DigitsWithUnit:
|
||||
return CVariant::from(this->valueRoundedWithUnit(1));
|
||||
case IndexValueRounded2DigitsWithUnit:
|
||||
return CVariant::from(this->valueRoundedWithUnit(2));
|
||||
case IndexValueRounded3DigitsWithUnit:
|
||||
return CVariant::from(this->valueRoundedWithUnit(3));
|
||||
case IndexValueRounded6DigitsWithUnit:
|
||||
return CVariant::from(this->valueRoundedWithUnit(6));
|
||||
default:
|
||||
return Mixin::Index<PQ>::propertyByIndex(index);
|
||||
case IndexValue: return CVariant::from(m_value);
|
||||
case IndexUnit: return CVariant::from(m_unit);
|
||||
case IndexValueRounded0DigitsWithUnit: return CVariant::from(this->valueRoundedWithUnit(0));
|
||||
case IndexValueRounded1DigitsWithUnit: return CVariant::from(this->valueRoundedWithUnit(1));
|
||||
case IndexValueRounded2DigitsWithUnit: return CVariant::from(this->valueRoundedWithUnit(2));
|
||||
case IndexValueRounded3DigitsWithUnit: return CVariant::from(this->valueRoundedWithUnit(3));
|
||||
case IndexValueRounded6DigitsWithUnit: return CVariant::from(this->valueRoundedWithUnit(6));
|
||||
default: return Mixin::Index<PQ>::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,14 +407,14 @@ namespace BlackMisc
|
||||
void CPhysicalQuantity<MU, PQ>::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<PQ>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexValue:
|
||||
this->m_value = variant.toDouble();
|
||||
m_value = variant.toDouble();
|
||||
break;
|
||||
case IndexUnit:
|
||||
this->m_unit = variant.to<MU>();
|
||||
m_unit = variant.to<MU>();
|
||||
break;
|
||||
case IndexValueRounded0DigitsWithUnit:
|
||||
case IndexValueRounded1DigitsWithUnit:
|
||||
@@ -441,13 +433,11 @@ namespace BlackMisc
|
||||
int CPhysicalQuantity<MU, PQ>::comparePropertyByIndex(const CPropertyIndex &index, const PQ &pq) const
|
||||
{
|
||||
if (index.isMyself()) { return compareImpl(*derived(), pq); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexValue:
|
||||
return Compare::compare(this->m_value, pq.m_value);
|
||||
default:
|
||||
break;
|
||||
case IndexValue: return Compare::compare(m_value, pq.m_value);
|
||||
default: break;
|
||||
}
|
||||
BLACK_VERIFY_X(false, Q_FUNC_INFO, qUtf8Printable("No comparison for index " + index.toQString()));
|
||||
return 0;
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace BlackMisc
|
||||
class BLACKMISC_EXPORT CTestData
|
||||
{
|
||||
public:
|
||||
//! Traffic server
|
||||
//! Traffic server (dummy)
|
||||
static const BlackMisc::Network::CServer &getTrafficServer();
|
||||
|
||||
//! Get a variant list with various data
|
||||
|
||||
Reference in New Issue
Block a user