mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
refs #466 Resolved TODO item in GUI.
This commit is contained in:
@@ -186,10 +186,9 @@ namespace BlackGui
|
||||
QTime t = dateTime.value<QTime>();
|
||||
return t.toString(m_formatString);
|
||||
}
|
||||
else if (static_cast<QMetaType::Type>(dateTime.type()) == QMetaType::Int)
|
||||
else if (dateTime.isIntegral())
|
||||
{
|
||||
//! \todo potential risk if int is not qint64
|
||||
QDateTime t = QDateTime::fromMSecsSinceEpoch(dateTime.toInt());
|
||||
QDateTime t = QDateTime::fromMSecsSinceEpoch(dateTime.value<qint64>());
|
||||
return t.toString(m_formatString);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -37,6 +37,23 @@ namespace BlackMisc
|
||||
return m_v.toString();
|
||||
}
|
||||
|
||||
bool CVariant::isIntegral() const
|
||||
{
|
||||
switch (type())
|
||||
{
|
||||
case QMetaType::Bool: case QMetaType::Char: case QMetaType::UChar: case QMetaType::SChar: case QMetaType::Short: case QMetaType::UShort:
|
||||
case QMetaType::Int: case QMetaType::UInt: case QMetaType::Long: case QMetaType::ULong: case QMetaType::LongLong: case QMetaType::ULongLong:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CVariant::isArithmetic() const
|
||||
{
|
||||
return isIntegral() || type() == QMetaType::Float || type() == QMetaType::Double;
|
||||
}
|
||||
|
||||
int CVariant::compareImpl(const CVariant &a, const CVariant &b)
|
||||
{
|
||||
if (a.userType() < b.userType()) { return -1; }
|
||||
|
||||
@@ -231,6 +231,12 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! True if this variant's type is an integral type.
|
||||
bool isIntegral() const;
|
||||
|
||||
//! True if this variant's type is an integral or floating-point type.
|
||||
bool isArithmetic() const;
|
||||
|
||||
//! Convert this variant to a bool.
|
||||
bool toBool() const { return m_v.toBool(); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user