Skip to content
Permalink
Browse files
Remove qt4 specific bits
  • Loading branch information
pvuorela committed Mar 13, 2019
1 parent 5c837bd commit dc9f619d39de8e7eb846b91579700fd600ec67a4
Show file tree
Hide file tree
Showing 28 changed files with 19 additions and 206 deletions.
@@ -16,24 +16,13 @@ QT += testlib
TEMPLATE = app
# DEFINES += QT_NO_DEBUG_OUTPUT
DEFINES += UNIT_TEST
equals(QT_MAJOR_VERSION, 4): target.path = $$[QT_INSTALL_LIBS]/libmlocale-benchmarks
equals(QT_MAJOR_VERSION, 5): target.path = $$[QT_INSTALL_LIBS]/libmlocale-benchmarks5
target.path = $$[QT_INSTALL_LIBS]/libmlocale-benchmarks5
INSTALLS += target

equals(QT_MAJOR_VERSION, 4): LIBS += $$mAddLibrary(mlocale)
equals(QT_MAJOR_VERSION, 5): LIBS += $$mAddLibrary(mlocale5)
LIBS += $$mAddLibrary(mlocale5)

support_files.files =
equals(QT_MAJOR_VERSION, 4): support_files.path = $$[QT_INSTALL_LIBS]/libmlocale-benchmarks
equals(QT_MAJOR_VERSION, 5): support_files.path = $$[QT_INSTALL_LIBS]/libmlocale-benchmarks5
support_files.path = $$[QT_INSTALL_LIBS]/libmlocale-benchmarks5
INSTALLS += support_files

CONFIG-=app_bundle

equals(QT_MAJOR_VERSION, 4): DEFINES += '\'QTEST_GUILESS_MAIN(TestObject)=\
int main(int argc, char *argv[]) \
{ \
QCoreApplication app(argc, argv); \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
}\''
@@ -29,9 +29,6 @@ using ML10N::MCalendar;

void Pt_MCalendar::initTestCase()
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
QProcess process;
process.start("sh -c \"dpkg -s libicu44 | grep Version | perl -pe 's/^Version:[[:space:]]*([^[[:space:]]+)$/$1/g'\"");
if (!process.waitForFinished()) {
@@ -24,9 +24,6 @@ using ML10N::MCharsetMatch;

void Pt_MCharsetDetector::initTestCase()
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
}

void Pt_MCharsetDetector::cleanupTestCase()
@@ -26,9 +26,6 @@ using ML10N::MCollator;

void Pt_MLocale::initTestCase()
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
QProcess process;
#ifdef HAVE_ICU
process.start("sh -c \"dpkg -s libicu44 | grep Version | perl -pe 's/^Version:[[:space:]]*([^[[:space:]]+)$/$1/g'\"");
@@ -28,9 +28,6 @@ using ML10N::MLocationDatabase;

void Pt_MLocationDatabase::initTestCase()
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
}

void Pt_MLocationDatabase::cleanupTestCase()
@@ -4,8 +4,7 @@ shell_scripts.CONFIG += no_check_exist

include(../mkspecs/common.pri)

equals(QT_MAJOR_VERSION, 4): shell_scripts.path += $$ML_INSTALL_DATA/libmlocale-benchmarks
equals(QT_MAJOR_VERSION, 5): shell_scripts.path += $$ML_INSTALL_DATA/libmlocale-benchmarks5
shell_scripts.path += $$ML_INSTALL_DATA/libmlocale-benchmarks5
shell_scripts.depends = FORCE

INSTALLS += \
@@ -501,7 +501,7 @@ fi

# substitute prefix in .pc files
MEEGOTOUCH_PC_DIR="$outpath/src/data"
MEEGOTOUCH_PC_FILES="mlocale mlocale5"
MEEGOTOUCH_PC_FILES="mlocale5"

# make sure the directory exists
if [ ! -d $MEEGOTOUCH_PC_DIR ]; then
@@ -551,8 +551,8 @@ if [ -z "$QMAKE_BIN" ]; then
fi

# now check for qt version
QT_MAJOR_VERSION_NEEDED=4
QT_MINOR_VERSION_NEEDED=7
QT_MAJOR_VERSION_NEEDED=5
QT_MINOR_VERSION_NEEDED=0

