cxx-qt-lib: standardize constructor method naming conventions #1220
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Per #1203, constructor methods are now named directly after their parameters, and suffixed by
_opt
if they returnOption<Self>
.This PR also adds the
AnyDateFormat
type (an enum of either aDateFormat
or aQString
) in order to deduplicate methods for converting between date/time types andQString
s:Alternatively, we could get rid of
AnyDateFormat
and usedate.to_qstring_qstring
,QDateTime::from_qstring_dateformat_opt
, etc. I think theAnyDateFormat
approach is slightly cleaner, but I'll get rid of it if you prefer.These are all breaking changes. Alternatively, the old functions could be deprecated rather than removed. I didn't see any
#[deprecated]
tags in the codebase, so I defaulted to removing them.Full list of changes (copied from the changelog):
QTime::from_string
andQTime::from_string_enum
now returnOption<QTime>
rather thanQTime
, in keeping with the identical functions forQDate
andQDateTime
.QDate::from_string
andQDate::from_string_enum
→QDate::from_qstring_opt
QDate::format
andQDate::format_enum
→QDate::to_qstring
QDateTime::from_date_and_time_time_zone
→QDateTime::from_qdate_qtime_qtimezone
QDateTime::from_date_and_time_time_spec
→QDateTime::from_qdate_qtime_timespec
QDateTime::from_string
andQDateTime::from_string_enum
→QDateTime::from_qstring_opt
QDateTime::format
andQDateTime::format_enum
→QDateTime::to_qstring
QImage::from_data
→QImage::from_data_opt
QTime::from_string
andQTime::from_string_enum
→QTime::from_qstring_opt
QTime::format
andQTime::format_enum
→QTime::to_qstring