mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
Formatting, minor tweaks
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -191,22 +192,22 @@ namespace BlackGui
|
||||
if (dateTime.isNull()) return "";
|
||||
if (static_cast<QMetaType::Type>(dateTime.type()) == QMetaType::QDateTime)
|
||||
{
|
||||
QDateTime dt = dateTime.value<QDateTime>();
|
||||
const QDateTime dt = dateTime.value<QDateTime>();
|
||||
return dt.toString(m_formatString);
|
||||
}
|
||||
else if (static_cast<QMetaType::Type>(dateTime.type()) == QMetaType::QDate)
|
||||
{
|
||||
QDate d = dateTime.value<QDate>();
|
||||
const QDate d = dateTime.value<QDate>();
|
||||
return d.toString(m_formatString);
|
||||
}
|
||||
else if (static_cast<QMetaType::Type>(dateTime.type()) == QMetaType::QTime)
|
||||
{
|
||||
QTime t = dateTime.value<QTime>();
|
||||
const QTime t = dateTime.value<QTime>();
|
||||
return t.toString(m_formatString);
|
||||
}
|
||||
else if (dateTime.isIntegral())
|
||||
{
|
||||
QDateTime t = QDateTime::fromMSecsSinceEpoch(dateTime.value<qint64>());
|
||||
const QDateTime t = QDateTime::fromMSecsSinceEpoch(dateTime.value<qint64>());
|
||||
return t.toString(m_formatString);
|
||||
}
|
||||
else
|
||||
@@ -218,33 +219,27 @@ namespace BlackGui
|
||||
|
||||
CVariant CAirspaceDistanceFormatter::displayRole(const CVariant &dataCVariant) const
|
||||
{
|
||||
if (dataCVariant.canConvert<BlackMisc::PhysicalQuantities::CLength>())
|
||||
if (dataCVariant.canConvert<CLength>())
|
||||
{
|
||||
// special treatment for some cases
|
||||
BlackMisc::PhysicalQuantities::CLength l = dataCVariant.value<BlackMisc::PhysicalQuantities::CLength>();
|
||||
if (!l.isNull() && (l.isPositiveWithEpsilonConsidered() || l.isZeroEpsilonConsidered()))
|
||||
{
|
||||
return CPhysiqalQuantiyFormatter::displayRole(dataCVariant);
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
const CLength l = dataCVariant.value<CLength>();
|
||||
const bool valid = !l.isNull() && (l.isPositiveWithEpsilonConsidered() || l.isZeroEpsilonConsidered());
|
||||
return valid ? CPhysiqalQuantiyFormatter::displayRole(dataCVariant) : QStringLiteral("");
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_ASSERT_X(false, "CAirspaceDistanceFormatter::formatQVariant", "No CLength class");
|
||||
return "";
|
||||
return QStringLiteral("");
|
||||
}
|
||||
}
|
||||
|
||||
CVariant CComFrequencyFormatter::displayRole(const CVariant &dataCVariant) const
|
||||
{
|
||||
if (dataCVariant.canConvert<BlackMisc::PhysicalQuantities::CFrequency>())
|
||||
if (dataCVariant.canConvert<CFrequency>())
|
||||
{
|
||||
// speical treatment for some cases
|
||||
BlackMisc::PhysicalQuantities::CFrequency f = dataCVariant.value<BlackMisc::PhysicalQuantities::CFrequency>();
|
||||
if (BlackMisc::Aviation::CComSystem::isValidComFrequency(f))
|
||||
const CFrequency f = dataCVariant.value<CFrequency>();
|
||||
if (CComSystem::isValidComFrequency(f))
|
||||
{
|
||||
return CPhysiqalQuantiyFormatter::displayRole(dataCVariant);
|
||||
}
|
||||
@@ -263,7 +258,7 @@ namespace BlackGui
|
||||
CVariant CSpeedKtsFormatter::displayRole(const CVariant &dataCVariant) const
|
||||
{
|
||||
// special treatment for some cases
|
||||
BlackMisc::PhysicalQuantities::CSpeed s = dataCVariant.value<BlackMisc::PhysicalQuantities::CSpeed>();
|
||||
const CSpeed s = dataCVariant.value<CSpeed>();
|
||||
if (!s.isNull() && (s.isPositiveWithEpsilonConsidered() || s.isZeroEpsilonConsidered()))
|
||||
{
|
||||
return CPhysiqalQuantiyFormatter::displayRole(dataCVariant);
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace BlackGui
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
BlackMisc::CPropertyIndex CListModelBaseNonTemplate::columnToPropertyIndex(int column) const
|
||||
CPropertyIndex CListModelBaseNonTemplate::columnToPropertyIndex(int column) const
|
||||
{
|
||||
return m_columns.columnToPropertyIndex(column);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ namespace BlackGui
|
||||
return m_columns.propertyIndexToColumn(propertyIndex);
|
||||
}
|
||||
|
||||
BlackMisc::CPropertyIndex CListModelBaseNonTemplate::modelIndexToPropertyIndex(const QModelIndex &index) const
|
||||
CPropertyIndex CListModelBaseNonTemplate::modelIndexToPropertyIndex(const QModelIndex &index) const
|
||||
{
|
||||
return this->columnToPropertyIndex(index.column());
|
||||
}
|
||||
@@ -104,7 +104,7 @@ namespace BlackGui
|
||||
this->sort(column, order);
|
||||
}
|
||||
|
||||
void CListModelBaseNonTemplate::setSortColumnByPropertyIndex(const BlackMisc::CPropertyIndex &propertyIndex)
|
||||
void CListModelBaseNonTemplate::setSortColumnByPropertyIndex(const CPropertyIndex &propertyIndex)
|
||||
{
|
||||
m_sortColumn = m_columns.propertyIndexToColumn(propertyIndex);
|
||||
}
|
||||
@@ -278,7 +278,7 @@ namespace BlackGui
|
||||
// index, updront checking
|
||||
const int row = index.row();
|
||||
const int col = index.column();
|
||||
const BlackMisc::CPropertyIndex propertyIndex = this->columnToPropertyIndex(col);
|
||||
const CPropertyIndex propertyIndex = this->columnToPropertyIndex(col);
|
||||
if (static_cast<int>(CPropertyIndex::GlobalIndexLineNumber) == propertyIndex.frontCasted<int>())
|
||||
{
|
||||
return QVariant::fromValue(row + 1);
|
||||
@@ -304,7 +304,7 @@ namespace BlackGui
|
||||
|
||||
ObjectType obj = m_container[index.row()];
|
||||
ObjectType currentObject(obj);
|
||||
BlackMisc::CPropertyIndex propertyIndex = this->columnToPropertyIndex(index.column());
|
||||
CPropertyIndex propertyIndex = this->columnToPropertyIndex(index.column());
|
||||
obj.setPropertyByIndex(propertyIndex, value);
|
||||
|
||||
if (obj != currentObject)
|
||||
@@ -393,7 +393,7 @@ namespace BlackGui
|
||||
if (m_modelDestroyed) { return nullptr; }
|
||||
auto sortColumn = this->getSortColumn();
|
||||
auto sortOrder = this->getSortOrder();
|
||||
CWorker *worker = BlackMisc::CWorker::fromTask(this, "ModelSort", [this, container, sortColumn, sortOrder]()
|
||||
CWorker *worker = CWorker::fromTask(this, "ModelSort", [this, container, sortColumn, sortOrder]()
|
||||
{
|
||||
return this->sortContainerByColumn(container, sortColumn, sortOrder);
|
||||
});
|
||||
@@ -675,7 +675,7 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
// this is the only part not really thread safe, but columns do not change so far
|
||||
BlackMisc::CPropertyIndex propertyIndex = m_columns.columnToSortPropertyIndex(column);
|
||||
const CPropertyIndex propertyIndex = m_columns.columnToSortPropertyIndex(column);
|
||||
Q_ASSERT(!propertyIndex.isEmpty());
|
||||
if (propertyIndex.isEmpty())
|
||||
{
|
||||
|
||||
@@ -323,7 +323,7 @@ namespace BlackGui
|
||||
template<class ObjectType>
|
||||
bool compareForModelSort(const ObjectType &a, const ObjectType &b, Qt::SortOrder order, const BlackMisc::CPropertyIndex &index, std::true_type)
|
||||
{
|
||||
int c = a.comparePropertyByIndex(index, b);
|
||||
const int c = a.comparePropertyByIndex(index, b);
|
||||
if (c == 0) { return false; }
|
||||
return (order == Qt::AscendingOrder) ? (c < 0) : (c > 0);
|
||||
}
|
||||
|
||||
@@ -37,20 +37,20 @@ namespace BlackGui
|
||||
|
||||
void CStatusMessageListModel::setMode(CStatusMessageListModel::Mode mode)
|
||||
{
|
||||
this->m_columns.clear();
|
||||
m_columns.clear();
|
||||
switch (mode)
|
||||
{
|
||||
case Detailed:
|
||||
{
|
||||
this->m_columns.addColumn(CColumn("time", CStatusMessage::IndexUtcTimestamp, new CDateTimeFormatter(CDateTimeFormatter::formatHms())));
|
||||
m_columns.addColumn(CColumn("time", CStatusMessage::IndexUtcTimestamp, new CDateTimeFormatter(CDateTimeFormatter::formatHmsz())));
|
||||
CColumn col = CColumn("severity", CStatusMessage::IndexIcon);
|
||||
col.setSortPropertyIndex(CStatusMessage::IndexSeverityAsString);
|
||||
this->m_columns.addColumn(col);
|
||||
this->m_columns.addColumn(CColumn::standardString("message", CStatusMessage::IndexMessage));
|
||||
this->m_columns.addColumn(CColumn::standardString("category", CStatusMessage::IndexCategoryHumanReadableOrTechnicalAsString));
|
||||
m_columns.addColumn(col);
|
||||
m_columns.addColumn(CColumn::standardString("message", CStatusMessage::IndexMessage));
|
||||
m_columns.addColumn(CColumn::standardString("category", CStatusMessage::IndexCategoryHumanReadableOrTechnicalAsString));
|
||||
|
||||
this->m_sortColumn = CStatusMessage::IndexUtcTimestamp;
|
||||
this->m_sortOrder = Qt::DescendingOrder;
|
||||
m_sortColumn = CStatusMessage::IndexUtcTimestamp;
|
||||
m_sortOrder = Qt::DescendingOrder;
|
||||
}
|
||||
break;
|
||||
case Simplified:
|
||||
@@ -58,11 +58,11 @@ namespace BlackGui
|
||||
this->m_columns.addColumn(CColumn("time", CStatusMessage::IndexUtcTimestamp, new CDateTimeFormatter(CDateTimeFormatter::formatHms())));
|
||||
CColumn col = CColumn("severity", CStatusMessage::IndexIcon);
|
||||
col.setSortPropertyIndex(CStatusMessage::IndexSeverityAsString);
|
||||
this->m_columns.addColumn(col);
|
||||
this->m_columns.addColumn(CColumn::standardString("message", CStatusMessage::IndexMessage));
|
||||
m_columns.addColumn(col);
|
||||
m_columns.addColumn(CColumn::standardString("message", CStatusMessage::IndexMessage));
|
||||
|
||||
this->m_sortColumn = CStatusMessage::IndexUtcTimestamp;
|
||||
this->m_sortOrder = Qt::DescendingOrder;
|
||||
m_sortColumn = CStatusMessage::IndexUtcTimestamp;
|
||||
m_sortOrder = Qt::DescendingOrder;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user