aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandro Knauß <[email protected]>2016-06-05 14:29:13 +0200
committerSandro Knauß <[email protected]>2016-06-05 14:29:13 +0200
commit8f82f9dcc10f537fdc1f0b75eb515e2c9042d444 (patch)
treed62f8f7d5485b55c2470686ec02f2ad18c359251
parent2078280b4d22cc72234a59872d3b5a5b94847e4d (diff)
Set default locale for tests to C
switch from QLocal::system() to QLocale() got the the default locale if that is set.
-rw-r--r--autotests/testincidenceformatter.cpp6
-rw-r--r--src/htmlexport.cpp2
-rw-r--r--src/incidenceformatter.cpp34
-rw-r--r--src/stringify.cpp12
4 files changed, 28 insertions, 26 deletions
diff --git a/autotests/testincidenceformatter.cpp b/autotests/testincidenceformatter.cpp
index fcf9b51..ef6860e 100644
--- a/autotests/testincidenceformatter.cpp
+++ b/autotests/testincidenceformatter.cpp
@@ -38,6 +38,7 @@
#include <QDebug>
#include <QIcon>
+#include <QLocale>
#include <QProcess>
#include <QTest>
@@ -52,6 +53,7 @@ void IncidenceFormatterTest::initTestCase()
GrantleeTemplateManager::instance()->setTemplatePath(QStringLiteral(TEST_TEMPLATE_PATH));
GrantleeTemplateManager::instance()->setPluginPath(QStringLiteral(TEST_PLUGIN_PATH));
QIcon::setThemeName(QStringLiteral("oxygen"));
+ QLocale::setDefault(QLocale(QStringLiteral("C")));
}
void IncidenceFormatterTest::testRecurrenceString()
@@ -135,12 +137,12 @@ void IncidenceFormatterTest::testRecurrenceString()
i18n("Recurs every 2 hours until %1", endDateStr));
r3->addExDateTime(kdt.addSecs(1 * 60 * 60));
- QString hourStr = QLocale::system().toString(QTime(13, 0), QLocale::ShortFormat);
+ QString hourStr = QLocale().toString(QTime(13, 0), QLocale::ShortFormat);
QCOMPARE(IncidenceFormatter::recurrenceString(e3),
i18n("Recurs every 2 hours until %1 (excluding %2)", endDateStr, hourStr));
r3->addExDateTime(kdt.addSecs(3 * 60 * 60));
- QString hourStr2 = QLocale::system().toString(QTime(15, 0), QLocale::ShortFormat);
+ QString hourStr2 = QLocale().toString(QTime(15, 0), QLocale::ShortFormat);
QCOMPARE(IncidenceFormatter::recurrenceString(e3),
i18n("Recurs every 2 hours until %1 (excluding %2,%3)", endDateStr, hourStr, hourStr2));
diff --git a/src/htmlexport.cpp b/src/htmlexport.cpp
index 43f0810..d6afaef 100644
--- a/src/htmlexport.cpp
+++ b/src/htmlexport.cpp
@@ -188,7 +188,7 @@ void HtmlExport::createMonthView(QTextStream *ts)
// Write table header
*ts << " <tr>";
for (int i = 0; i < 7; ++i) {
- *ts << "<th>" << QLocale::system().dayName(start.addDays(i).dayOfWeek()) << "</th>";
+ *ts << "<th>" << QLocale().dayName(start.addDays(i).dayOfWeek()) << "</th>";
}
*ts << "</tr>" << endl;
diff --git a/src/incidenceformatter.cpp b/src/incidenceformatter.cpp
index 3d43def..95109d9 100644
--- a/src/incidenceformatter.cpp
+++ b/src/incidenceformatter.cpp
@@ -2652,10 +2652,10 @@ QString IncidenceFormatter::ToolTipVisitor::dateRangeText(const FreeBusy::Ptr &f
QString ret;
ret = QLatin1String("<br>") +
i18n("<i>Period start:</i> %1",
- QLocale::system().toString(fb->dtStart().dateTime(), QLocale::ShortFormat));
+ QLocale().toString(fb->dtStart().dateTime(), QLocale::ShortFormat));
ret += QLatin1String("<br>") +
i18n("<i>Period start:</i> %1",
- QLocale::system().toString(fb->dtEnd().dateTime(), QLocale::ShortFormat));
+ QLocale().toString(fb->dtEnd().dateTime(), QLocale::ShortFormat));
return ret.replace(QLatin1Char(' '), QLatin1String("&nbsp;"));
}
@@ -3017,7 +3017,7 @@ bool IncidenceFormatter::MailBodyVisitor::visit(const Event::Ptr &event)
if (event->allDay()) {
endstr = QLocale().toString(recur->endDate());
} else {
- endstr = QLocale::system().toString(recur->endDateTime().dateTime(), QLocale::ShortFormat);
+ endstr = QLocale().toString(recur->endDateTime().dateTime(), QLocale::ShortFormat);
}
mResult += i18n("Repeat until: %1\n", endstr);
} else {
@@ -3185,7 +3185,7 @@ QString IncidenceFormatter::recurrenceString(const Incidence::Ptr &incidence)
dayList.append(i18n("31st"));
}
- const int weekStart = QLocale::system().firstDayOfWeek();
+ const int weekStart = QLocale().firstDayOfWeek();
QString dayNames;
Recurrence *recur = incidence->recurrence();
@@ -3249,7 +3249,7 @@ QString IncidenceFormatter::recurrenceString(const Incidence::Ptr &incidence)
if (addSpace) {
dayNames.append(i18nc("separator for list of days", ", "));
}
- dayNames.append(QLocale::system().dayName(((i + weekStart + 6) % 7) + 1,
+ dayNames.append(QLocale().dayName(((i + weekStart + 6) % 7) + 1,
QLocale::ShortFormat));
addSpace = true;
}
@@ -3285,7 +3285,7 @@ QString IncidenceFormatter::recurrenceString(const Incidence::Ptr &incidence)
"Recurs every %1 months on the %2 %3 until %4",
recur->frequency(),
dayList[rule.pos() + 31],
- QLocale::system().dayName(rule.day(), QLocale::LongFormat),
+ QLocale().dayName(rule.day(), QLocale::LongFormat),
recurEnd(incidence));
if (recur->duration() > 0) {
recurStr += xi18nc("number of occurrences",
@@ -3298,7 +3298,7 @@ QString IncidenceFormatter::recurrenceString(const Incidence::Ptr &incidence)
"Recurs every %1 months on the %2 %3",
recur->frequency(),
dayList[rule.pos() + 31],
- QLocale::system().dayName(rule.day(), QLocale::LongFormat));
+ QLocale().dayName(rule.day(), QLocale::LongFormat));
}
}
break;
@@ -3404,7 +3404,7 @@ QString IncidenceFormatter::recurrenceString(const Incidence::Ptr &incidence)
" until %5",
recur->frequency(),
dayList[rule.pos() + 31],
- QLocale::system().dayName(rule.day(), QLocale::LongFormat),
+ QLocale().dayName(rule.day(), QLocale::LongFormat),
QLocale().monthName(recur->yearMonths().at(0), QLocale::LongFormat),
recurEnd(incidence));
if (recur->duration() > 0) {
@@ -3419,7 +3419,7 @@ QString IncidenceFormatter::recurrenceString(const Incidence::Ptr &incidence)
"Every %1 years on the %2 %3 of %4",
recur->frequency(),
dayList[rule.pos() + 31],
- QLocale::system().dayName(rule.day(), QLocale::LongFormat),
+ QLocale().dayName(rule.day(), QLocale::LongFormat),
QLocale().monthName(recur->yearMonths().at(0), QLocale::LongFormat));
}
}
@@ -3441,13 +3441,13 @@ QString IncidenceFormatter::recurrenceString(const Incidence::Ptr &incidence)
exStr << i18n("minute %1", (*il).time().minute());
break;
case Recurrence::rHourly:
- exStr << QLocale::system().toString((*il).time(), QLocale::ShortFormat);
+ exStr << QLocale().toString((*il).time(), QLocale::ShortFormat);
break;
case Recurrence::rDaily:
exStr << QLocale().toString((*il).date(), QLocale::ShortFormat);
break;
case Recurrence::rWeekly:
- exStr << QLocale::system().dayName((*il).date().dayOfWeek(), QLocale::ShortFormat);
+ exStr << QLocale().dayName((*il).date().dayOfWeek(), QLocale::ShortFormat);
break;
case Recurrence::rMonthlyPos:
exStr << QLocale().toString((*il).date(), QLocale::ShortFormat);
@@ -3456,7 +3456,7 @@ QString IncidenceFormatter::recurrenceString(const Incidence::Ptr &incidence)
exStr << QLocale().toString((*il).date(), QLocale::ShortFormat);
break;
case Recurrence::rYearlyMonth:
- exStr << QLocale::system().monthName((*il).date().month(), QLocale::LongFormat);
+ exStr << QLocale().monthName((*il).date().month(), QLocale::LongFormat);
break;
case Recurrence::rYearlyDay:
exStr << QLocale().toString((*il).date(), QLocale::ShortFormat);
@@ -3488,7 +3488,7 @@ QString IncidenceFormatter::recurrenceString(const Incidence::Ptr &incidence)
exStr << QLocale().toString((*dl), QLocale::ShortFormat);
break;
case Recurrence::rYearlyMonth:
- exStr << QLocale::system().monthName((*dl).month(), QLocale::LongFormat);
+ exStr << QLocale().monthName((*dl).month(), QLocale::LongFormat);
break;
case Recurrence::rYearlyDay:
exStr << QLocale().toString((*dl), QLocale::ShortFormat);
@@ -3517,9 +3517,9 @@ QString IncidenceFormatter::timeToString(const KDateTime &date,
timeZone = QLatin1Char(' ') + spec.timeZone().name();
}
- return QLocale::system().toString(date.toTimeSpec(spec).time(), shortfmt ? QLocale::ShortFormat : QLocale::LongFormat) + timeZone;
+ return QLocale().toString(date.toTimeSpec(spec).time(), shortfmt ? QLocale::ShortFormat : QLocale::LongFormat) + timeZone;
} else {
- return QLocale::system().toString(date.time(), shortfmt ? QLocale::ShortFormat : QLocale::LongFormat);
+ return QLocale().toString(date.time(), shortfmt ? QLocale::ShortFormat : QLocale::LongFormat);
}
}
@@ -3559,11 +3559,11 @@ QString IncidenceFormatter::dateTimeToString(const KDateTime &date,
timeZone = QLatin1Char(' ') + spec.timeZone().name();
}
- return QLocale::system().toString(
+ return QLocale().toString(
date.toTimeSpec(spec).dateTime(),
(shortfmt ? QLocale::ShortFormat : QLocale::LongFormat)) + timeZone;
} else {
- return QLocale::system().toString(
+ return QLocale().toString(
date.dateTime(),
(shortfmt ? QLocale::ShortFormat : QLocale::LongFormat));
}
diff --git a/src/stringify.cpp b/src/stringify.cpp
index 2dff3a9..48987e7 100644
--- a/src/stringify.cpp
+++ b/src/stringify.cpp
@@ -65,8 +65,8 @@ QString Stringify::incidenceType(Incidence::IncidenceType type)
QString Stringify::todoCompletedDateTime(const Todo::Ptr &todo,
bool shortfmt)
{
- return QLocale::system().toString(todo->completed().dateTime(),
- (shortfmt ? QLocale::ShortFormat : QLocale::LongFormat));
+ return QLocale().toString(todo->completed().dateTime(),
+ (shortfmt ? QLocale::ShortFormat : QLocale::LongFormat));
}
QString Stringify::incidenceSecrecy(Incidence::Secrecy secrecy)
@@ -212,9 +212,9 @@ QString Stringify::formatTime(const KDateTime &dt, bool shortfmt, const KDateTim
timeZone = QLatin1Char(' ') + spec.timeZone().name();
}
- return QLocale::system().toString(dt.toTimeSpec(spec).time(), shortfmt ? QLocale::ShortFormat : QLocale::LongFormat) + timeZone;
+ return QLocale().toString(dt.toTimeSpec(spec).time(), shortfmt ? QLocale::ShortFormat : QLocale::LongFormat) + timeZone;
} else {
- return QLocale::system().toString(dt.time(), shortfmt ? QLocale::ShortFormat : QLocale::LongFormat);
+ return QLocale().toString(dt.time(), shortfmt ? QLocale::ShortFormat : QLocale::LongFormat);
}
}
@@ -251,11 +251,11 @@ QString Stringify::formatDateTime(const KDateTime &dt, bool allDay,
timeZone = QLatin1Char(' ') + spec.timeZone().name();
}
- return QLocale::system().toString(
+ return QLocale().toString(
dt.toTimeSpec(spec).dateTime(),
(shortfmt ? QLocale::ShortFormat : QLocale::LongFormat)) + timeZone;
} else {
- return QLocale::system().toString(
+ return QLocale().toString(
dt.dateTime(),
(shortfmt ? QLocale::ShortFormat : QLocale::LongFormat));
}