qt: clean up control `getType()`
1. the name suggests that it returns an item's type, yet in fact it returns the item's type class, so essentially it gives up false information, as named. (one exception is the hotkey group control which actually does give up its specific type, yet that is somewhat a lie also because the control does not represent a single config item). 2. any efficiency gain from returning a hard-coded value is dwarfed by the mess and fragility of having a collection of implementations cluttering the files, returning hard coded values. it is much more straight forward to just return the item's actual type value, and either let the caller use `CONFIG_CLASS()` on it where appropriate, (or do it for them with a more suitably named method). 3. this method is only used in one single place, the open-capture-advanced code, so is certainly not worth the mess. this reworks the method to a single implementation on the base class, which just returns an item's raw and actual type. to account for the special hotkey group control which has a null item pointer since it is not linked to a single config item unlike all other controls, it guardedly returns `-1` if the item pointer is null. the one user of this function, (which happens to have no interest in the hotkey control), now gets the raw type, asserts that it did not unexpectedly get `-1` to protect against any future mistake, reduces the type down to type class itself to get the info it actually wants, and proceeds from there as normal.
Showing
- modules/gui/qt/dialogs/open/open_panels.cpp 9 additions, 2 deletionsmodules/gui/qt/dialogs/open/open_panels.cpp
- modules/gui/qt/dialogs/preferences/preferences_widgets.cpp 0 additions, 10 deletionsmodules/gui/qt/dialogs/preferences/preferences_widgets.cpp
- modules/gui/qt/dialogs/preferences/preferences_widgets.hpp 1 addition, 6 deletionsmodules/gui/qt/dialogs/preferences/preferences_widgets.hpp
Loading
Please register or sign in to comment