summaryrefslogtreecommitdiffstats
path: root/src/corelib/time
diff options
context:
space:
mode:
authorIevgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>2021-07-22 14:28:30 +0200
committerIevgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>2021-07-27 14:58:41 +0200
commit25170b324b7db872be2a2bde5c04eb0c1e3972e5 (patch)
tree496c80ebcc36382a494f33f85fe3273bc087fdf3 /src/corelib/time
parent7d49dc2222ddfd442face88c2243e28f5d26165f (diff)
QCalendarBackend: Use QAnyStringView to create backends by name
Combine two implementations of QCalendarBackend::byName() accepting QStringView and QLatin1String arguments into one accepting QAnyStringView to reduce code duplication. Add a note to QCalendar constructors accepting strings to do the same for Qt 7. Change-Id: Idfc3b9c61e22712543c723bd94fcd788da52780a Pick-to: 6.2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/time')
-rw-r--r--src/corelib/time/qcalendar.cpp16
-rw-r--r--src/corelib/time/qcalendar.h2
-rw-r--r--src/corelib/time/qcalendarbackend_p.h4
3 files changed, 5 insertions, 17 deletions
diff --git a/src/corelib/time/qcalendar.cpp b/src/corelib/time/qcalendar.cpp
index 4a245f6d3f..d3dada33b3 100644
--- a/src/corelib/time/qcalendar.cpp
+++ b/src/corelib/time/qcalendar.cpp
@@ -890,7 +890,7 @@ bool QCalendarBackend::registerAlias(const QString &name)
\sa availableCalendars(), registerAlias(), fromEnum(), fromId()
*/
-const QCalendarBackend *QCalendarBackend::fromName(QStringView name)
+const QCalendarBackend *QCalendarBackend::fromName(QAnyStringView name)
{
if (calendarRegistry.isDestroyed())
return nullptr;
@@ -902,20 +902,6 @@ const QCalendarBackend *QCalendarBackend::fromName(QStringView name)
/*!
\internal
- \overload
- */
-const QCalendarBackend *QCalendarBackend::fromName(QLatin1String name)
-{
- if (calendarRegistry.isDestroyed())
- return nullptr;
- calendarRegistry->populate();
- const auto registryLock = qt_scoped_lock(registryMutex);
- auto it = calendarRegistry->byName.find(QString(name));
- return it == calendarRegistry->byName.end() ? nullptr : *it;
-}
-
-/*!
- \internal
Returns a pointer to a calendar backend, specified by ID.
If a calendar with ID \a id is known to the calendar registry, the backend
diff --git a/src/corelib/time/qcalendar.h b/src/corelib/time/qcalendar.h
index c3d8800db8..a723209a1c 100644
--- a/src/corelib/time/qcalendar.h
+++ b/src/corelib/time/qcalendar.h
@@ -145,7 +145,9 @@ public:
explicit QCalendar(); // Gregorian, optimised
explicit QCalendar(System system);
+ // ### Qt 7: remove
explicit QCalendar(QLatin1String name);
+ // ### Qt 7: use QAnyStringView
explicit QCalendar(QStringView name);
explicit QCalendar(SystemId id);
diff --git a/src/corelib/time/qcalendarbackend_p.h b/src/corelib/time/qcalendarbackend_p.h
index c3f57e7f74..83893571fc 100644
--- a/src/corelib/time/qcalendarbackend_p.h
+++ b/src/corelib/time/qcalendarbackend_p.h
@@ -56,6 +56,7 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qstring.h>
#include <QtCore/qmap.h>
+#include <QtCore/qanystringview.h>
#include <QtCore/private/qlocale_p.h>
QT_BEGIN_NAMESPACE
@@ -145,8 +146,7 @@ protected:
private:
const QCalendar::SystemId m_id;
// QCalendar's access to its registry:
- static const QCalendarBackend *fromName(QStringView name);
- static const QCalendarBackend *fromName(QLatin1String name);
+ static const QCalendarBackend *fromName(QAnyStringView name);
static const QCalendarBackend *fromId(QCalendar::SystemId id);
// QCalendar's access to singletons:
static const QCalendarBackend *fromEnum(QCalendar::System system);