File indexing completed on 2024-04-28 03:58:58

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2008 Chusslove Illich <caslav.ilic@gmx.net>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef COMMON_HELPERS_P_H
0009 #define COMMON_HELPERS_P_H
0010 
0011 #include <QLocale>
0012 #include <QString>
0013 
0014 // Standalone (pure Qt) functionality needed internally in more than
0015 // one source file on localization.
0016 
0017 /**
0018  * @internal
0019  *
0020  * Removes accelerator marker from a UI text label.
0021  *
0022  * Accelerator marker is not always a plain ampersand (&),
0023  * so it is not enough to just remove it by @c QString::remove().
0024  * The label may contain escaped markers ("&&") which must be resolved
0025  * and skipped, as well as CJK-style markers ("Foo (&F)") where
0026  * the whole parenthesis construct should be removed.
0027  * Therefore always use this function to remove accelerator marker
0028  * from UI labels.
0029  *
0030  * @param label UI label which may contain an accelerator marker
0031  * @return label without the accelerator marker
0032  */
0033 QString removeAcceleratorMarker(const QString &label);
0034 
0035 /**
0036  * @internal
0037  *
0038  * Returns the date format used for the locale with the year as a four digit
0039  * number.
0040  *
0041  * If the date format used for the locale already has a 4-digit year, then
0042  * this is the same as locale.dateFormat(format). Otherwise, it's the result
0043  * of QLocale::dateFormat with "yy" replaced with "yyyy".
0044  * In particular when using the short format for date inputs you may want to
0045  * use the short format with 4-digit year because Qt parses current 2-digit year
0046  * values like 22 as 1922.
0047  *
0048  * @param locale The locale that you want the date format for.
0049  * @param format The date format that you want.
0050  * @return the date format string with 4-digit year
0051  */
0052 QString dateFormatWith4DigitYear(const QLocale &locale, QLocale::FormatType format);
0053 
0054 #endif