mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
Bug fixes and improvements for PropertyIndex discovered during refs #319, mainly contributing to refs #314
* Start index 10 instead 0 for CValueObject (easier to detect bugs) * Fixed wrong indexes * Asserts in CPropertyIndex * Used Icon instead of QPixpmap with indexes, icons are sortable and have a tooltip * Removed redundant toQVariant methods
This commit is contained in:
@@ -29,6 +29,22 @@ namespace BlackMisc
|
|||||||
class CAircraftSituation : public BlackMisc::CValueObject, public BlackMisc::Geo::ICoordinateGeodetic
|
class CAircraftSituation : public BlackMisc::CValueObject, public BlackMisc::Geo::ICoordinateGeodetic
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
//! Properties by index
|
||||||
|
enum ColumnIndex
|
||||||
|
{
|
||||||
|
IndexPosition = BlackMisc::CPropertyIndex::GlobalIndexCAircraftSituation,
|
||||||
|
IndexLatitude,
|
||||||
|
IndexLongitude,
|
||||||
|
IndexAltitude,
|
||||||
|
IndexHeading,
|
||||||
|
IndexBank,
|
||||||
|
IndexPitch,
|
||||||
|
IndexGroundspeed,
|
||||||
|
IndexTimeStamp,
|
||||||
|
IndexTimeStampFormatted
|
||||||
|
};
|
||||||
|
|
||||||
//! Default constructor.
|
//! Default constructor.
|
||||||
CAircraftSituation() : m_timestamp(QDateTime::currentDateTimeUtc()) {}
|
CAircraftSituation() : m_timestamp(QDateTime::currentDateTimeUtc()) {}
|
||||||
|
|
||||||
@@ -41,21 +57,6 @@ namespace BlackMisc
|
|||||||
: m_position(position), m_altitude(altitude), m_heading(heading), m_pitch(pitch),
|
: m_position(position), m_altitude(altitude), m_heading(heading), m_pitch(pitch),
|
||||||
m_bank(bank), m_groundspeed(gs), m_timestamp(QDateTime::currentDateTimeUtc()) {}
|
m_bank(bank), m_groundspeed(gs), m_timestamp(QDateTime::currentDateTimeUtc()) {}
|
||||||
|
|
||||||
//! Properties by index
|
|
||||||
enum ColumnIndex
|
|
||||||
{
|
|
||||||
IndexPosition,
|
|
||||||
IndexLatitude,
|
|
||||||
IndexLongitude,
|
|
||||||
IndexAltitude,
|
|
||||||
IndexHeading,
|
|
||||||
IndexBank,
|
|
||||||
IndexPitch,
|
|
||||||
IndexGroundspeed,
|
|
||||||
IndexTimeStamp,
|
|
||||||
IndexTimeStampFormatted
|
|
||||||
};
|
|
||||||
|
|
||||||
//! \copydoc CValueObject::propertyByIndex(index)
|
//! \copydoc CValueObject::propertyByIndex(index)
|
||||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ namespace BlackMisc
|
|||||||
};
|
};
|
||||||
|
|
||||||
//! Indexes
|
//! Indexes
|
||||||
enum ColumnIndex {
|
enum ColumnIndex
|
||||||
IndexMode,
|
{
|
||||||
|
IndexMode = BlackMisc::CPropertyIndex::GlobalIndexCTransponder,
|
||||||
IndexModeAsString,
|
IndexModeAsString,
|
||||||
IndexTransponderCode,
|
IndexTransponderCode,
|
||||||
IndexTransponderCodeFormatted,
|
IndexTransponderCodeFormatted,
|
||||||
|
|||||||
@@ -45,9 +45,6 @@ namespace BlackMisc
|
|||||||
//! Init by double value
|
//! Init by double value
|
||||||
CLatitude(double value, const BlackMisc::PhysicalQuantities::CAngleUnit &unit) : CEarthAngle(value, unit) {}
|
CLatitude(double value, const BlackMisc::PhysicalQuantities::CAngleUnit &unit) : CEarthAngle(value, unit) {}
|
||||||
|
|
||||||
//! \copydoc CValueObject::toQVariant
|
|
||||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
|
||||||
|
|
||||||
//! Virtual destructor
|
//! Virtual destructor
|
||||||
virtual ~CLatitude() {}
|
virtual ~CLatitude() {}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,9 +42,6 @@ namespace BlackMisc
|
|||||||
//! Init by double value
|
//! Init by double value
|
||||||
CLongitude(double value, const BlackMisc::PhysicalQuantities::CAngleUnit &unit) : CEarthAngle(value, unit) {}
|
CLongitude(double value, const BlackMisc::PhysicalQuantities::CAngleUnit &unit) : CEarthAngle(value, unit) {}
|
||||||
|
|
||||||
//! \copydoc CValueObject::toQVariant
|
|
||||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
|
||||||
|
|
||||||
//! Virtual destructor
|
//! Virtual destructor
|
||||||
virtual ~CLongitude() {}
|
virtual ~CLongitude() {}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -127,17 +127,13 @@ namespace BlackMisc
|
|||||||
return QVariant(this->m_name);
|
return QVariant(this->m_name);
|
||||||
case IndexVariant:
|
case IndexVariant:
|
||||||
return this->m_variant.toQVariant();
|
return this->m_variant.toQVariant();
|
||||||
case IndexCallsignIcon:
|
case IndexIcon:
|
||||||
return this->m_icon.toQVariant();
|
return this->m_icon.toQVariant();
|
||||||
case IndexPixmap:
|
case IndexPixmap:
|
||||||
return this->m_icon.toPixmap();
|
return this->m_icon.toPixmap();
|
||||||
default:
|
default:
|
||||||
break;
|
return CValueObject::propertyByIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_ASSERT_X(false, "CNameVariantPair", "index unknown");
|
|
||||||
QString m = QString("no property, index ").append(index.toQString());
|
|
||||||
return QVariant::fromValue(m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -159,8 +155,8 @@ namespace BlackMisc
|
|||||||
case IndexVariant:
|
case IndexVariant:
|
||||||
this->m_variant = variant;
|
this->m_variant = variant;
|
||||||
break;
|
break;
|
||||||
case IndexCallsignIcon:
|
case IndexIcon:
|
||||||
if (variant.canConvert<int>())
|
if (variant.type() == QMetaType::Int)
|
||||||
{
|
{
|
||||||
CIcons::IconIndex index = static_cast<CIcons::IconIndex>(variant.toInt());
|
CIcons::IconIndex index = static_cast<CIcons::IconIndex>(variant.toInt());
|
||||||
this->m_icon = CIconList::iconForIndex(index);
|
this->m_icon = CIconList::iconForIndex(index);
|
||||||
@@ -171,7 +167,7 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Q_ASSERT_X(false, "CNameVariantPair", "index unknown");
|
CValueObject::setPropertyByIndex(variant, index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,9 +72,9 @@ namespace BlackMisc
|
|||||||
//! Properties by index
|
//! Properties by index
|
||||||
enum ColumnIndex
|
enum ColumnIndex
|
||||||
{
|
{
|
||||||
IndexName = 0,
|
IndexName = BlackMisc::CPropertyIndex::GlobalIndexCNameVariantPair,
|
||||||
IndexVariant,
|
IndexVariant,
|
||||||
IndexCallsignIcon,
|
IndexIcon,
|
||||||
IndexPixmap
|
IndexPixmap
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -197,6 +197,10 @@ namespace BlackMisc
|
|||||||
return this->m_voiceCapabilities.propertyByIndex(index.copyFrontRemoved());
|
return this->m_voiceCapabilities.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexVoiceCapabilitiesPixmap:
|
case IndexVoiceCapabilitiesPixmap:
|
||||||
return QVariant(this->m_voiceCapabilities.toPixmap());
|
return QVariant(this->m_voiceCapabilities.toPixmap());
|
||||||
|
case IndexVoiceCapabilitiesIcon:
|
||||||
|
return QVariant(this->m_voiceCapabilities.toIcon().toQVariant());
|
||||||
|
case IndexVoiceCapabilitiesString:
|
||||||
|
return QVariant(this->m_voiceCapabilities.toQString(true));
|
||||||
default:
|
default:
|
||||||
return CValueObject::propertyByIndex(index);
|
return CValueObject::propertyByIndex(index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,13 +40,14 @@ namespace BlackMisc
|
|||||||
IndexCallsign,
|
IndexCallsign,
|
||||||
IndexVoiceCapabilities,
|
IndexVoiceCapabilities,
|
||||||
IndexVoiceCapabilitiesString,
|
IndexVoiceCapabilitiesString,
|
||||||
IndexVoiceCapabilitiesPixmap
|
IndexVoiceCapabilitiesPixmap,
|
||||||
|
IndexVoiceCapabilitiesIcon
|
||||||
};
|
};
|
||||||
|
|
||||||
//! The Capabilities enum
|
//! The Capabilities enum
|
||||||
enum Capabilities
|
enum Capabilities
|
||||||
{
|
{
|
||||||
FsdWithInterimPositions,
|
FsdWithInterimPositions = BlackMisc::CPropertyIndex::GlobalIndexAbuseMode,
|
||||||
FsdWithModelDescription,
|
FsdWithModelDescription,
|
||||||
FsdAtisCanBeReceived
|
FsdAtisCanBeReceived
|
||||||
};
|
};
|
||||||
@@ -60,7 +61,6 @@ namespace BlackMisc
|
|||||||
//! Constructor.
|
//! Constructor.
|
||||||
CClient(const CUser &user) : m_user(user) {}
|
CClient(const CUser &user) : m_user(user) {}
|
||||||
|
|
||||||
|
|
||||||
//! Equal operator ==
|
//! Equal operator ==
|
||||||
bool operator ==(const CClient &other) const;
|
bool operator ==(const CClient &other) const;
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace BlackMisc
|
|||||||
//! Properties by index
|
//! Properties by index
|
||||||
enum ColumnIndex
|
enum ColumnIndex
|
||||||
{
|
{
|
||||||
IndexName = 0,
|
IndexName = BlackMisc::CPropertyIndex::GlobalIndexCServer,
|
||||||
IndexDescription,
|
IndexDescription,
|
||||||
IndexAddress,
|
IndexAddress,
|
||||||
IndexPort,
|
IndexPort,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
CPropertyIndex::CPropertyIndex(int singleProperty)
|
CPropertyIndex::CPropertyIndex(int singleProperty)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(singleProperty >= static_cast<int>(GlobalIndexCValueObject));
|
||||||
this->m_indexes.append(singleProperty);
|
this->m_indexes.append(singleProperty);
|
||||||
this->listToString();
|
this->listToString();
|
||||||
}
|
}
|
||||||
@@ -152,6 +153,7 @@ namespace BlackMisc
|
|||||||
QString l;
|
QString l;
|
||||||
foreach(int i, this->m_indexes)
|
foreach(int i, this->m_indexes)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(i >= static_cast<int>(GlobalIndexCValueObject));
|
||||||
if (!l.isEmpty()) { l.append(";"); }
|
if (!l.isEmpty()) { l.append(";"); }
|
||||||
l.append(QString::number(i));
|
l.append(QString::number(i));
|
||||||
}
|
}
|
||||||
@@ -172,6 +174,7 @@ namespace BlackMisc
|
|||||||
bool ok;
|
bool ok;
|
||||||
int i = index.toInt(&ok);
|
int i = index.toInt(&ok);
|
||||||
Q_ASSERT(ok);
|
Q_ASSERT(ok);
|
||||||
|
Q_ASSERT(i >= static_cast<int>(GlobalIndexCValueObject));
|
||||||
this->m_indexes.append(i);
|
this->m_indexes.append(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,23 +33,29 @@ namespace BlackMisc
|
|||||||
//! Global index, make sure the indexes are unqiue (for using them in class hierarchy)
|
//! Global index, make sure the indexes are unqiue (for using them in class hierarchy)
|
||||||
enum GlobalIndex
|
enum GlobalIndex
|
||||||
{
|
{
|
||||||
GlobalIndexCValueObject = 0,
|
GlobalIndexCValueObject = 10, // GlobalIndexCValueObject needs to be set manually in CValueObject
|
||||||
GlobalIndexCPhysicalQuantity = 100,
|
GlobalIndexCPhysicalQuantity = 100,
|
||||||
GlobalIndexCStatusMessage = 200,
|
GlobalIndexCStatusMessage = 200,
|
||||||
|
GlobalIndexCNameVariantPair = 300,
|
||||||
GlobalIndexCCallsign = 1000,
|
GlobalIndexCCallsign = 1000,
|
||||||
GlobalIndexCAircraftIcao = 1100,
|
GlobalIndexCAircraftIcao = 1100,
|
||||||
GlobalIndexCAircraft = 1200,
|
GlobalIndexCAircraft = 1200,
|
||||||
GlobalIndexCAtcStation = 1300,
|
GlobalIndexCAircraftSituation = 1300,
|
||||||
GlobalIndexCAirport = 1400,
|
GlobalIndexCAtcStation = 1400,
|
||||||
|
GlobalIndexCAirport = 1500,
|
||||||
GlobalIndexCModulator = 2000,
|
GlobalIndexCModulator = 2000,
|
||||||
|
GlobalIndexCTransponder = 2100,
|
||||||
GlobalIndexICoordinateGeodetic = 3000,
|
GlobalIndexICoordinateGeodetic = 3000,
|
||||||
GlobalIndexCCoordinateGeodetic = 3100,
|
GlobalIndexCCoordinateGeodetic = 3100,
|
||||||
GlobalIndexCClient = 4000,
|
GlobalIndexCClient = 4000,
|
||||||
GlobalIndexCUser = 4100,
|
GlobalIndexCUser = 4100,
|
||||||
GlobalIndexCAircraftModel = 4200,
|
GlobalIndexCServer = 4200,
|
||||||
|
GlobalIndexCAircraftModel = 4300,
|
||||||
GlobalIndexCVoiceRoom = 5000,
|
GlobalIndexCVoiceRoom = 5000,
|
||||||
GlobalIndexCAircraftMapping = 6000,
|
GlobalIndexCSettingKeyboardHotkey = 6000,
|
||||||
GlobalIndexCAircraftCfgEntries = 6100
|
GlobalIndexCAircraftMapping = 7000,
|
||||||
|
GlobalIndexCAircraftCfgEntries = 7100,
|
||||||
|
GlobalIndexAbuseMode = 20000 // property index abused as map key or otherwise
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Default constructor.
|
//! Default constructor.
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace BlackMisc
|
|||||||
//! Properties by index
|
//! Properties by index
|
||||||
enum ColumnIndex
|
enum ColumnIndex
|
||||||
{
|
{
|
||||||
IndexKey = 0,
|
IndexKey = BlackMisc::CPropertyIndex::GlobalIndexCSettingKeyboardHotkey,
|
||||||
IndexKeyAsString,
|
IndexKeyAsString,
|
||||||
IndexKeyAsStringRepresentation,
|
IndexKeyAsStringRepresentation,
|
||||||
IndexModifier1,
|
IndexModifier1,
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ namespace BlackMisc
|
|||||||
//! Base class enums
|
//! Base class enums
|
||||||
enum ColumnIndex
|
enum ColumnIndex
|
||||||
{
|
{
|
||||||
IndexPixmap,
|
IndexPixmap = 10, // manually set to avoid circular dependencies
|
||||||
IndexIcon,
|
IndexIcon,
|
||||||
IndexString
|
IndexString
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace BlackSim
|
|||||||
//! Properties by index
|
//! Properties by index
|
||||||
enum ColumnIndex
|
enum ColumnIndex
|
||||||
{
|
{
|
||||||
IndexEntryIndex = BlackMisc::CPropertyIndex::GlobalIndexCAircraftModel,
|
IndexEntryIndex = BlackMisc::CPropertyIndex::GlobalIndexCAircraftCfgEntries,
|
||||||
IndexFilePath,
|
IndexFilePath,
|
||||||
IndexTitle,
|
IndexTitle,
|
||||||
IndexAtcType,
|
IndexAtcType,
|
||||||
|
|||||||
Reference in New Issue
Block a user