1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2008 Chusslove Illich <caslav.ilic@gmx.net> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #ifndef COMMON_HELPERS_P_H |
9 | #define COMMON_HELPERS_P_H |
10 | |
11 | #include <QLocale> |
12 | #include <QString> |
13 | |
14 | // Standalone (pure Qt) functionality needed internally in more than |
15 | // one source file on localization. |
16 | |
17 | /*! |
18 | * \internal |
19 | * |
20 | * Removes accelerator marker from a UI text label. |
21 | * |
22 | * Accelerator marker is not always a plain ampersand (&), |
23 | * so it is not enough to just remove it by QString::remove(). |
24 | * The label may contain escaped markers ("&&") which must be resolved |
25 | * and skipped, as well as CJK-style markers ("Foo (&F)") where |
26 | * the whole parenthesis construct should be removed. |
27 | * Therefore always use this function to remove accelerator marker |
28 | * from UI labels. |
29 | * |
30 | * \a label UI label which may contain an accelerator marker |
31 | * |
32 | * Returns label without the accelerator marker |
33 | */ |
34 | QString removeAcceleratorMarker(const QString &label); |
35 | |
36 | /*! |
37 | * \internal |
38 | * |
39 | * Returns the date format used for the locale with the year as a four digit |
40 | * number. |
41 | * |
42 | * If the date format used for the locale already has a 4-digit year, then |
43 | * this is the same as locale.dateFormat(format). Otherwise, it's the result |
44 | * of QLocale::dateFormat with "yy" replaced with "yyyy". |
45 | * In particular when using the short format for date inputs you may want to |
46 | * use the short format with 4-digit year because Qt parses current 2-digit year |
47 | * values like 22 as 1922. |
48 | * |
49 | * \a locale The locale that you want the date format for. |
50 | * |
51 | * \a format The date format that you want. |
52 | * |
53 | * Returns the date format string with 4-digit year |
54 | */ |
55 | QString dateFormatWith4DigitYear(const QLocale &locale, QLocale::FormatType format); |
56 | |
57 | #endif |
58 | |