summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2012-02-29 09:18:59 +1000
committerRohan McGovern <rohan.mcgovern@nokia.com>2012-02-29 09:23:14 +1000
commit98dd1781d9256f68025d2a2db408f4f5947f3214 (patch)
treedbe1424abd90014edb5546c920ca585ed62b46e3 /src/gui/text
parent6c1bdc1854a7700c2b3a345b95f6a2fdca84037d (diff)
parentfa1b9070af66edb81b2a3735c1951f78b22bd666 (diff)
Merge master -> api_changes
Includes fixes for tst_qfiledialog2, tst_qtextedit autotests on mac. Change-Id: I49cac26894d31291a8339ccc1eb80b6a940f0827
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.cpp2
-rw-r--r--src/gui/text/qcssparser.cpp40
-rw-r--r--src/gui/text/qcssparser_p.h21
-rw-r--r--src/gui/text/qtextengine.cpp17
4 files changed, 50 insertions, 30 deletions
diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp
index 7bf2a631ea..86de48b1dc 100644
--- a/src/gui/text/qabstracttextdocumentlayout.cpp
+++ b/src/gui/text/qabstracttextdocumentlayout.cpp
@@ -239,7 +239,7 @@ QT_BEGIN_NAMESPACE
/*!
\fn int QAbstractTextDocumentLayout::hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const
- Returns the cursor postion for the given \a point with the specified
+ Returns the cursor position for the given \a point with the specified
\a accuracy. Returns -1 if no valid cursor position was found.
*/
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 38070458b7..fd01934eae 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -1272,11 +1272,9 @@ void ValueExtractor::extractFont()
extractFont(&f, &dummy);
}
-bool ValueExtractor::extractImage(QIcon *icon, Qt::Alignment *a, QSize *size)
+bool ValueExtractor::extractImage(QCss::IconValue *icon, Qt::Alignment *a, QSize *size)
{
bool hit = false;
-#if 0
- // ### Qt5
for (int i = 0; i < declarations.count(); ++i) {
const Declaration &decl = declarations.at(i);
switch (decl.d->propertyId) {
@@ -1297,7 +1295,6 @@ bool ValueExtractor::extractImage(QIcon *icon, Qt::Alignment *a, QSize *size)
}
hit = true;
}
-#endif
return hit;
}
@@ -1646,30 +1643,27 @@ void Declaration::borderImageValue(QString *image, int *cuts,
*h = *v;
}
-#if 0
-// ### Qt 5
-QIcon Declaration::iconValue() const
+IconValue Declaration::iconValue() const
{
if (d->parsed.isValid())
- return qvariant_cast<QIcon>(d->parsed);
+ return qvariant_cast<IconValue>(d->parsed);
- QIcon icon;
+ IconValue icon;
for (int i = 0; i < d->values.count();) {
const Value &value = d->values.at(i++);
if (value.type != Value::Uri)
break;
- QString uri = value.variant.toString();
- QIcon::Mode mode = QIcon::Normal;
- QIcon::State state = QIcon::Off;
+ IconValue::IconEntry entry;
+ entry.uri = value.variant.toString();
for (int j = 0; j < 2; j++) {
if (i != d->values.count() && d->values.at(i).type == Value::KnownIdentifier) {
switch (d->values.at(i).variant.toInt()) {
- case Value_Disabled: mode = QIcon::Disabled; break;
- case Value_Active: mode = QIcon::Active; break;
- case Value_Selected: mode = QIcon::Selected; break;
- case Value_Normal: mode = QIcon::Normal; break;
- case Value_On: state = QIcon::On; break;
- case Value_Off: state = QIcon::Off; break;
+ case Value_Disabled: entry.mode = IconValue::Disabled; break;
+ case Value_Active: entry.mode = IconValue::Active; break;
+ case Value_Selected: entry.mode = IconValue::Selected; break;
+ case Value_Normal: entry.mode = IconValue::Normal; break;
+ case Value_On: entry.state = IconValue::On; break;
+ case Value_Off: entry.state = IconValue::Off; break;
default: break;
}
++i;
@@ -1677,12 +1671,7 @@ QIcon Declaration::iconValue() const
break;
}
}
-
- // QIcon is soo broken
- if (icon.isNull())
- icon = QIcon(uri);
- else
- icon.addPixmap(uri, mode, state);
+ icon.entries.push_back(entry);
if (i == d->values.count())
break;
@@ -1691,10 +1680,9 @@ QIcon Declaration::iconValue() const
i++;
}
- d->parsed = QVariant::fromValue<QIcon>(icon);
+ d->parsed = QVariant::fromValue<QCss::IconValue>(icon);
return icon;
}
-#endif
///////////////////////////////////////////////////////////////////////////////
// Selector
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h
index d50b87dcd5..b19fd8326e 100644
--- a/src/gui/text/qcssparser_p.h
+++ b/src/gui/text/qcssparser_p.h
@@ -411,6 +411,22 @@ struct BorderData {
BrushData color;
};
+struct Q_GUI_EXPORT IconValue
+{
+ enum Mode { Normal, Disabled, Active, Selected }; // In sync with QIcon.
+ enum State { On, Off };
+
+ struct Q_GUI_EXPORT IconEntry
+ {
+ IconEntry() : mode(Normal) , state(On) {}
+
+ Mode mode;
+ State state;
+ QString uri;
+ };
+
+ QList<IconEntry> entries;
+};
// 1. StyleRule - x:hover, y:clicked > z:checked { prop1: value1; prop2: value2; }
// 2. QVector<Selector> - x:hover, y:clicked z:checked
@@ -455,7 +471,7 @@ struct Q_GUI_EXPORT Declaration
QSize sizeValue() const;
QRect rectValue() const;
QString uriValue() const;
-// QIcon iconValue() const;
+ IconValue iconValue() const;
void borderImageValue(QString *image, int *cuts, TileMode *h, TileMode *v) const;
};
@@ -582,7 +598,7 @@ struct Q_GUI_EXPORT ValueExtractor
bool extractOutline(int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii, int *offsets);
bool extractPalette(QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg);
int extractStyleFeatures();
- bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size);
+ bool extractImage(QCss::IconValue *icon, Qt::Alignment *a, QSize *size);
int lengthValue(const Declaration &decl);
@@ -842,6 +858,7 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE( QCss::BackgroundData )
Q_DECLARE_METATYPE( QCss::LengthData )
Q_DECLARE_METATYPE( QCss::BorderData )
+Q_DECLARE_METATYPE( QCss::IconValue )
#endif // QT_NO_CSSPARSER
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index bc7f4f7ad6..c63f0fede8 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -115,7 +115,20 @@ private:
return;
const int end = start + length;
for (int i = start + 1; i < end; ++i) {
- if ((m_analysis[i] == m_analysis[start])
+ // According to the unicode spec we should be treating characters in the Common script
+ // (punctuation, spaces, etc) as being the same script as the surrounding text for the
+ // purpose of splitting up text. This is important because, for example, a fullstop
+ // (0x2E) can be used to indicate an abbreviation and so must be treated as part of a
+ // word. Thus it must be passed along with the word in languages that have to calculate
+ // word breaks. For example the thai word "ครม." has no word breaks but the word "ครม"
+ // does.
+ // Unfortuntely because we split up the strings for both wordwrapping and for setting
+ // the font and because Japanese and Chinese are also aliases of the script "Common",
+ // doing this would break too many things. So instead we only pass the full stop
+ // along, and nothing else.
+ if (m_analysis[i].bidiLevel == m_analysis[start].bidiLevel
+ && m_analysis[i].flags == m_analysis[start].flags
+ && (m_analysis[i].script == m_analysis[start].script || m_string[i] == QLatin1Char('.'))
&& m_analysis[i].flags < QScriptAnalysis::SpaceTabOrObject
&& i - start < MaxItemLength)
continue;
@@ -2689,6 +2702,8 @@ int QTextEngine::positionInLigature(const QScriptItem *si, int end,
QFixed glyphWidth = glyphs.effectiveAdvance(glyph_pos);
// the approximate width of each individual element of the ligature
QFixed perItemWidth = glyphWidth / clusterLength;
+ if (perItemWidth <= 0)
+ return si->position + clusterStart;
QFixed left = x > edge ? edge : edge - glyphWidth;
int n = ((x - left) / perItemWidth).floor().toInt();
QFixed dist = x - left - n * perItemWidth;