mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 17:30:12 +08:00
Ref T270, added CVariant long long functions and used those in formatter
This commit is contained in:
@@ -406,7 +406,28 @@ namespace BlackGui
|
|||||||
|
|
||||||
CVariant CIntegerFormatter::displayRole(const CVariant &expectedInteger) const
|
CVariant CIntegerFormatter::displayRole(const CVariant &expectedInteger) const
|
||||||
{
|
{
|
||||||
return QString::number(expectedInteger.toInt());
|
bool ok = false;
|
||||||
|
switch (expectedInteger.type())
|
||||||
|
{
|
||||||
|
case QMetaType::LongLong:
|
||||||
|
{
|
||||||
|
const qlonglong ll = expectedInteger.toLongLong(&ok);
|
||||||
|
if (ok) { return QString::number(ll); }
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QMetaType::ULongLong:
|
||||||
|
{
|
||||||
|
const qulonglong ll = expectedInteger.toULongLong(&ok);
|
||||||
|
if (ok) { return QString::number(ll); }
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int i = expectedInteger.toInt(&ok);
|
||||||
|
if (ok) { return QString::number(i); }
|
||||||
|
return CVariant();
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ namespace BlackMisc
|
|||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexUtcTimestamp: this->setUtcTimestamp(variant.toDateTime()); return;
|
case IndexUtcTimestamp: this->setUtcTimestamp(variant.toDateTime()); return;
|
||||||
case IndexMSecsSinceEpoch: this->setMSecsSinceEpoch(variant.toInt()); return;
|
case IndexMSecsSinceEpoch: this->setMSecsSinceEpoch(variant.toQInt64()); return;
|
||||||
case IndexUtcTimestampFormattedYmdhms:
|
case IndexUtcTimestampFormattedYmdhms:
|
||||||
case IndexUtcTimestampFormattedYmdhmsz:
|
case IndexUtcTimestampFormattedYmdhmsz:
|
||||||
case IndexUtcTimestampFormattedHm:
|
case IndexUtcTimestampFormattedHm:
|
||||||
|
|||||||
@@ -69,6 +69,12 @@ namespace BlackMisc
|
|||||||
return isIntegral() || type() == QMetaType::Float || type() == QMetaType::Double;
|
return isIntegral() || type() == QMetaType::Float || type() == QMetaType::Double;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qint64 CVariant::toQInt64(bool *ok) const
|
||||||
|
{
|
||||||
|
if (this->type() == QMetaType::LongLong) { return this->toLongLong(ok); }
|
||||||
|
return this->toInt(ok);
|
||||||
|
}
|
||||||
|
|
||||||
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; }
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ namespace BlackMisc
|
|||||||
static bool baseIsA(const void *, int) { return false; }
|
static bool baseIsA(const void *, int) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// *INDENT-OFF*
|
||||||
/*!
|
/*!
|
||||||
* When a derived class and a base class both inherit from Mixin::MetaType,
|
* When a derived class and a base class both inherit from Mixin::MetaType,
|
||||||
* the derived class uses this macro to disambiguate the inherited members.
|
* the derived class uses this macro to disambiguate the inherited members.
|
||||||
@@ -92,6 +93,7 @@ namespace BlackMisc
|
|||||||
using ::BlackMisc::Mixin::MetaType<DERIVED>::getMetaTypeId; \
|
using ::BlackMisc::Mixin::MetaType<DERIVED>::getMetaTypeId; \
|
||||||
using ::BlackMisc::Mixin::MetaType<DERIVED>::getClassName; \
|
using ::BlackMisc::Mixin::MetaType<DERIVED>::getClassName; \
|
||||||
using ::BlackMisc::Mixin::MetaType<DERIVED>::isA;
|
using ::BlackMisc::Mixin::MetaType<DERIVED>::isA;
|
||||||
|
// *INDENT-ON*
|
||||||
|
|
||||||
} // Mixin
|
} // Mixin
|
||||||
|
|
||||||
@@ -244,14 +246,26 @@ namespace BlackMisc
|
|||||||
bool toBool() const { return m_v.toBool(); }
|
bool toBool() const { return m_v.toBool(); }
|
||||||
|
|
||||||
//! Convert this variant to an integer.
|
//! Convert this variant to an integer.
|
||||||
int toInt() const { return m_v.toInt(); }
|
int toInt(bool *ok = nullptr) const { return m_v.toInt(ok); }
|
||||||
|
|
||||||
|
//! Convert this variant to a longlong integer.
|
||||||
|
qlonglong toLongLong(bool *ok = nullptr) const { return m_v.toLongLong(ok); }
|
||||||
|
|
||||||
|
//! Convert this variant to a unsigned longlong integer.
|
||||||
|
qulonglong toULongLong(bool *ok = nullptr) const { return m_v.toULongLong(ok); }
|
||||||
|
|
||||||
|
//! COnvert to qint64, which is used for all timestamps
|
||||||
|
qint64 toQInt64(bool *ok = nullptr) const;
|
||||||
|
|
||||||
//! Convert this variant to double.
|
//! Convert this variant to double.
|
||||||
double toDouble() const { return m_v.toDouble(); }
|
double toDouble(bool *ok = nullptr) const { return m_v.toDouble(ok); }
|
||||||
|
|
||||||
//! Convert this variant to QDateTime.
|
//! Convert this variant to QDateTime.
|
||||||
QDateTime toDateTime() const { return m_v.toDateTime(); }
|
QDateTime toDateTime() const { return m_v.toDateTime(); }
|
||||||
|
|
||||||
|
//! Convert this variant to QUrl.
|
||||||
|
QUrl toUrl() const { return m_v.toUrl(); }
|
||||||
|
|
||||||
//! Set the variant to null.
|
//! Set the variant to null.
|
||||||
void clear() { m_v.clear(); }
|
void clear() { m_v.clear(); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user