diff --git a/src/blackmisc/propertyindex.cpp b/src/blackmisc/propertyindex.cpp index 009994ff8..fe8cd1042 100644 --- a/src/blackmisc/propertyindex.cpp +++ b/src/blackmisc/propertyindex.cpp @@ -144,4 +144,9 @@ namespace BlackMisc return f; } + bool CPropertyIndex::startsWith(int index) const + { + if (this->isEmpty()) { return false; } + return this->frontToInt() == index; + } } // namespace diff --git a/src/blackmisc/propertyindex.h b/src/blackmisc/propertyindex.h index 4114cb192..ab952f5a9 100644 --- a/src/blackmisc/propertyindex.h +++ b/src/blackmisc/propertyindex.h @@ -93,8 +93,9 @@ namespace BlackMisc GlobalIndexCAircraftParts = 1400, GlobalIndexCAircraftLights = 1500, GlobalIndexCLivery = 1600, - GlobalIndexCModulator = 2000, - GlobalIndexCTransponder = 2100, + GlobalIndexCComSystem = 2000, + GlobalIndexCModulator = 2100, + GlobalIndexCTransponder = 2200, GlobalIndexCAircraftIcaoData = 2500, GlobalIndexCAircraftIcaoCode = 2600, GlobalIndexCAirlineIcaoCode = 2700, @@ -202,6 +203,9 @@ namespace BlackMisc //! Front to integer int frontToInt() const; + //! Starts with given index? + bool startsWith(int index) const; + //! First element casted to given type, usually the PropertIndex enum template CastType frontCasted() const { @@ -210,12 +214,10 @@ namespace BlackMisc } //! Compare with index given by enum - template bool equalsPropertyIndexEnum(EnumType ev) + template bool startsWithPropertyIndexEnum(EnumType ev) const { static_assert(std::is_enum::value, "Argument must be an enum"); - QList l = indexList(); - if (l.size() != 1) { return false; } - return static_cast(ev) == l.first(); + return this->startsWith(static_cast(ev)); } //! Return a predicate function which can compare two objects based on this index