QT_VERSION=$($QMAKE_BIN -query QT_VERSION)

@@ -28,13 +28,10 @@ win32 {
ML_INSTALL_BIN = $$ML_PREFIX/bin
ML_INSTALL_LIBS = $$ML_LIBDIR
ML_INSTALL_DATA = $$ML_PREFIX/share
equals(QT_MAJOR_VERSION, 4): ML_INSTALL_HEADERS = $$ML_PREFIX/include/mlocale
equals(QT_MAJOR_VERSION, 5): ML_INSTALL_HEADERS = $$ML_PREFIX/include/mlocale5
equals(QT_MAJOR_VERSION, 4): ML_TRANSLATION_DIR = $$ML_INSTALL_DATA/l10n/mlocale
equals(QT_MAJOR_VERSION, 5): ML_TRANSLATION_DIR = $$ML_INSTALL_DATA/l10n/mlocale5
ML_INSTALL_HEADERS = $$ML_PREFIX/include/mlocale5
ML_TRANSLATION_DIR = $$ML_INSTALL_DATA/l10n/mlocale5

equals(QT_MAJOR_VERSION, 4): unix|win32: ML_ICUEXTRADATA_DIR = $$ML_INSTALL_DATA/mlocale/icu
equals(QT_MAJOR_VERSION, 5): unix|win32: ML_ICUEXTRADATA_DIR = $$ML_INSTALL_DATA/mlocale5/icu
ML_ICUEXTRADATA_DIR = $$ML_INSTALL_DATA/mlocale5/icu
win32: ML_INSTALL_LIBS = $$ML_PREFIX/bin

defineReplace(mAddLibrary) {

This file was deleted.

@@ -288,14 +288,7 @@ void MCalendar::setDateTime(QDateTime dateTime)

// We cannot use QDateTime::toTime_t because this
// works only for dates after 1970-01-01T00:00:00.000.
#if QT_VERSION >= 0x040700
UDate icuDate = dateTime.toMSecsSinceEpoch();
#else
// Qt < 4.7 lacks QDateTime::toMSecsSinceEpoch(), we need to emulate it:
int days = QDate(1970, 1, 1).daysTo(dateTime.date());
qint64 msecs = qint64(QTime().secsTo(dateTime.time())) * 1000;
UDate icuDate = (qint64(days) * MSECS_PER_DAY) + msecs;
#endif

if (originalTimeSpec == Qt::LocalTime) {
// convert from local time to UTC
@@ -335,21 +328,7 @@ QDateTime MCalendar::qDateTime(Qt::TimeSpec spec) const
QDateTime dateTime;
// avoid conversions by Qt
dateTime.setTimeSpec(Qt::UTC);
#if QT_VERSION >= 0x040700
dateTime.setMSecsSinceEpoch(qint64(icuDate));
#else
// Qt < 4.7 lacks QDateTime::setMSecsSinceEpoch(), we need to emulate it.
qint64 msecs = qint64(icuDate);
int ddays = msecs / MSECS_PER_DAY;
msecs %= MSECS_PER_DAY;
if (msecs < 0) {
// negative
--ddays;
msecs += MSECS_PER_DAY;
}
dateTime.setDate(QDate(1970, 1, 1).addDays(ddays));
dateTime.setTime(QTime().addMSecs(msecs));
#endif
// note: we set time spec after time value so Qt will not any
// conversions of its own to UTC. We might let Qt handle it but
// this might be more robust
@@ -134,14 +134,7 @@ qint32 MCity::timeZoneDstOffset(QDateTime dateTime) const
UBool local = dateTime.timeSpec() == Qt::LocalTime? true : false;
// we avoid time conversions done by Qt:
dateTime.setTimeSpec(Qt::UTC);
#if QT_VERSION >= 0x040700
UDate icuDate = dateTime.toMSecsSinceEpoch();
#else
// Qt < 4.7 lacks QDateTime::toMSecsSinceEpoch(), we need to emulate it:
int days = QDate(1970, 1, 1).daysTo(dateTime.date());
qint64 msecs = qint64(QTime().secsTo(dateTime.time())) * 1000;
UDate icuDate = (qint64(days) * MSECS_PER_DAY) + msecs;
#endif
icu::TimeZone *tz =
TimeZone::createTimeZone(MIcuConversions::qStringToUnicodeString(d->timeZone));
qint32 rawOffset;
@@ -163,14 +156,7 @@ qint32 MCity::timeZoneTotalOffset(QDateTime dateTime) const
UBool local = dateTime.timeSpec() == Qt::LocalTime? true : false;
// we avoid time conversions done by Qt:
dateTime.setTimeSpec(Qt::UTC);
#if QT_VERSION >= 0x040700
UDate icuDate = dateTime.toMSecsSinceEpoch();
#else
// Qt < 4.7 lacks QDateTime::toMSecsSinceEpoch(), we need to emulate it:
int days = QDate(1970, 1, 1).daysTo(dateTime.date());
qint64 msecs = qint64(QTime().secsTo(dateTime.time())) * 1000;
UDate icuDate = (qint64(days) * MSECS_PER_DAY) + msecs;
#endif
icu::TimeZone *tz =
TimeZone::createTimeZone(MIcuConversions::qStringToUnicodeString(d->timeZone));
qint32 rawOffset;
@@ -6,8 +6,7 @@ include(common_top.pri)
QT += xml
QT -= gui

equals(QT_MAJOR_VERSION, 4): TARGET = mlocale
equals(QT_MAJOR_VERSION, 5): TARGET = mlocale5
TARGET = mlocale5

INCLUDEPATH += .

@@ -104,8 +103,7 @@ INSTALLS += install_prf

# install pkgconfig file
install_pkgconfig.path = $$ML_INSTALL_LIBS/pkgconfig
equals(QT_MAJOR_VERSION, 4): install_pkgconfig.files = data/mlocale.pc
equals(QT_MAJOR_VERSION, 5): install_pkgconfig.files = data/mlocale5.pc
install_pkgconfig.files = data/mlocale5.pc

INSTALLS += install_pkgconfig

@@ -19,22 +19,11 @@ QT += testlib
TEMPLATE = app
# DEFINES += QT_NO_DEBUG_OUTPUT
DEFINES += UNIT_TEST
equals(QT_MAJOR_VERSION, 4): target.path = $$[QT_INSTALL_LIBS]/libmlocale-tests
equals(QT_MAJOR_VERSION, 5): target.path = $$[QT_INSTALL_LIBS]/libmlocale-tests5
target.path = $$[QT_INSTALL_LIBS]/libmlocale-tests5
INSTALLS += target

equals(QT_MAJOR_VERSION, 4): LIBS += $$mAddLibrary(mlocale)
equals(QT_MAJOR_VERSION, 5): LIBS += $$mAddLibrary(mlocale5)
LIBS += $$mAddLibrary(mlocale5)

support_files.files =
equals(QT_MAJOR_VERSION, 4): support_files.path = $$[QT_INSTALL_LIBS]/libmlocale-tests
equals(QT_MAJOR_VERSION, 5): support_files.path = $$[QT_INSTALL_LIBS]/libmlocale-tests5
support_files.path = $$[QT_INSTALL_LIBS]/libmlocale-tests5
INSTALLS += support_files

equals(QT_MAJOR_VERSION, 4): DEFINES += '\'QTEST_GUILESS_MAIN(TestObject)=\
int main(int argc, char *argv[]) \
{ \
QCoreApplication app(argc, argv); \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
}\''
@@ -37,9 +37,6 @@ class TestBreakIterator : public MBreakIterator

void Ft_BreakIterator::initTestCase()
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
}

void Ft_BreakIterator::cleanupTestCase()
@@ -23,9 +23,6 @@ using ML10N::MLocale;

void Ft_LocaleData::initTestCase()
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
MLocale::setDataPath(qApp->applicationDirPath());
}

