remove unused QLocale list patterns related method

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-06-11 08:44:13 +03:00
parent 68fdef86f0
commit 89cc3cdbc6
6 changed files with 21 additions and 673 deletions

View file

@ -103,12 +103,6 @@ def todayenum(day):
print('Unknown day: %s' % day)
sys.exit(1)
def tolistformat(fromformat):
result = fromformat.replace('{0}', '%1')
result = result.replace('{1}', '%2')
result = result.replace('{2}', '%3')
return result
def todatetimeformat(fromformat):
# valid are y, m, M, d, h, H, s, a, A, z and t
unsupportedtags = [
@ -353,7 +347,6 @@ def printlocaledata(frommap, key):
%s, %s, %s, %s, %s, %s, %s, %s,
%s, %s,
%s, %s, %s, %s,
%s, %s, %s, %s,
%s, %s,
%s,
%s,
@ -384,10 +377,6 @@ def printlocaledata(frommap, key):
touint(value['zero']),
tochar(value['language_endonym']),
tochar(value['country_endonym']),
tochar(value['list_pattern_part_start']),
tochar(value['list_pattern_part_mid']),
tochar(value['list_pattern_part_end']),
tochar(value['list_pattern_part_two']),
tochar(value['short_date_format']),
tochar(value['long_date_format']),
tochar(value['short_time_format']),
@ -608,10 +597,6 @@ localedefaults = {
# strings
'language_endonym': '',
'country_endonym': '',
'list_pattern_part_start': "%1, %2",
'list_pattern_part_mid': "%1, %2",
'list_pattern_part_end': "%1, %2",
'list_pattern_part_two': "%1, %2",
'short_date_format': 'd MMM yyyy', # default in CLDR is y-MM-dd
'long_date_format': 'd MMMM yyyy',
'short_time_format': 'HH:mm:ss', # default in CLDR is HH:mm
@ -784,19 +769,6 @@ def readlocale(fromxml, tomap, isparent):
tomap[locale]['country_endonym'] = nativecountry.text
break
listpattern = root.find('./listPatterns/listPattern')
if listpattern is not None:
for listpatternpart in listpattern.findall('./listPatternPart'):
listpatternparttype = listpatternpart.get('type')
if listpatternparttype == 'start':
tomap[locale]['list_pattern_part_start'] = tolistformat(listpatternpart.text)
elif listpatternparttype == 'middle':
tomap[locale]['list_pattern_part_mid'] = tolistformat(listpatternpart.text)
elif listpatternparttype == 'end':
tomap[locale]['list_pattern_part_end'] = tolistformat(listpatternpart.text)
elif listpatternparttype == '2':
tomap[locale]['list_pattern_part_two'] = tolistformat(listpatternpart.text)
for calendar in root.findall('./dates/calendars/calendar'):
calendartype = calendar.get('type')
if not calendartype == 'gregorian':

View file

@ -514,34 +514,6 @@ QLocale::NumberOptions QLocale::numberOptions() const
return p.numberOptions;
}
/*!
\since 4.8
Returns a string that represents a join of a given \a list of strings with
a separator defined by the locale.
*/
QString QLocale::createSeparatedList(const QStringList &list) const
{
const int size = list.size();
if (size == 1) {
return list.at(0);
} else if (size == 2) {
QString format = getLocaleData(d()->m_list_pattern_part_two);
return format.arg(list.at(0), list.at(1));
} else if (size > 2) {
QString formatStart = getLocaleData(d()->m_list_pattern_part_start);
QString formatMid = getLocaleData(d()->m_list_pattern_part_mid);
QString formatEnd = getLocaleData(d()->m_list_pattern_part_end);
QString result = formatStart.arg(list.at(0), list.at(1));
for (int i = 2; i < size - 1; ++i)
result = formatMid.arg(result, list.at(i));
result = formatEnd.arg(result, list.at(size - 1));
return result;
}
return QString();
}
/*!
\nonreentrant

View file

@ -1376,7 +1376,6 @@ public:
void setNumberOptions(NumberOptions options);
NumberOptions numberOptions() const;
QString createSeparatedList(const QStringList &strl) const;
private:
friend class QLocalePrivate;
// ### We now use this field to pack an index into locale_data and NumberOptions.

File diff suppressed because it is too large Load diff

View file

@ -160,10 +160,6 @@ public:
const uint m_zero;
const char* m_language_endonym;
const char* m_country_endonym;
const char* m_list_pattern_part_start;
const char* m_list_pattern_part_mid;
const char* m_list_pattern_part_end;
const char* m_list_pattern_part_two;
const char* m_short_date_format;
const char* m_long_date_format;
const char* m_short_time_format;

View file

@ -103,7 +103,6 @@ private slots:
void ampm();
void uiLanguages();
void weekendDays();
void listPatterns();
private:
QString m_decimal, m_thousand, m_sdate, m_ldate, m_time;
@ -1603,40 +1602,6 @@ void tst_QLocale::weekendDays()
QCOMPARE(c.weekdays(), days);
}
void tst_QLocale::listPatterns()
{
QStringList sl1;
QStringList sl2;
sl2 << "aaa";
QStringList sl3;
sl3 << "aaa" << "bbb";
QStringList sl4;
sl4 << "aaa" << "bbb" << "ccc";
QStringList sl5;
sl5 << "aaa" << "bbb" << "ccc" << "ddd";
const QLocale c(QLocale::C);
QCOMPARE(c.createSeparatedList(sl1), QString(""));
QCOMPARE(c.createSeparatedList(sl2), QString("aaa"));
QCOMPARE(c.createSeparatedList(sl3), QString("aaa, bbb"));
QCOMPARE(c.createSeparatedList(sl4), QString("aaa, bbb, ccc"));
QCOMPARE(c.createSeparatedList(sl5), QString("aaa, bbb, ccc, ddd"));
const QLocale en_US("en_US");
QCOMPARE(en_US.createSeparatedList(sl1), QString(""));
QCOMPARE(en_US.createSeparatedList(sl2), QString("aaa"));
QCOMPARE(en_US.createSeparatedList(sl3), QString("aaa and bbb"));
QCOMPARE(en_US.createSeparatedList(sl4), QString("aaa, bbb, and ccc"));
QCOMPARE(en_US.createSeparatedList(sl5), QString("aaa, bbb, ccc, and ddd"));
const QLocale zh_CN("zh_CN");
QCOMPARE(zh_CN.createSeparatedList(sl1), QString(""));
QCOMPARE(zh_CN.createSeparatedList(sl2), QString("aaa"));
QCOMPARE(zh_CN.createSeparatedList(sl3), QString::fromUtf8("aaa" "\xe5\x92\x8c" "bbb"));
QCOMPARE(zh_CN.createSeparatedList(sl4), QString::fromUtf8("aaa" "\xe3\x80\x81" "bbb" "\xe5\x92\x8c" "ccc"));
QCOMPARE(zh_CN.createSeparatedList(sl5), QString::fromUtf8("aaa" "\xe3\x80\x81" "bbb" "\xe3\x80\x81" "ccc" "\xe5\x92\x8c" "ddd"));
}
QTEST_MAIN(tst_QLocale)
#include "moc_tst_qlocale.cpp"