summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@nokia.com>2010-07-14 04:06:57 (GMT)
committerLorn Potter <lorn.potter@nokia.com>2010-07-14 04:06:57 (GMT)
commit423e373ed0935ebe3d2f54a4c56101081c3311b5 (patch)
tree35e27c69dee1d96775f4a921e93f5cd2e574a834 /src/gui/text
parenta9b6c59857c28f48e093abccaf9a89755b0995bc (diff)
parent444fa479484f80cbd5de3e9c5fa2b2e4082643dd (diff)
downloadQt-423e373ed0935ebe3d2f54a4c56101081c3311b5.zip
Qt-423e373ed0935ebe3d2f54a4c56101081c3311b5.tar.gz
Qt-423e373ed0935ebe3d2f54a4c56101081c3311b5.tar.bz2
Merge branch '4.7' of ../oslo-staging-1 into 4.7
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfont.cpp9
-rw-r--r--src/gui/text/qfont.h5
-rw-r--r--src/gui/text/qfont_mac.cpp6
-rw-r--r--src/gui/text/qfont_qws.cpp1
-rw-r--r--src/gui/text/qfont_win.cpp5
-rw-r--r--src/gui/text/qfont_x11.cpp9
-rw-r--r--src/gui/text/qfontengine_s60_p.h3
-rw-r--r--src/gui/text/qtextcursor.cpp10
-rw-r--r--src/gui/text/qtextcursor_p.h1
-rw-r--r--src/gui/text/qtextdocument.cpp8
-rw-r--r--src/gui/text/qtextdocument_p.cpp51
-rw-r--r--src/gui/text/qtextdocument_p.h6
-rw-r--r--src/gui/text/qtextengine.cpp4
-rw-r--r--src/gui/text/qtextengine_p.h2
-rw-r--r--src/gui/text/qtextoption.cpp7
-rw-r--r--src/gui/text/qtexttable.cpp28
16 files changed, 116 insertions, 39 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index c229242..3fe98e1 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -1266,6 +1266,15 @@ QFont::StyleHint QFont::styleHint() const
\value OldEnglish the font matcher prefers decorative fonts.
\value Decorative is a synonym for \c OldEnglish.
+ \value Monospace the font matcher prefers fonts that map to the
+ CSS generic font-family 'monospace'.
+
+ \value Fantasy the font matcher prefers fonts that map to the
+ CSS generic font-family 'fantasy'.
+
+ \value Cursive the font matcher prefers fonts that map to the
+ CSS generic font-family 'cursive'.
+
\value System the font matcher prefers system fonts.
*/
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index 6f62424..2cc41e1 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -72,7 +72,10 @@ public:
Courier, TypeWriter = Courier,
OldEnglish, Decorative = OldEnglish,
System,
- AnyStyle
+ AnyStyle,
+ Cursive,
+ Monospace,
+ Fantasy
};
enum StyleStrategy {
diff --git a/src/gui/text/qfont_mac.cpp b/src/gui/text/qfont_mac.cpp
index 93985ab..0bc8ca2 100644
--- a/src/gui/text/qfont_mac.cpp
+++ b/src/gui/text/qfont_mac.cpp
@@ -136,8 +136,14 @@ QString QFont::defaultFamily() const
return QString::fromLatin1("Times New Roman");
case QFont::Courier:
return QString::fromLatin1("Courier New");
+ case QFont::Monospace:
+ return QString::fromLatin1("Courier");
case QFont::Decorative:
return QString::fromLatin1("Bookman Old Style");
+ case QFont::Cursive:
+ return QString::fromLatin1("Apple Chancery");
+ case QFont::Fantasy:
+ return QString::fromLatin1("Papyrus");
case QFont::Helvetica:
case QFont::System:
default:
diff --git a/src/gui/text/qfont_qws.cpp b/src/gui/text/qfont_qws.cpp
index 51af1e1..72f8c37 100644
--- a/src/gui/text/qfont_qws.cpp
+++ b/src/gui/text/qfont_qws.cpp
@@ -108,6 +108,7 @@ QString QFont::defaultFamily() const
case QFont::Times:
return QString::fromLatin1("times");
case QFont::Courier:
+ case QFont::Monospace:
return QString::fromLatin1("courier");
case QFont::Decorative:
return QString::fromLatin1("old english");
diff --git a/src/gui/text/qfont_win.cpp b/src/gui/text/qfont_win.cpp
index a9610f7..fa45ae1 100644
--- a/src/gui/text/qfont_win.cpp
+++ b/src/gui/text/qfont_win.cpp
@@ -148,9 +148,14 @@ QString QFont::defaultFamily() const
case QFont::Times:
return QString::fromLatin1("Times New Roman");
case QFont::Courier:
+ case QFont::Monospace:
return QString::fromLatin1("Courier New");
case QFont::Decorative:
return QString::fromLatin1("Bookman Old Style");
+ case QFont::Cursive:
+ return QString::fromLatin1("Comic Sans MS");
+ case QFont::Fantasy:
+ return QString::fromLatin1("Impact");
case QFont::Helvetica:
return QString::fromLatin1("Arial");
case QFont::System:
diff --git a/src/gui/text/qfont_x11.cpp b/src/gui/text/qfont_x11.cpp
index 39127dc..92e2326 100644
--- a/src/gui/text/qfont_x11.cpp
+++ b/src/gui/text/qfont_x11.cpp
@@ -281,6 +281,15 @@ QString QFont::defaultFamily() const
case QFont::Courier:
return QString::fromLatin1("Courier");
+ case QFont::Monospace:
+ return QString::fromLatin1("Courier New");
+
+ case QFont::Cursive:
+ return QString::fromLatin1("Comic Sans MS");
+
+ case QFont::Fantasy:
+ return QString::fromLatin1("Impact");
+
case QFont::Decorative:
return QString::fromLatin1("Old English");
diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h
index beeb4cc..d65f13b 100644
--- a/src/gui/text/qfontengine_s60_p.h
+++ b/src/gui/text/qfontengine_s60_p.h
@@ -54,7 +54,7 @@
//
#include "qconfig.h"
-#include "qfontengine_p.h"
+#include <private/qfontengine_p.h>
#include "qsize.h"
#include <openfont.h>
@@ -134,6 +134,7 @@ public:
private:
friend class QFontPrivate;
+ friend class QSymbianVGFontGlyphCache;
QFixed glyphAdvance(HB_Glyph glyph) const;
CFont *fontWithSize(qreal size) const;
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index a9caa6b..769ab2f 100644
--- a/src/gui/text/qtextcursor.cpp
+++ b/src/gui/text/qtextcursor.cpp
@@ -64,7 +64,8 @@ enum {
QTextCursorPrivate::QTextCursorPrivate(QTextDocumentPrivate *p)
: priv(p), x(0), position(0), anchor(0), adjusted_anchor(0),
- currentCharFormat(-1), visualNavigation(false), keepPositionOnInsert(false)
+ currentCharFormat(-1), visualNavigation(false), keepPositionOnInsert(false),
+ changed(false)
{
priv->addCursor(this);
}
@@ -80,6 +81,7 @@ QTextCursorPrivate::QTextCursorPrivate(const QTextCursorPrivate &rhs)
currentCharFormat = rhs.currentCharFormat;
visualNavigation = rhs.visualNavigation;
keepPositionOnInsert = rhs.keepPositionOnInsert;
+ changed = rhs.changed;
priv->addCursor(this);
}
@@ -1281,7 +1283,7 @@ void QTextCursor::setVisualNavigation(bool b)
/*!
\since 4.7
- Sets the visual x position for vertical cursor movements.
+ Sets the visual x position for vertical cursor movements to \a x.
The vertical movement x position is cleared automatically when the cursor moves horizontally, and kept
unchanged when the cursor moves vertically. The mechanism allows the cursor to move up and down on a
@@ -1333,8 +1335,8 @@ bool QTextCursor::keepPositionOnInsert() const
Defines whether the cursor should keep its current position when text gets inserted at the current position of the
cursor.
- If \b is true, the cursor keeps its current position when text gets inserted at the positing of the cursor.
- If \b is false, the cursor moves along with the inserted text.
+ If \a b is true, the cursor keeps its current position when text gets inserted at the positing of the cursor.
+ If \a b is false, the cursor moves along with the inserted text.
The default is false.
diff --git a/src/gui/text/qtextcursor_p.h b/src/gui/text/qtextcursor_p.h
index 4e36b95..4b3262f 100644
--- a/src/gui/text/qtextcursor_p.h
+++ b/src/gui/text/qtextcursor_p.h
@@ -114,6 +114,7 @@ public:
int currentCharFormat;
uint visualNavigation : 1;
uint keepPositionOnInsert : 1;
+ uint changed : 1;
};
QT_END_NAMESPACE
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index e0386f1..195dc28 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -583,11 +583,11 @@ void QTextDocument::setDefaultTextOption(const QTextOption &option)
void QTextDocument::markContentsDirty(int from, int length)
{
Q_D(QTextDocument);
- if (!d->inContentsChange)
- d->beginEditBlock();
d->documentChange(from, length);
- if (!d->inContentsChange)
- d->endEditBlock();
+ if (!d->inContentsChange) {
+ d->lout->documentChanged(d->docChangeFrom, d->docChangeOldLength, d->docChangeLength);
+ d->docChangeFrom = -1;
+ }
}
/*!
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index f3cd481..7b3f985 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -205,6 +205,7 @@ QTextDocumentPrivate::QTextDocumentPrivate()
undoEnabled = true;
inContentsChange = false;
+ blockCursorAdjustment = false;
defaultTextOption.setTabStop(80); // same as in qtextengine.cpp
defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
@@ -234,17 +235,17 @@ void QTextDocumentPrivate::init()
void QTextDocumentPrivate::clear()
{
Q_Q(QTextDocument);
- for (int i = 0; i < cursors.count(); ++i) {
- cursors.at(i)->setPosition(0);
- cursors.at(i)->currentCharFormat = -1;
- cursors.at(i)->anchor = 0;
- cursors.at(i)->adjusted_anchor = 0;
+
+ foreach (QTextCursorPrivate *curs, cursors) {
+ curs->setPosition(0);
+ curs->currentCharFormat = -1;
+ curs->anchor = 0;
+ curs->adjusted_anchor = 0;
}
QList<QTextCursorPrivate *>oldCursors = cursors;
QT_TRY{
cursors.clear();
- changedCursors.clear();
QMap<int, QTextObject *>::Iterator objectIt = objects.begin();
while (objectIt != objects.end()) {
@@ -287,8 +288,8 @@ void QTextDocumentPrivate::clear()
QTextDocumentPrivate::~QTextDocumentPrivate()
{
- for (int i = 0; i < cursors.count(); ++i)
- cursors.at(i)->priv = 0;
+ foreach (QTextCursorPrivate *curs, cursors)
+ curs->priv = 0;
cursors.clear();
undoState = 0;
undoEnabled = true;
@@ -669,7 +670,14 @@ void QTextDocumentPrivate::remove(int pos, int length, QTextUndoCommand::Operati
{
if (length == 0)
return;
+ blockCursorAdjustment = true;
move(pos, -1, length, op);
+ blockCursorAdjustment = false;
+ foreach (QTextCursorPrivate *curs, cursors) {
+ if (curs->adjustPosition(pos, -length, op) == QTextCursorPrivate::CursorMoved) {
+ curs->changed = true;
+ }
+ }
}
void QTextDocumentPrivate::setCharFormat(int pos, int length, const QTextCharFormat &newFormat, FormatChangeMode mode)
@@ -1221,10 +1229,15 @@ void QTextDocumentPrivate::finishEdit()
}
}
- while (!changedCursors.isEmpty()) {
- QTextCursorPrivate *curs = changedCursors.takeFirst();
- emit q->cursorPositionChanged(QTextCursor(curs));
+ QList<QTextCursor> changedCursors;
+ foreach (QTextCursorPrivate *curs, cursors) {
+ if (curs->changed) {
+ curs->changed = false;
+ changedCursors.append(QTextCursor(curs));
+ }
}
+ foreach (const QTextCursor &cursor, changedCursors)
+ emit q->cursorPositionChanged(cursor);
contentsChanged();
@@ -1266,11 +1279,13 @@ void QTextDocumentPrivate::adjustDocumentChangesAndCursors(int from, int addedOr
if (!editBlock)
++revision;
- for (int i = 0; i < cursors.size(); ++i) {
- QTextCursorPrivate *curs = cursors.at(i);
- if (curs->adjustPosition(from, addedOrRemoved, op) == QTextCursorPrivate::CursorMoved) {
- if (!changedCursors.contains(curs))
- changedCursors.append(curs);
+ if (blockCursorAdjustment) {
+ ; // postpone, will be called again from QTextDocumentPrivate::remove()
+ } else {
+ foreach (QTextCursorPrivate *curs, cursors) {
+ if (curs->adjustPosition(from, addedOrRemoved, op) == QTextCursorPrivate::CursorMoved) {
+ curs->changed = true;
+ }
}
}
@@ -1693,8 +1708,8 @@ bool QTextDocumentPrivate::ensureMaximumBlockCount()
void QTextDocumentPrivate::aboutToRemoveCell(int from, int to)
{
Q_ASSERT(from <= to);
- for (int i = 0; i < cursors.size(); ++i)
- cursors.at(i)->aboutToRemoveCell(from, to);
+ foreach (QTextCursorPrivate *curs, cursors)
+ curs->aboutToRemoveCell(from, to);
}
QT_END_NAMESPACE
diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h
index d1bd698..b46d01c 100644
--- a/src/gui/text/qtextdocument_p.h
+++ b/src/gui/text/qtextdocument_p.h
@@ -277,7 +277,7 @@ public:
void documentChange(int from, int length);
inline void addCursor(QTextCursorPrivate *c) { cursors.append(c); }
- inline void removeCursor(QTextCursorPrivate *c) { cursors.removeAll(c); changedCursors.removeAll(c); }
+ inline void removeCursor(QTextCursorPrivate *c) { cursors.removeAll(c); }
QTextFrame *frameAt(int pos) const;
QTextFrame *rootFrame() const;
@@ -329,8 +329,7 @@ private:
BlockMap blocks;
int initialBlockCharFormatIndex;
- QList<QTextCursorPrivate*> cursors;
- QList<QTextCursorPrivate*> changedCursors;
+ QList<QTextCursorPrivate *> cursors;
QMap<int, QTextObject *> objects;
QMap<QUrl, QVariant> resources;
QMap<QUrl, QVariant> cachedResources;
@@ -346,6 +345,7 @@ public:
int maximumBlockCount;
uint needsEnsureMaximumBlockCount : 1;
uint inContentsChange : 1;
+ uint blockCursorAdjustment : 1;
QSizeF pageSize;
QString title;
QString url;
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 60195a8..439f2a4 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -2668,9 +2668,9 @@ QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFo
flags |= QTextItem::StrikeOut;
}
-QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, QFontEngine *fe)
+QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars_, int numChars, QFontEngine *fe)
: flags(0), justified(false), underlineStyle(QTextCharFormat::NoUnderline),
- num_chars(0), chars(0), logClusters(0), f(font), glyphs(g), fontEngine(fe)
+ num_chars(numChars), chars(chars_), logClusters(0), f(font), glyphs(g), fontEngine(fe)
{
}
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 908a0ec..e623fa5 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -311,7 +311,7 @@ public:
logClusters(0), f(0), fontEngine(0)
{}
QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFormat &format = QTextCharFormat());
- QTextItemInt(const QGlyphLayout &g, QFont *font, QFontEngine *fe);
+ QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars, int numChars, QFontEngine *fe);
/// copy the structure items, adjusting the glyphs arrays to the right subarrays.
/// the width of the returned QTextItemInt is not adjusted, for speed reasons
diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp
index 8f31e46..9eeec0b 100644
--- a/src/gui/text/qtextoption.cpp
+++ b/src/gui/text/qtextoption.cpp
@@ -392,7 +392,12 @@ QList<QTextOption::Tab> QTextOption::tabs() const
/*!
\fn Tab::Tab(qreal pos, TabType tabType, QChar delim = QChar())
- Creates a tab with the given position, tab type, and (for DelimiterTab) delimiter
+
+ Creates a tab with the given position, tab type, and delimiter
+ (\a pos, \a tabType, \a delim).
+
+ \note \a delim is only used when \a tabType is DelimiterTab.
+
\since 4.7
*/
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp
index 5100176..e3985ce 100644
--- a/src/gui/text/qtexttable.cpp
+++ b/src/gui/text/qtexttable.cpp
@@ -754,19 +754,39 @@ void QTextTable::insertColumns(int pos, int num)
QTextFormatCollection *c = p->formatCollection();
p->beginEditBlock();
+ QList<int> extendedSpans;
for (int i = 0; i < d->nRows; ++i) {
int cell;
if (i == d->nRows - 1 && pos == d->nCols)
cell = d->fragment_end;
else
cell = d->grid[i*d->nCols + pos];
- QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell);
- QTextCharFormat fmt = c->charFormat(it->format);
if (pos > 0 && pos < d->nCols && cell == d->grid[i*d->nCols + pos - 1]) {
// cell spans the insertion place, extend it
- fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num);
- p->setCharFormat(it.position(), 1, fmt);
+ if (!extendedSpans.contains(cell)) {
+ QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell);
+ QTextCharFormat fmt = c->charFormat(it->format);
+ fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num);
+ p->setCharFormat(it.position(), 1, fmt);
+ d->dirty = true;
+ extendedSpans << cell;
+ }
} else {
+ /* If the next cell is spanned from the row above, we need to find the right position
+ to insert to */
+ if (i > 0 && pos < d->nCols && cell == d->grid[(i-1) * d->nCols + pos]) {
+ int gridIndex = i*d->nCols + pos;
+ const int gridEnd = d->nRows * d->nCols - 1;
+ while (gridIndex < gridEnd && cell == d->grid[gridIndex]) {
+ ++gridIndex;
+ }
+ if (gridIndex == gridEnd)
+ cell = d->fragment_end;
+ else
+ cell = d->grid[gridIndex];
+ }
+ QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell);
+ QTextCharFormat fmt = c->charFormat(it->format);
fmt.setTableCellRowSpan(1);
fmt.setTableCellColumnSpan(1);
Q_ASSERT(fmt.objectIndex() == objectIndex());