@@ -31,9 +31,6 @@ class TestLocale : public MLocale

void Ft_Locales::initTestCase()
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
QProcess process;
process.start("sh -c \"dpkg -s libqtcore4 | grep Version | perl -pe 's/^Version:[[:space:]]*([^[[:space:]]+)$/$1/g'\"");
if (!process.waitForFinished()) {
@@ -949,59 +946,19 @@ void Ft_Locales::testMLocaleToLower_data()
<< QString("größe")
;

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
if(libqtcore4PackageVersion >= "4.7.2~git20110119"
&& libqtcore4PackageVersion < "4.7.4~git20110516-0maemo2") { // Qt uses libicu
QTest::newRow("de_DE")
<< QString("de_DE")
<< QString("GRÖẞE")
<< QString("größe")
<< QString("größe") // works because Qt’s toLower uses libicu now
;
}
else {
QTest::newRow("de_DE")
<< QString("de_DE")
<< QString("GRÖẞE")
<< QString("größe")
<< QString("gröẞe") // Qt bug?
;
}
#else
QTest::newRow("de_DE")
<< QString("de_DE")
<< QString("GRÖẞE")
<< QString("größe")
<< QString("größe")
;
#endif

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
if(libqtcore4PackageVersion >= "4.7.2~git20110119"
&& libqtcore4PackageVersion < "4.7.4~git20110516-0maemo2") { // Qt uses libicu
QTest::newRow("de_CH") // no difference in behaviour to de_CH here
<< QString("de_CH")
<< QString("GRÖẞE")
<< QString("größe")
<< QString("größe") // works because Qt’s toLower uses libicu now
;
}
else {
QTest::newRow("de_CH") // no difference in behaviour to de_CH here
<< QString("de_CH")
<< QString("GRÖẞE")
<< QString("größe")
<< QString("gröẞe") // Qt bug?
;
}
#else
QTest::newRow("de_CH") // no difference in behaviour to de_CH here
<< QString("de_CH")
<< QString("GRÖẞE")
<< QString("größe")
<< QString("größe")
;
#endif

QTest::newRow("en_GB")
<< QString("en_GB")
@@ -4039,11 +3996,7 @@ void Ft_Locales::testMLocaleIndexBucket()
// we need to instantiate a MLocale before dataPaths returns
// a valid result.
MLocale locale(localeName);
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QCOMPARE(MLocale::dataPaths(), (QStringList() << "/usr/share/mlocale/icu"));
#else
QCOMPARE(MLocale::dataPaths(), (QStringList() << "/usr/share/mlocale5/icu"));
#endif

MLocale localeEn("en_US");
locale.setCategoryLocale(MLocale::MLcCollate, lcCollate);
@@ -4206,11 +4159,7 @@ void Ft_Locales::testDifferentStrengthComparison()
QFETCH(QString, string2);
QFETCH(QList<MLocale::Comparison>, comparisonExpectedResults);

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QCOMPARE(MLocale::dataPaths(), (QStringList() << "/usr/share/mlocale/icu"));
#else
QCOMPARE(MLocale::dataPaths(), (QStringList() << "/usr/share/mlocale5/icu"));
#endif
MLocale locale(localeName);
locale.setCategoryLocale(MLocale::MLcCollate, lcCollate);
MCollator collator = locale.collator();
@@ -4618,11 +4567,7 @@ void Ft_Locales::checkAvailableLocales()
QString ft_localesTestOutput = "";
foreach(QString supportedLocaleName, supportedLocaleNames) {
MLocale locale(supportedLocaleName);
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QCOMPARE(MLocale::dataPaths(), (QStringList() << "/usr/share/mlocale/icu"));
#else
QCOMPARE(MLocale::dataPaths(), (QStringList() << "/usr/share/mlocale5/icu"));
#endif
locale.setTimeFormat24h(MLocale::LocaleDefaultTimeFormat24h);
QCOMPARE(locale.timeFormat24h(), MLocale::LocaleDefaultTimeFormat24h);
qSort(sortingTestList.begin(), sortingTestList.end(), locale.collator());
@@ -26,9 +26,6 @@ using ML10N::MCharsetDetector;

void Ft_MCharsetDetector::initTestCase()
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
}

void Ft_MCharsetDetector::cleanupTestCase()
@@ -43,11 +43,6 @@ QStringList inputItems;

void Ft_MLocaleBuckets::initTestCase()
{
// This is important for string constants with non-ASCII characters:
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif

inputItems
<< "Ömer" // 0
<< "Yannick" // 1
@@ -27,9 +27,6 @@ using ML10N::MStringSearch;

void Ft_MStringSearch::initTestCase()
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
}

void Ft_MStringSearch::cleanupTestCase()

0 comments on commit dc9f619

Please sign in to comment.