Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove qt4 specific bits
  • Loading branch information
pvuorela committed Mar 13, 2019
1 parent 5c837bd commit dc9f619
Show file tree
Hide file tree
Showing 28 changed files with 19 additions and 206 deletions.
17 changes: 3 additions & 14 deletions benchmarks/common_top.pri
Expand Up @@ -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); \
}\''
3 changes: 0 additions & 3 deletions benchmarks/pt_mcalendar/pt_mcalendar.cpp
Expand Up @@ -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()) {
Expand Down
3 changes: 0 additions & 3 deletions benchmarks/pt_mcharsetdetector/pt_mcharsetdetector.cpp
Expand Up @@ -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()
Expand Down
3 changes: 0 additions & 3 deletions benchmarks/pt_mlocale/pt_mlocale.cpp
Expand Up @@ -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'\"");
Expand Down
3 changes: 0 additions & 3 deletions benchmarks/pt_mlocationdatabase/pt_mlocationdatabase.cpp
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/shell.pri
Expand Up @@ -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 += \
Expand Down
6 changes: 3 additions & 3 deletions configure
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
9 changes: 3 additions & 6 deletions mkspecs/features/mlocale_defines.prf.in
Expand Up @@ -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) {
Expand Down
11 changes: 0 additions & 11 deletions src/data/mlocale.pc.in

This file was deleted.

21 changes: 0 additions & 21 deletions src/mcalendar.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 0 additions & 14 deletions src/mcity.cpp
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions src/src.pro
Expand Up @@ -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 += .

Expand Down Expand Up @@ -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

Expand Down
17 changes: 3 additions & 14 deletions tests/common_top.pri
Expand Up @@ -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); \
}\''
3 changes: 0 additions & 3 deletions tests/ft_breakiterator/ft_breakiterator.cpp
Expand Up @@ -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()
Expand Down
3 changes: 0 additions & 3 deletions tests/ft_localedata/ft_localedata.cpp
Expand Up @@ -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());
}

Expand Down
55 changes: 0 additions & 55 deletions tests/ft_locales/ft_locales.cpp
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand Down
3 changes: 0 additions & 3 deletions tests/ft_mcharsetdetector/ft_mcharsetdetector.cpp
Expand Up @@ -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()
Expand Down
5 changes: 0 additions & 5 deletions tests/ft_mlocalebuckets/ft_mlocalebuckets.cpp
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions tests/ft_mstringsearch/ft_mstringsearch.cpp
Expand Up @@ -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()
Expand Down

0 comments on commit dc9f619

Please sign in to comment.