[KPhotoAlbum] Fwd: [Qt bugreports] Updates for QTBUG-75585: Massive performance regression in QML Date object

Joe josephj at main.nc.us
Tue Sep 22 21:04:16 BST 2020


On 9/22/20 2:42 PM, Tobias Leupold wrote:
> Playing around a bit, we'll get UTC almost for free :-)
>
> When reading the database, we can simply do QDateTime::toUTC() for all dates.
> That will, in our case, assume the time to be in local timezone and return the
> corresponding UTC representation.
>
> Getting the timezone to put inside the database is a bit more tricky. We can
> get the offset via:
>
>     const int offsetFromUtc = QDateTime::currentDateTime().offsetFromUtc();
>     const int hours = offsetFromUtc / 3600;
>     const int minutes = (offsetFromUtc - hours * 3600) / 60;
>     QString localTimezone = hours > 0 ? QStringLiteral("UTC+%1:%2")
>                                       : QStringLiteral("UTC-%1:%2");
>     localTimezone = localTimezone.arg(hours, 2, 10, QLatin1Char('0'));
>     localTimezone = localTimezone.arg(minutes, 2, 10, QLatin1Char('0'));
>
> But that also won't be unambiguous, as DST stuff is a political decision (man,
> I really hope they finally abandon that time shifting in the EU, and they'll
> stick to the normal "winter" time ... ;-) and may change for a defined period
> of time.
>
> So I think we should use a named timezone. We can get the local one via
>
>     QTimeZone::systemTimeZone().id()
>
> So I think the right approach would be (indside an update function):
>  - Get QTimeZone::systemTimeZone().id() once
>  - Get QDateTime::toUTC() for each image and put it in the database
>  - Also put the local timezone in each image's data
>
> Or we set a default timezone for the database and only put one into an image's
> data if it's not the default one. This may cover most (if not all) images and
> reduce overhead.

What if the user moves and wants a new default time zone either
temporarily or permanently?

Joe

> Of course, we'll need a possibility to adjust the image timezone for each
> image. That won't be too hard, we can simply build a list of all available
> ones via QTimeZone::availableTimeZoneIds() and let the user choose from that
> for one image or a selection of images.
>
> When showing the image, display the time as before if the image's timezone
> matches the system's (or the database default one). If not, display it in the
> image's timezone with a hint that the timezone shown deviates from the
> standard.
>
> What do you think?
>
> _______________________________________________
> KPhotoAlbum mailing list
> KPhotoAlbum at mail.kdab.com
> https://mail.kdab.com/mailman/listinfo/kphotoalbum



More information about the Kphotoalbum mailing list