From 93233fc811920002d5b5b8272d9b5b8d5d3e2b98 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 3 May 2011 16:18:42 +0200 Subject: Added support for QLocale::uiLanguages on Symbian. Extended the mapping table that matches symbian device languages to a locale name and language code. Task-number: QTBUG-7329 Reviewed-by: trustme --- src/corelib/tools/qlocale_symbian.cpp | 166 ++++++++++++++++++++-------------- 1 file changed, 96 insertions(+), 70 deletions(-) diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index 09d74d0..3ed10f9 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -86,6 +87,7 @@ static TPtrC defaultFormatSpec(TExtendedLocale&) struct symbianToISO { int symbian_language; char iso_name[8]; + char uilanguage[8]; }; @@ -94,77 +96,79 @@ struct symbianToISO { NOTE: This array should be sorted by the first column! */ static const symbianToISO symbian_to_iso_list[] = { - { ELangEnglish, "en_GB" }, // 1 - { ELangFrench, "fr_FR" }, // 2 - { ELangGerman, "de_DE" }, // 3 - { ELangSpanish, "es_ES" }, // 4 - { ELangItalian, "it_IT" }, // 5 - { ELangSwedish, "sv_SE" }, // 6 - { ELangDanish, "da_DK" }, // 7 - { ELangNorwegian, "no_NO" }, // 8 - { ELangFinnish, "fi_FI" }, // 9 - { ELangAmerican, "en_US" }, // 10 - { ELangPortuguese, "pt_PT" }, // 13 - { ELangTurkish, "tr_TR" }, // 14 - { ELangIcelandic, "is_IS" }, // 15 - { ELangRussian, "ru_RU" }, // 16 - { ELangHungarian, "hu_HU" }, // 17 - { ELangDutch, "nl_NL" }, // 18 - { ELangBelgianFlemish, "nl_BE" }, // 19 - { ELangCzech, "cs_CZ" }, // 25 - { ELangSlovak, "sk_SK" }, // 26 - { ELangPolish, "pl_PL" }, // 27 - { ELangSlovenian, "sl_SI" }, // 28 - { ELangTaiwanChinese, "zh_TW" }, // 29 - { ELangHongKongChinese, "zh_HK" }, // 30 - { ELangPrcChinese, "zh_CN" }, // 31 - { ELangJapanese, "ja_JP" }, // 32 - { ELangThai, "th_TH" }, // 33 - { ELangArabic, "ar_AE" }, // 37 - { ELangTagalog, "tl_PH" }, // 39 - { ELangBulgarian, "bg_BG" }, // 42 - { ELangCatalan, "ca_ES" }, // 44 - { ELangCroatian, "hr_HR" }, // 45 - { ELangEstonian, "et_EE" }, // 49 - { ELangFarsi, "fa_IR" }, // 50 - { ELangCanadianFrench, "fr_CA" }, // 51 - { ELangGreek, "el_GR" }, // 54 - { ELangHebrew, "he_IL" }, // 57 - { ELangHindi, "hi_IN" }, // 58 - { ELangIndonesian, "id_ID" }, // 59 - { ELangKorean, "ko_KO" }, // 65 - { ELangLatvian, "lv_LV" }, // 67 - { ELangLithuanian, "lt_LT" }, // 68 - { ELangMalay, "ms_MY" }, // 70 - { ELangNorwegianNynorsk, "nn_NO" }, // 75 - { ELangBrazilianPortuguese, "pt_BR" }, // 76 - { ELangRomanian, "ro_RO" }, // 78 - { ELangSerbian, "sr_RS" }, // 79 - { ELangLatinAmericanSpanish,"es_419" }, // 83 - { ELangUkrainian, "uk_UA" }, // 93 - { ELangUrdu, "ur_PK" }, // 94 - India/Pakistan - { ELangVietnamese, "vi_VN" }, // 96 + { ELangEnglish, "en_GB", "en" }, // 1 + { ELangFrench, "fr_FR", "fr" }, // 2 + { ELangGerman, "de_DE", "de" }, // 3 + { ELangSpanish, "es_ES", "es" }, // 4 + { ELangItalian, "it_IT", "it" }, // 5 + { ELangSwedish, "sv_SE", "sv" }, // 6 + { ELangDanish, "da_DK", "da" }, // 7 + { ELangNorwegian, "nb_NO", "nb" }, // 8 + { ELangFinnish, "fi_FI", "fi" }, // 9 + { ELangAmerican, "en_US", "en-US" }, // 10 + { ELangPortuguese, "pt_PT", "pt" }, // 13 + { ELangTurkish, "tr_TR", "tr" }, // 14 + { ELangIcelandic, "is_IS", "is" }, // 15 + { ELangRussian, "ru_RU", "ru" }, // 16 + { ELangHungarian, "hu_HU", "hu" }, // 17 + { ELangDutch, "nl_NL", "nl" }, // 18 + { ELangCzech, "cs_CZ", "cs" }, // 25 + { ELangSlovak, "sk_SK", "sk" }, // 26 + { ELangPolish, "pl_PL", "pl" }, // 27 + { ELangSlovenian, "sl_SI", "sl" }, // 28 + { ELangTaiwanChinese, "zh_TW", "zh-TW" }, // 29 + { ELangHongKongChinese, "zh_HK", "zh-HK" }, // 30 + { ELangPrcChinese, "zh_CN", "zh" }, // 31 + { ELangJapanese, "ja_JP", "ja" }, // 32 + { ELangThai, "th_TH", "th" }, // 33 + { ELangArabic, "ar_AE", "ar" }, // 37 + { ELangTagalog, "tl_PH", "tl" }, // 39 + { ELangBulgarian, "bg_BG", "bg" }, // 42 + { ELangCatalan, "ca_ES", "ca" }, // 44 + { ELangCroatian, "hr_HR", "hr" }, // 45 + { ELangEstonian, "et_EE", "et" }, // 49 + { ELangFarsi, "fa_IR", "fa" }, // 50 + { ELangCanadianFrench, "fr_CA", "fr-CA" }, // 51 + { ELangGreek, "el_GR", "el" }, // 54 + { ELangHebrew, "he_IL", "he" }, // 57 + { ELangHindi, "hi_IN", "hi" }, // 58 + { ELangIndonesian, "id_ID", "id" }, // 59 + { ELangKorean, "ko_KO", "ko" }, // 65 + { ELangLatvian, "lv_LV", "lv" }, // 67 + { ELangLithuanian, "lt_LT", "lt" }, // 68 + { ELangMalay, "ms_MY", "ms" }, // 70 + { ELangNorwegianNynorsk, "nn_NO", "nn" }, // 75 + { ELangBrazilianPortuguese, "pt_BR", "pt-BR" }, // 76 + { ELangRomanian, "ro_RO", "ro" }, // 78 + { ELangSerbian, "sr_RS", "sr" }, // 79 + { ELangLatinAmericanSpanish,"es_419", "es-419" },// 83 + { ELangUkrainian, "uk_UA", "uk" }, // 93 + { ELangUrdu, "ur_PK", "ur" }, // 94 - India/Pakistan + { ELangVietnamese, "vi_VN", "vi" }, // 96 #ifdef __E32LANG_H__ // 5.0 - { ELangBasque, "eu_ES" }, // 102 - { ELangGalician, "gl_ES" }, // 103 + { ELangBasque, "eu_ES", "eu" }, // 102 + { ELangGalician, "gl_ES", "gl" }, // 103 #endif #if !defined(__SERIES60_31__) - { ELangEnglish_Apac, "en" }, // 129 - { ELangEnglish_Taiwan, "en_TW" }, // 157 ### Not supported by CLDR - { ELangEnglish_HongKong, "en_HK" }, // 158 - { ELangEnglish_Prc, "en_CN" }, // 159 ### Not supported by CLDR - { ELangEnglish_Japan, "en_JP"}, // 160 ### Not supported by CLDR - { ELangEnglish_Thailand, "en_TH" }, // 161 ### Not supported by CLDR - { ELangMalay_Apac, "ms" }, // 326 + { ELangEnglish_Apac, "en_GB", "en" }, // 129 + { ELangEnglish_Taiwan, "en_TW", "en-TW" }, // 157 ### Not supported by CLDR + { ELangEnglish_HongKong, "en_HK", "en-HK" }, // 158 + { ELangEnglish_Prc, "en_CN", "en-CN" }, // 159 ### Not supported by CLDR + { ELangEnglish_Japan, "en_JP", "en" }, // 160 ### Not supported by CLDR + { ELangEnglish_Thailand, "en_TH", "en" }, // 161 ### Not supported by CLDR + { ELangEnglish_India, "en_IN", "en" }, // 230 + { ELangMalay_Apac, "ms_MY", "ms" }, // 326 #endif - { 327/*ELangIndonesian_Apac*/,"id_ID" } // 327 - appeared in Symbian^3 + { 327/*ELangIndonesian_Apac*/, "id_ID", "id" } // 327 - appeared in Symbian^3 }; -/*! - Returns ISO name corresponding to the Symbian locale code \a sys_fmt. -*/ -QByteArray qt_symbianLocaleName(int code) +enum LocaleNameType { + ISO, + UILanguage +}; + +QByteArray qt_resolveSymbianLocaleName(int code, LocaleNameType type) { //Number of Symbian to ISO locale mappings static const int symbian_to_iso_count @@ -174,8 +178,11 @@ QByteArray qt_symbianLocaleName(int code) if (cmp < 0) return 0; - if (cmp == 0) - return symbian_to_iso_list[0].iso_name; + if (cmp == 0) { + if (type == ISO) + return symbian_to_iso_list[0].iso_name; + return symbian_to_iso_list[0].uilanguage; + } int begin = 0; int end = symbian_to_iso_count; @@ -185,17 +192,27 @@ QByteArray qt_symbianLocaleName(int code) const symbianToISO *elt = symbian_to_iso_list + mid; int cmp = code - elt->symbian_language; - if (cmp < 0) + if (cmp < 0) { end = mid; - else if (cmp > 0) + } else if (cmp > 0) { begin = mid; - else - return elt->iso_name; + } else { + if (type == ISO) + return elt->iso_name; + return elt->uilanguage; + } } return 0; } +/*! + Returns ISO name corresponding to the Symbian locale code \a sys_fmt. +*/ +QByteArray qt_symbianLocaleName(int code) +{ + return qt_resolveSymbianLocaleName(code, ISO); +} // order is: normal, abbr, nmode, nmode+abbr static const char *us_locale_dep[] = { @@ -822,6 +839,13 @@ QLocale QSystemLocale::fallbackLocale() const return QLocale(locale); } +static QStringList symbianUILanguages() +{ + TLanguage lang = User::Language(); + QString s = QLatin1String(qt_resolveSymbianLocaleName(lang, UILanguage)); + return QStringList(s); +} + QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const { switch(type) { @@ -889,6 +913,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const return qt_TDes2QString(TAmPmName(TAmPm(EAm))); case PMText: return qt_TDes2QString(TAmPmName(TAmPm(EPm))); + case UILanguages: + return QVariant(symbianUILanguages()); default: break; } -- cgit v0.12 From c6808af66d45541546b30c8e6de155b9812b4ef9 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 3 May 2011 16:22:43 +0200 Subject: Added Kazakh language to the QLocale mapping table on Symbian. Reviewed-by: trustme --- src/corelib/tools/qlocale_symbian.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index 3ed10f9..abd1da2 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -133,6 +133,7 @@ static const symbianToISO symbian_to_iso_list[] = { { ELangHebrew, "he_IL", "he" }, // 57 { ELangHindi, "hi_IN", "hi" }, // 58 { ELangIndonesian, "id_ID", "id" }, // 59 + { 63/*ELangKazakh*/, "kk_KZ", "kk" }, // 63 { ELangKorean, "ko_KO", "ko" }, // 65 { ELangLatvian, "lv_LV", "lv" }, // 67 { ELangLithuanian, "lt_LT", "lt" }, // 68 -- cgit v0.12 From 154ab1cb4c4cdf34f21fc93b078f91cc79048bd4 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 4 May 2011 13:07:54 +0200 Subject: Compile fix for QLocale on Symbian. The previous change added new ELangEnglish_India that doesn't necesserally present in all SDKs. Reviewed-by: trustme --- src/corelib/tools/qlocale_symbian.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index abd1da2..5dca7b7 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -158,7 +158,7 @@ static const symbianToISO symbian_to_iso_list[] = { { ELangEnglish_Prc, "en_CN", "en-CN" }, // 159 ### Not supported by CLDR { ELangEnglish_Japan, "en_JP", "en" }, // 160 ### Not supported by CLDR { ELangEnglish_Thailand, "en_TH", "en" }, // 161 ### Not supported by CLDR - { ELangEnglish_India, "en_IN", "en" }, // 230 + { 230/*ELangEnglish_India*/,"en_IN", "en" }, // 230 { ELangMalay_Apac, "ms_MY", "ms" }, // 326 #endif { 327/*ELangIndonesian_Apac*/, "id_ID", "id" } // 327 - appeared in Symbian^3 -- cgit v0.12 From 0e449f38894b1bd2dbb2f14206a011424679f063 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 4 May 2011 13:47:06 +0200 Subject: HTTP backend: do not load resources from cache that must be revalidated The header field "Cache-Control: must-revalidate" is a strict requirement for loading the resource from the server, and not reading it from the cache without revalidating first. With this patch, PreferCache will load such from the network instead of loading them from the cache, and AlwaysCache will throw a ContentNotFound error. Reviewed-by: Markus Goetz Task-number: QTBUG-18983 --- src/network/access/qnetworkaccesshttpbackend.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index c619114..a45c2de 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -262,13 +262,11 @@ bool QNetworkAccessHttpBackend::loadFromCacheIfAllowed(QHttpNetworkRequest &http if (lastModified.isValid()) httpRequest.setHeaderField("If-Modified-Since", QNetworkHeadersPrivate::toHttpDate(lastModified)); - if (CacheLoadControlAttribute == QNetworkRequest::PreferNetwork) { - it = cacheHeaders.findRawHeader("Cache-Control"); - if (it != cacheHeaders.rawHeaders.constEnd()) { - QHash cacheControl = parseHttpOptionHeader(it->second); - if (cacheControl.contains("must-revalidate")) - return false; - } + it = cacheHeaders.findRawHeader("Cache-Control"); + if (it != cacheHeaders.rawHeaders.constEnd()) { + QHash cacheControl = parseHttpOptionHeader(it->second); + if (cacheControl.contains("must-revalidate")) + return false; } QDateTime currentDateTime = QDateTime::currentDateTime(); -- cgit v0.12 From 1a75d7cde5bf7fb97abb188300e2a56b5b9963bf Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 4 May 2011 13:49:51 +0200 Subject: HTTP cache backend: do not load resources that must be revalidated The header field "Cache-Control: must-revalidate" is a strict requirement for loading the resource from the server, and not reading it from the cache without revalidating first. With this patch, PreferCache will load such from the network instead of loading them from the cache, and AlwaysCache will throw a ContentNotFound error. Reviewed-by: Markus Goetz Task-number: QTBUG-18983 --- src/network/access/qnetworkaccesscachebackend.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/network/access/qnetworkaccesscachebackend.cpp b/src/network/access/qnetworkaccesscachebackend.cpp index 13f4cd9..c585848 100644 --- a/src/network/access/qnetworkaccesscachebackend.cpp +++ b/src/network/access/qnetworkaccesscachebackend.cpp @@ -66,6 +66,7 @@ void QNetworkAccessCacheBackend::open() QString msg = QCoreApplication::translate("QNetworkAccessCacheBackend", "Error opening %1") .arg(this->url().toString()); error(QNetworkReply::ContentNotFoundError, msg); + } else { setAttribute(QNetworkRequest::SourceIsFromCacheAttribute, true); } finished(); @@ -85,14 +86,18 @@ bool QNetworkAccessCacheBackend::sendCacheContents() QNetworkCacheMetaData::AttributesMap attributes = item.attributes(); setAttribute(QNetworkRequest::HttpStatusCodeAttribute, attributes.value(QNetworkRequest::HttpStatusCodeAttribute)); setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, attributes.value(QNetworkRequest::HttpReasonPhraseAttribute)); - setAttribute(QNetworkRequest::SourceIsFromCacheAttribute, true); // set the raw headers QNetworkCacheMetaData::RawHeaderList rawHeaders = item.rawHeaders(); QNetworkCacheMetaData::RawHeaderList::ConstIterator it = rawHeaders.constBegin(), end = rawHeaders.constEnd(); - for ( ; it != end; ++it) + for ( ; it != end; ++it) { + if (it->first.toLower() == "cache-control" && + it->second.toLower().contains("must-revalidate")) { + return false; + } setRawHeader(it->first, it->second); + } // handle a possible redirect QVariant redirectionTarget = attributes.value(QNetworkRequest::RedirectionTargetAttribute); -- cgit v0.12 From 4237c59dba78d80be165ae8dd1691abfc61503b1 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 4 May 2011 13:50:40 +0200 Subject: HTTP auto tests: do not load resources from cache that must be revalidtd The header field "Cache-Control: must-revalidate" is a strict requirement for loading the resource from the server, and not reading it from the cache without revalidating first. With this patch, PreferCache will load such from the network instead of loading them from the cache, and AlwaysCache will throw a ContentNotFound error. Reviewed-by: Markus Goetz Task-number: QTBUG-18983 --- tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp | 4 ++-- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp index 76e6711..e2842c1 100644 --- a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp +++ b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp @@ -261,14 +261,14 @@ void tst_QAbstractNetworkCache::cacheControl_data() QTest::newRow("200-2") << QNetworkRequest::AlwaysNetwork << "httpcachetest_cachecontrol.cgi?no-cache" << AlwaysFalse; QTest::newRow("200-3") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol.cgi?no-cache" << false; - QTest::newRow("200-4") << QNetworkRequest::AlwaysCache << "httpcachetest_cachecontrol.cgi?no-cache" << false;//AlwaysTrue; + QTest::newRow("200-4") << QNetworkRequest::AlwaysCache << "httpcachetest_cachecontrol.cgi?no-cache" << false; QTest::newRow("200-5") << QNetworkRequest::PreferCache << "httpcachetest_cachecontrol.cgi?no-cache" << false; QTest::newRow("304-0") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol.cgi?max-age=1000" << true; QTest::newRow("304-1") << QNetworkRequest::AlwaysNetwork << "httpcachetest_cachecontrol.cgi?max-age=1000, must-revalidate" << AlwaysFalse; QTest::newRow("304-2") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol.cgi?max-age=1000, must-revalidate" << true; - QTest::newRow("304-3") << QNetworkRequest::AlwaysCache << "httpcachetest_cachecontrol.cgi?max-age=1000, must-revalidate" << AlwaysTrue; + QTest::newRow("304-3") << QNetworkRequest::AlwaysCache << "httpcachetest_cachecontrol.cgi?max-age=1000, must-revalidate" << false; QTest::newRow("304-4") << QNetworkRequest::PreferCache << "httpcachetest_cachecontrol.cgi?max-age=1000, must-revalidate" << true; // see QTBUG-7060 diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index f509cea..bf1feaf 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -3237,16 +3237,16 @@ void tst_QNetworkReply::ioGetFromHttpWithCache_data() QTest::newRow("must-revalidate,200,prefer-network") << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << false << true; QTest::newRow("must-revalidate,200,prefer-cache") - << reply200 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << true << false; + << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << false << true; QTest::newRow("must-revalidate,200,always-cache") - << reply200 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << QStringList() << true << false; + << reply200 << "" << content << int(QNetworkRequest::AlwaysCache) << QStringList() << false << false; QTest::newRow("must-revalidate,304,prefer-network") << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << true << true; QTest::newRow("must-revalidate,304,prefer-cache") - << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << true << false; + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << true << true; QTest::newRow("must-revalidate,304,always-cache") - << reply304 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << QStringList() << true << false; + << reply304 << "" << content << int(QNetworkRequest::AlwaysCache) << QStringList() << false << false; // // Partial content -- cgit v0.12 From 124ec3200f8453142717fcfe7a4aa0a55164aaa6 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Thu, 5 May 2011 10:49:59 +0200 Subject: Ensure that QDateTimeEdit::calendarWidget() will always return a valid widget. This case may be triggered in the (admittedly slightly abnormal) case where a user wishes to embed the calendar widget in a layout or, for whatever reason, do something else that will change its ownership. We work around this by detecting when it is deleted and recreating the widget. This will also have a positive side effect if setCalendarWidget() is called with a widget which is then subsequently deleted, returning the default widget instead of a pointer to (now deleted) memory. Reviewed-by: Denis Dzyubenko Merge-request: 2568 Reviewed-by: Denis Dzyubenko --- src/gui/widgets/qdatetimeedit.cpp | 41 +++++++++++++++++--------- src/gui/widgets/qdatetimeedit_p.h | 10 ++++--- tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp | 23 +++++++++++++++ 3 files changed, 56 insertions(+), 18 deletions(-) diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp index 6337113..a4739a7 100644 --- a/src/gui/widgets/qdatetimeedit.cpp +++ b/src/gui/widgets/qdatetimeedit.cpp @@ -2538,20 +2538,32 @@ void QDateTimeEditPrivate::syncCalendarWidget() } QCalendarPopup::QCalendarPopup(QWidget * parent, QCalendarWidget *cw) - : QWidget(parent, Qt::Popup), calendar(0) + : QWidget(parent, Qt::Popup) { setAttribute(Qt::WA_WindowPropagation); dateChanged = false; if (!cw) { - cw = new QCalendarWidget(this); + verifyCalendarInstance(); + } else { + setCalendarWidget(cw); + } +} + +QCalendarWidget *QCalendarPopup::verifyCalendarInstance() +{ + if (calendar.isNull()) { + QCalendarWidget *cw = new QCalendarWidget(this); cw->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader); #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled()) cw->setHorizontalHeaderFormat(QCalendarWidget::SingleLetterDayNames); #endif + setCalendarWidget(cw); + return cw; + } else { + return calendar.data(); } - setCalendarWidget(cw); } void QCalendarPopup::setCalendarWidget(QCalendarWidget *cw) @@ -2563,28 +2575,29 @@ void QCalendarPopup::setCalendarWidget(QCalendarWidget *cw) widgetLayout->setMargin(0); widgetLayout->setSpacing(0); } - delete calendar; - calendar = cw; - widgetLayout->addWidget(calendar); + delete calendar.data(); + calendar = QWeakPointer(cw); + widgetLayout->addWidget(cw); - connect(calendar, SIGNAL(activated(QDate)), this, SLOT(dateSelected(QDate))); - connect(calendar, SIGNAL(clicked(QDate)), this, SLOT(dateSelected(QDate))); - connect(calendar, SIGNAL(selectionChanged()), this, SLOT(dateSelectionChanged())); + connect(cw, SIGNAL(activated(QDate)), this, SLOT(dateSelected(QDate))); + connect(cw, SIGNAL(clicked(QDate)), this, SLOT(dateSelected(QDate))); + connect(cw, SIGNAL(selectionChanged()), this, SLOT(dateSelectionChanged())); - calendar->setFocus(); + cw->setFocus(); } void QCalendarPopup::setDate(const QDate &date) { oldDate = date; - calendar->setSelectedDate(date); + verifyCalendarInstance()->setSelectedDate(date); } void QCalendarPopup::setDateRange(const QDate &min, const QDate &max) { - calendar->setMinimumDate(min); - calendar->setMaximumDate(max); + QCalendarWidget *cw = verifyCalendarInstance(); + cw->setMinimumDate(min); + cw->setMaximumDate(max); } void QCalendarPopup::mousePressEvent(QMouseEvent *event) @@ -2620,7 +2633,7 @@ bool QCalendarPopup::event(QEvent *event) void QCalendarPopup::dateSelectionChanged() { dateChanged = true; - emit newDateSelected(calendar->selectedDate()); + emit newDateSelected(verifyCalendarInstance()->selectedDate()); } void QCalendarPopup::dateSelected(const QDate &date) { diff --git a/src/gui/widgets/qdatetimeedit_p.h b/src/gui/widgets/qdatetimeedit_p.h index acdc878..c85c0fb 100644 --- a/src/gui/widgets/qdatetimeedit_p.h +++ b/src/gui/widgets/qdatetimeedit_p.h @@ -148,11 +148,11 @@ class QCalendarPopup : public QWidget Q_OBJECT public: QCalendarPopup(QWidget *parent = 0, QCalendarWidget *cw = 0); - QDate selectedDate() { return calendar->selectedDate(); } + QDate selectedDate() { return verifyCalendarInstance()->selectedDate(); } void setDate(const QDate &date); void setDateRange(const QDate &min, const QDate &max); - void setFirstDayOfWeek(Qt::DayOfWeek dow) { calendar->setFirstDayOfWeek(dow); } - QCalendarWidget *calendarWidget() const { return calendar; } + void setFirstDayOfWeek(Qt::DayOfWeek dow) { verifyCalendarInstance()->setFirstDayOfWeek(dow); } + QCalendarWidget *calendarWidget() const { return const_cast(this)->verifyCalendarInstance(); } void setCalendarWidget(QCalendarWidget *cw); Q_SIGNALS: void activated(const QDate &date); @@ -171,7 +171,9 @@ protected: bool event(QEvent *e); private: - QCalendarWidget *calendar; + QCalendarWidget *verifyCalendarInstance(); + + QWeakPointer calendar; QDate oldDate; bool dateChanged; }; diff --git a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp index c8c3b90..9d0c5f7 100644 --- a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp @@ -275,6 +275,8 @@ private slots: void focusNextPrevChild(); void taskQTBUG_12384_timeSpecShowTimeOnly(); + + void deleteCalendarWidget(); private: EditorDateEdit* testWidget; @@ -3438,5 +3440,26 @@ void tst_QDateTimeEdit::taskQTBUG_12384_timeSpecShowTimeOnly() QCOMPARE(edit.time(), time.time()); } +void tst_QDateTimeEdit::deleteCalendarWidget() +{ + { + // setup + QCalendarWidget *cw = 0; + QDateEdit edit; + QVERIFY(!edit.calendarWidget()); + edit.setCalendarPopup(true); + QVERIFY(edit.calendarWidget()); + edit.calendarWidget()->setObjectName("cw1");; + + // delete + cw = edit.calendarWidget(); + delete cw; + + // it should create a new widget + QVERIFY(edit.calendarWidget()); + QVERIFY(edit.calendarWidget()->objectName() != "cw1"); + } +} + QTEST_MAIN(tst_QDateTimeEdit) #include "tst_qdatetimeedit.moc" -- cgit v0.12 From 671fff6071d1064094bf41364b11df3b55e7a65c Mon Sep 17 00:00:00 2001 From: Taito Silvola Date: Thu, 5 May 2011 12:09:32 +0300 Subject: QSslConfiguration documentation fix setPeerVerifyMode() and peerVerifyMode() comments fix Merge-request: 1220 Reviewed-by: Peter Hartmann --- src/network/ssl/qsslconfiguration.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/ssl/qsslconfiguration.cpp b/src/network/ssl/qsslconfiguration.cpp index 70d7dd8..ab4d7f1 100644 --- a/src/network/ssl/qsslconfiguration.cpp +++ b/src/network/ssl/qsslconfiguration.cpp @@ -233,7 +233,7 @@ void QSslConfiguration::setProtocol(QSsl::SslProtocol protocol) client), and whether it should require that this certificate is valid. The default mode is AutoVerifyPeer, which tells QSslSocket to use - VerifyPeer for clients, QueryPeer for clients. + VerifyPeer for clients, QueryPeer for servers. \sa setPeerVerifyMode() */ @@ -249,7 +249,7 @@ QSslSocket::PeerVerifyMode QSslConfiguration::peerVerifyMode() const client), and whether it should require that this certificate is valid. The default mode is AutoVerifyPeer, which tells QSslSocket to use - VerifyPeer for clients, QueryPeer for clients. + VerifyPeer for clients, QueryPeer for servers. \sa peerVerifyMode() */ -- cgit v0.12