summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-10-22 09:18:02 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-10-22 09:18:02 (GMT)
commit4f3c09be1c736d2d39c8266138dc4519f79fff29 (patch)
tree3d4a0ccba9cabf3e6a5fda58d9ad5dce1b67b30d
parent19c60da9c15dc609d6d07c687a59d9c2c1a4da13 (diff)
parentd4a136dc3f1176665c19eec24fa43f40e5180a89 (diff)
downloadQt-4f3c09be1c736d2d39c8266138dc4519f79fff29.zip
Qt-4f3c09be1c736d2d39c8266138dc4519f79fff29.tar.gz
Qt-4f3c09be1c736d2d39c8266138dc4519f79fff29.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt into 4.6-WM_NULL-driven
-rw-r--r--src/gui/text/qfontengine_win.cpp91
-rw-r--r--tests/auto/auto.pro1
-rw-r--r--tests/auto/linguist/lrelease/testdata/idbased.ts7
-rw-r--r--tests/auto/qdom/tst_qdom.cpp1
-rw-r--r--tools/linguist/lupdate/main.cpp2
-rw-r--r--tools/linguist/shared/qm.cpp9
-rw-r--r--tools/linguist/shared/translatormessage.cpp8
7 files changed, 38 insertions, 81 deletions
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index cc555a3..d781c70 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -125,6 +125,7 @@ HDC shared_dc()
}
#endif
+#ifndef Q_WS_WINCE
typedef BOOL (WINAPI *PtrGetCharWidthI)(HDC, UINT, UINT, LPWORD, LPINT);
static PtrGetCharWidthI ptrGetCharWidthI = 0;
static bool resolvedGetCharWidthI = false;
@@ -136,6 +137,7 @@ static void resolveGetCharWidthI()
resolvedGetCharWidthI = true;
ptrGetCharWidthI = (PtrGetCharWidthI)QLibrary::resolve(QLatin1String("gdi32"), "GetCharWidthI");
}
+#endif // !defined(Q_WS_WINCE)
// defined in qtextengine_win.cpp
typedef void *SCRIPT_CACHE;
@@ -340,8 +342,10 @@ QFontEngineWin::QFontEngineWin(const QString &name, HFONT _hfont, bool stockFont
designAdvances = 0;
designAdvancesSize = 0;
+#ifndef Q_WS_WINCE
if (!resolvedGetCharWidthI)
resolveGetCharWidthI();
+#endif
}
QFontEngineWin::~QFontEngineWin()
@@ -381,80 +385,18 @@ bool QFontEngineWin::stringToCMap(const QChar *str, int len, QGlyphLayout *glyph
if (flags & QTextEngine::GlyphIndicesOnly)
return true;
-#if defined(Q_WS_WINCE)
- HDC hdc = shared_dc();
- if (flags & QTextEngine::DesignMetrics) {
- HGDIOBJ oldFont = 0;
- int glyph_pos = 0;
- for(register int i = 0; i < len; i++) {
- bool surrogate = (str[i].unicode() >= 0xd800 && str[i].unicode() < 0xdc00 && i < len-1
- && str[i+1].unicode() >= 0xdc00 && str[i+1].unicode() < 0xe000);
- unsigned int glyph = glyphs->glyphs[glyph_pos];
- if(int(glyph) >= designAdvancesSize) {
- int newSize = (glyph + 256) >> 8 << 8;
- designAdvances = q_check_ptr((QFixed *)realloc(designAdvances, newSize*sizeof(QFixed)));
- for(int i = designAdvancesSize; i < newSize; ++i)
- designAdvances[i] = -1000000;
- designAdvancesSize = newSize;
- }
- if(designAdvances[glyph] < -999999) {
- if(!oldFont)
- oldFont = selectDesignFont();
- SIZE size = {0, 0};
- GetTextExtentPoint32(hdc, (wchar_t *)(str+i), surrogate ? 2 : 1, &size);
- designAdvances[glyph] = QFixed((int)size.cx)/designToDevice;
- }
- glyphs->advances_x[glyph_pos] = designAdvances[glyph];
- glyphs->advances_y[glyph_pos] = 0;
- if (surrogate)
- ++i;
- ++glyph_pos;
- }
- if(oldFont)
- DeleteObject(SelectObject(hdc, oldFont));
- } else {
- int glyph_pos = 0;
- HGDIOBJ oldFont = 0;
-
- for(register int i = 0; i < len; i++) {
- bool surrogate = (str[i].unicode() >= 0xd800 && str[i].unicode() < 0xdc00 && i < len-1
- && str[i+1].unicode() >= 0xdc00 && str[i+1].unicode() < 0xe000);
- unsigned int glyph = glyphs->glyphs[glyph_pos];
-
- glyphs->advances_y[glyph_pos] = 0;
-
- if (glyph >= widthCacheSize) {
- int newSize = (glyph + 256) >> 8 << 8;
- widthCache = q_check_ptr((unsigned char *)realloc(widthCache,
- newSize*sizeof(QFixed)));
- memset(widthCache + widthCacheSize, 0, newSize - widthCacheSize);
- widthCacheSize = newSize;
- }
- glyphs->advances_x[glyph_pos] = widthCache[glyph];
- // font-width cache failed
- if (glyphs->advances_x[glyph_pos] == 0) {
- SIZE size = {0, 0};
- if (!oldFont)
- oldFont = SelectObject(hdc, hfont);
- GetTextExtentPoint32(hdc, (wchar_t *)str + i, surrogate ? 2 : 1, &size);
- glyphs->advances_x[glyph_pos] = size.cx;
- // if glyph's within cache range, store it for later
- if (size.cx > 0 && size.cx < 0x100)
- widthCache[glyph] = size.cx;
- }
-
- if (surrogate)
- ++i;
- ++glyph_pos;
- }
+ recalcAdvances(glyphs, flags);
+ return true;
+}
- if (oldFont)
- SelectObject(hdc, oldFont);
- }
+inline void calculateTTFGlyphWidth(HDC hdc, UINT glyph, int &width)
+{
+#if defined(Q_WS_WINCE)
+ GetCharWidth32(hdc, glyph, glyph, &width);
#else
- recalcAdvances(glyphs, flags);
+ if (ptrGetCharWidthI)
+ ptrGetCharWidthI(hdc, glyph, 1, 0, &width);
#endif
- return true;
}
void QFontEngineWin::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
@@ -477,8 +419,7 @@ void QFontEngineWin::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFla
oldFont = selectDesignFont();
int width = 0;
- if (ptrGetCharWidthI)
- ptrGetCharWidthI(hdc, glyph, 1, 0, &width);
+ calculateTTFGlyphWidth(hdc, glyph, width);
designAdvances[glyph] = QFixed(width) / designToDevice;
}
glyphs->advances_x[i] = designAdvances[glyph];
@@ -517,8 +458,8 @@ void QFontEngineWin::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFla
SIZE size = {0, 0};
GetTextExtentPoint32(hdc, (wchar_t *)ch, chrLen, &size);
width = size.cx;
- } else if (ptrGetCharWidthI) {
- ptrGetCharWidthI(hdc, glyph, 1, 0, &width);
+ } else {
+ calculateTTFGlyphWidth(hdc, glyph, width);
}
glyphs->advances_x[i] = width;
// if glyph's within cache range, store it for later
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 8e3ce81..0f7a7f1 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -127,6 +127,7 @@ SUBDIRS += \
qexplicitlyshareddatapointer \
qfile \
qfiledialog \
+ qfiledialog2 \
qfileinfo \
qfilesystemwatcher \
qfilesystemmodel \
diff --git a/tests/auto/linguist/lrelease/testdata/idbased.ts b/tests/auto/linguist/lrelease/testdata/idbased.ts
index 61497de..c7555c8 100644
--- a/tests/auto/linguist/lrelease/testdata/idbased.ts
+++ b/tests/auto/linguist/lrelease/testdata/idbased.ts
@@ -9,6 +9,7 @@
</message>
<message id="untranslated_id">
<source>This has no translation.</source>
+ <translation type="unfinished"></translation>
</message>
<message id="this_another_id">
<source>Foo bar.</source>
@@ -17,5 +18,11 @@
<message>
<source>Drop me!</source>
</message>
+ <message id="one_id">
+ <source></source>
+ </message>
+ <message id="two_id">
+ <source></source>
+ </message>
</context>
</TS>
diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp
index 6637202..0d58554e 100644
--- a/tests/auto/qdom/tst_qdom.cpp
+++ b/tests/auto/qdom/tst_qdom.cpp
@@ -322,6 +322,7 @@ void tst_QDom::toString_01_data()
*/
void tst_QDom::toString_01()
{
+ QFAIL("make test fail instead of timing out, will be fixed later (QT-2357)");
QFETCH(QString, fileName);
QFile f(fileName);
diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp
index 6b554e0..bdaec4f 100644
--- a/tools/linguist/lupdate/main.cpp
+++ b/tools/linguist/lupdate/main.cpp
@@ -160,6 +160,8 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil
tor.setCodecName(codecForTr);
if (!targetLanguage.isEmpty())
tor.setLanguageCode(targetLanguage);
+ else
+ tor.setLanguageCode(Translator::guessLanguageCodeFromFileName(fileName));
if (!sourceLanguage.isEmpty())
tor.setSourceLanguageCode(sourceLanguage);
}
diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp
index fefe91c..317a07e 100644
--- a/tools/linguist/shared/qm.cpp
+++ b/tools/linguist/shared/qm.cpp
@@ -440,9 +440,10 @@ void Releaser::insert(const TranslatorMessage &message, bool forceComment)
void Releaser::insertIdBased(const TranslatorMessage &message)
{
QStringList tlns = message.translations();
- for (int i = 0; i < tlns.size(); ++i)
- if (tlns.at(i).isEmpty())
- tlns[i] = message.sourceText();
+ if (message.type() == TranslatorMessage::Unfinished)
+ for (int i = 0; i < tlns.size(); ++i)
+ if (tlns.at(i).isEmpty())
+ tlns[i] = message.sourceText();
ByteTranslatorMessage bmsg("", originalBytes(message.id(), false), "", tlns);
m_messages.insert(bmsg, 0);
}
@@ -713,7 +714,7 @@ static bool saveQM(const Translator &translator, QIODevice &dev, ConversionData
continue;
}
if (typ == TranslatorMessage::Unfinished) {
- if (msg.translation().isEmpty()) {
+ if (!cd.m_idBased && msg.translation().isEmpty()) {
++untranslated;
continue;
} else {
diff --git a/tools/linguist/shared/translatormessage.cpp b/tools/linguist/shared/translatormessage.cpp
index 417f6b1..db6f333 100644
--- a/tools/linguist/shared/translatormessage.cpp
+++ b/tools/linguist/shared/translatormessage.cpp
@@ -151,6 +151,7 @@ bool TranslatorMessage::operator==(const TranslatorMessage& m) const
return (m_context == m.m_context)
&& m_sourcetext == m.m_sourcetext
&& m_extra[msgIdPlural] == m.m_extra[msgIdPlural]
+ && m_id == m.m_id
&& (m_sourcetext.isEmpty() || m_comment == m.m_comment);
}
@@ -161,7 +162,9 @@ bool TranslatorMessage::operator<(const TranslatorMessage& m) const
return m_context < m.m_context;
if (m_sourcetext != m.m_sourcetext)
return m_sourcetext < m.m_sourcetext;
- return m_comment < m.m_comment;
+ if (m_comment != m.m_comment)
+ return m_comment < m.m_comment;
+ return m_id < m.m_id;
}
int qHash(const TranslatorMessage &msg)
@@ -170,7 +173,8 @@ int qHash(const TranslatorMessage &msg)
qHash(msg.context()) ^
qHash(msg.sourceText()) ^
qHash(msg.extra(QLatin1String("po-msgid_plural"))) ^
- qHash(msg.comment());
+ qHash(msg.comment()) ^
+ qHash(msg.id());
}
bool TranslatorMessage::hasExtra(const QString &key) const