[Development] Naming convention for (scoped) enums

Shawn Rutledge Shawn.Rutledge at qt.io
Mon Aug 13 20:19:57 CEST 2018


On Aug 13, 2018, at 18:12, Giuseppe D'Angelo via Development <development at qt-project.org> wrote:

> Il 13/08/2018 16:40, Tor Arne Vestbø ha scritto:
>> Or:
>>   if (event->device()->pointerType() != QQuickPointerDevice::Finger
>> Gives me all the info I need, and having to type or read this instead is worse in my opinion:
> 
> This is actually against the old "non-enum class" coding standards: one must repeat the enumeration name in the enumerators. Then, the difference is between something like
> 
> QQuickPointerDevice::FingerPointerType (?)
> 
> and
> 
> QQuickPointerDevice::PointerType::Finger
> 
> So quite minor, all in all…

I would prefer the enum class over prefixing.  But it works fine to do without both, too.

It came up because I tried to add Scroll as a DeviceType, so there was a clash in that patch.  But then I decided the reason I wanted that was not a great one anyway.  So this change is not urgently needed now, it’s just a matter of doing what will make the most sense for the eventual supported API (when we get around to making QQuickPointerHandler and its subclasses public, which is not for 5.12, then users will be able to subclass it and handle events) and for future-proofing (prevent clashes later).

>>   if (event->device()->pointerType() != QQuickPointerDevice::PointerType::Finger &&
>> I think we should revisit this policy, and only use it when there’s actually a clash.
> 
> Which is always "too late" if we're talking about public APIs, as they're set in stone.

For the record, the class is still private for now.




More information about the Development mailing list