mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 11:05:44 +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>();
|
QTime t = dateTime.value<QTime>();
|
||||||
return t.toString(m_formatString);
|
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.value<qint64>());
|
||||||
QDateTime t = QDateTime::fromMSecsSinceEpoch(dateTime.toInt());
|
|
||||||
return t.toString(m_formatString);
|
return t.toString(m_formatString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -37,6 +37,23 @@ namespace BlackMisc
|
|||||||
return m_v.toString();
|
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)
|
int CVariant::compareImpl(const CVariant &a, const CVariant &b)
|
||||||
{
|
{
|
||||||
if (a.userType() < b.userType()) { return -1; }
|
if (a.userType() < b.userType()) { return -1; }
|
||||||
|
|||||||
@@ -231,6 +231,12 @@ namespace BlackMisc
|
|||||||
//! \copydoc CValueObject::convertToQString
|
//! \copydoc CValueObject::convertToQString
|
||||||
QString convertToQString(bool i18n = false) const;
|
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.
|
//! Convert this variant to a bool.
|
||||||
bool toBool() const { return m_v.toBool(); }
|
bool toBool() const { return m_v.toBool(); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user