summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-08-03 11:37:04 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-08-03 11:37:04 (GMT)
commita6633a9cf1bb2083d0ce41f4667b3f9349a39865 (patch)
treef26b48a5c03e22fe96cdbf50f93fefb4c202e594 /src
parentd4da5248006e4a9f4d6a454bf754407a34a09407 (diff)
parent794c7c77f28bb530db017cc25a5e33e00933253b (diff)
downloadQt-a6633a9cf1bb2083d0ce41f4667b3f9349a39865.zip
Qt-a6633a9cf1bb2083d0ce41f4667b3f9349a39865.tar.gz
Qt-a6633a9cf1bb2083d0ce41f4667b3f9349a39865.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Fix the issue of resizing a window with the Add QTextFragment::glyphs() accessor
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm18
-rw-r--r--src/gui/text/qtextlayout.cpp15
-rw-r--r--src/gui/text/qtextlayout.h3
-rw-r--r--src/gui/text/qtextobject.cpp29
-rw-r--r--src/gui/text/qtextobject.h3
5 files changed, 62 insertions, 6 deletions
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 5780ebc..3229e71 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -532,9 +532,23 @@ static int qCocoaViewCount = 0;
if (!qwidget)
return;
+ // We use a different graphics system.
if (QApplicationPrivate::graphicsSystem() != 0) {
- qwidget->update(qwidget->rect());
- qwidgetprivate->syncBackingStore(qwidget->rect());
+
+ // Qt handles the painting occuring inside the window.
+ // Cocoa also keeps track of all widgets as NSView and therefore might
+ // ask for a repainting of a widget even if Qt is already taking care of it.
+ //
+ // The only valid reason for Cocoa to call drawRect: is for window manipulation
+ // (ie. resize, ...).
+ //
+ // Qt will then forward the update to the children.
+ if (qwidget->isWindow()) {
+ qwidget->update(qwidget->rect());
+ qwidgetprivate->syncBackingStore(qwidget->rect());
+ }
+
+ // Since we don't want to use the native engine, we must exit.
return;
}
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index aff88f6..531e46b 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1134,7 +1134,7 @@ QList<QGlyphs> QTextLayout::glyphs() const
{
QList<QGlyphs> glyphs;
for (int i=0; i<d->lines.size(); ++i)
- glyphs += QTextLine(i, d).glyphs();
+ glyphs += QTextLine(i, d).glyphs(-1, -1);
return glyphs;
}
@@ -2198,13 +2198,16 @@ namespace {
/*!
\internal
- Returns the glyph indexes and positions for all glyphs in this QTextLine.
+ Returns the glyph indexes and positions for all glyphs in this QTextLine which reside in
+ QScriptItems that overlap with the range defined by \a from and \a length. The arguments
+ specify characters, relative to the text in the layout. Note that it is not possible to
+ use this function to retrieve a subset of the glyphs in a QScriptItem.
\since 4.8
\sa QTextLayout::glyphs()
*/
-QList<QGlyphs> QTextLine::glyphs() const
+QList<QGlyphs> QTextLine::glyphs(int from, int length) const
{
const QScriptLine &line = eng->lines[i];
@@ -2217,7 +2220,13 @@ QList<QGlyphs> QTextLine::glyphs() const
qreal y = line.y.toReal() + line.base().toReal();
while (!iterator.atEnd()) {
QScriptItem &si = iterator.next();
+ if (si.analysis.flags >= QScriptAnalysis::TabOrObject)
+ continue;
+
QPointF pos(iterator.x.toReal(), y);
+ if (from >= 0 && length >= 0 &&
+ (from >= si.position + eng->length(&si) || from + length <= si.position))
+ continue;
QFont font = eng->font(si);
diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h
index f6aaf22..32d6d0e 100644
--- a/src/gui/text/qtextlayout.h
+++ b/src/gui/text/qtextlayout.h
@@ -239,9 +239,10 @@ public:
private:
QTextLine(int line, QTextEngine *e) : i(line), eng(e) {}
void layout_helper(int numGlyphs);
- QList<QGlyphs> glyphs() const;
+ QList<QGlyphs> glyphs(int from, int length) const;
friend class QTextLayout;
+ friend class QTextFragment;
int i;
QTextEngine *eng;
};
diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp
index 5fb3384..e366f77 100644
--- a/src/gui/text/qtextobject.cpp
+++ b/src/gui/text/qtextobject.cpp
@@ -1650,6 +1650,35 @@ QTextBlock::iterator &QTextBlock::iterator::operator--()
than the \a other text fragment; otherwise returns false.
*/
+/*!
+ Returns the glyphs of this text fragment. The positions of the glyphs are
+ relative to the position of the QTextBlock's layout.
+
+ \sa QGlyphs, QTextBlock::layout(), QTextLayout::position(), QPainter::drawGlyphs()
+*/
+QList<QGlyphs> QTextFragment::glyphs() const
+{
+ if (!p || !n)
+ return QList<QGlyphs>();
+
+ int pos = position();
+ int len = length();
+ if (len == 0)
+ return QList<QGlyphs>();
+
+ int blockNode = p->blockMap().findNode(pos);
+
+ const QTextBlockData *blockData = p->blockMap().fragment(blockNode);
+ QTextLayout *layout = blockData->layout;
+
+ QList<QGlyphs> ret;
+ for (int i=0; i<layout->lineCount(); ++i) {
+ QTextLine textLine = layout->lineAt(i);
+ ret += textLine.glyphs(pos, len);
+ }
+
+ return ret;
+}
/*!
Returns the position of this text fragment in the document.
diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h
index a573a26..332458d 100644
--- a/src/gui/text/qtextobject.h
+++ b/src/gui/text/qtextobject.h
@@ -44,6 +44,7 @@
#include <QtCore/qobject.h>
#include <QtGui/qtextformat.h>
+#include <QtGui/qglyphs.h>
QT_BEGIN_HEADER
@@ -315,6 +316,8 @@ public:
int charFormatIndex() const;
QString text() const;
+ QList<QGlyphs> glyphs() const;
+
private:
const QTextDocumentPrivate *p;
int n;