Skip to content

Conversation

josephcrowell
Copy link

…nput instead of 3 spin edits.

TODO: Change display when out of editor to show similar values and mask input to only allow proper values.

…nput instead of 3 spin edits.

TODO: Change display when out of editor to show similar values and mask input to only allow proper values.
gavrant referenced this pull request in gavrant/nifskope Jul 14, 2023
Main goals of the whole model refactoring:
- For NifItem and *Model (BaseModel, NifModel, etc.) methods with a QString parameter provide QLatin1String and 'const char *' overloads. QLatin1String("foo") is much faster than "foo" with its under-the-hood conversion to QString because in Qt 5 QLatin1String("foo") could be done at compile time. And this will make something like reading Skyrim SE shapes several (4 to 8) times faster.
- For *Model methods working with QModelIndex child items provide convenient overloads to work with 'NifItem *' instead. Overall, gradually migrate from using QModelIndex to 'NifItem *', at least on low level, to avoid back-and-forth conversions between QModelIndex and 'NifItem *' and to simplify the code overall.

Bonuses in this commit:
- NifItem: name(), type(), ... getters now return 'const QString &' instead of QString, to avoid wasting resources on creating a QString copy when it's not needed.
- NifItem: new hasName and hasType methods as a replacement for 'name() == "foo"' and 'type() == "foo"' ('const char *' overloads - for performance (see main goal #1), QString and QLatin1String - for uniformity).
- NifItem: new get<T> method as a shortcut for this->itemData.value.get<T>().
- NifItem: static versions of get<T> and getArray<T> methods, with a nullptr check for the item.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant