diff options
-rw-r--r-- | src/declarative/fx/qfxpainteditem.cpp | 3 | ||||
-rw-r--r-- | src/declarative/fx/qfxtextedit.cpp | 5 | ||||
-rw-r--r-- | src/declarative/fx/qfxtextinput.cpp | 17 |
3 files changed, 16 insertions, 9 deletions
diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index 5471e1b..85924e0 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -101,7 +101,7 @@ void QFxPaintedItem::dirtyCache(const QRect& rect) QFxPaintedItemPrivate::ImageCacheItem *c = d->imagecache[i]; QRect isect = (c->area & rect) | c->dirty; if (isect == c->area && !inpaint) { - d->imagecache.removeAt(i); + delete d->imagecache.takeAt(i); } else { c->dirty = isect; ++i; @@ -231,6 +231,7 @@ void QFxPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidge QPainter qp(&d->imagecache[i]->image); qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smooth); qp.translate(-area.x(), -area.y()); + qp.eraseRect(d->imagecache[i]->dirty); if (d->fillColor.isValid()) qp.fillRect(d->imagecache[i]->dirty,d->fillColor); qp.setClipRect(d->imagecache[i]->dirty); diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index d1bafd6..58b5c8e 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -1047,6 +1047,11 @@ void QFxTextEdit::updateSize() //### need to comfirm cost of always setting these int newWidth = (int)d->document->idealWidth(); d->document->setTextWidth(newWidth); // ### QTextDoc> Alignment will not work unless textWidth is set. Does Text need this line as well? + int cursorWidth = 1; + if(d->cursor) + cursorWidth = d->cursor->width(); + newWidth += cursorWidth; + newWidth += 3;// ### Need a better way of ensuring cursor is in width setImplicitWidth(newWidth); setImplicitHeight(d->text.isEmpty() ? fm.height() : (int)d->document->size().height()); diff --git a/src/declarative/fx/qfxtextinput.cpp b/src/declarative/fx/qfxtextinput.cpp index 16ad185..b7b155a 100644 --- a/src/declarative/fx/qfxtextinput.cpp +++ b/src/declarative/fx/qfxtextinput.cpp @@ -625,7 +625,9 @@ void QFxTextInput::drawContents(QPainter *p, const QRect &r) flags |= QLineControl::DrawSelections; } - d->control->draw(p, QPoint(0,0), r, flags); + QPoint offset = QPoint(0,0); + QRect clipRect = r; + d->control->draw(p, offset, clipRect, flags); p->restore(); } @@ -674,7 +676,7 @@ void QFxTextInputPrivate::init() q, SLOT(updateRect()));//TODO: Only update rect between pos's q->connect(control, SIGNAL(selectionChanged()), q, SLOT(updateRect()));//TODO: Only update rect in selection - //Note that above TODOs are waiting, pending getting the updateRect working right + //Note that above TODOs probably aren't that big a savings q->updateSize(); oldValidity = control->hasAcceptableInput(); lastSelectionStart = 0; @@ -730,11 +732,10 @@ void QFxTextInput::q_textChanged() void QFxTextInput::updateRect(const QRect &r) { - //### Only update that rect. if(r == QRect()) clearCache(); - //else - //dirtyCache(r);//Not working yet + else + dirtyCache(r); update(); } @@ -744,12 +745,12 @@ void QFxTextInput::updateSize(bool needsRedraw) int w = width(); int h = height(); setImplicitHeight(d->control->height()); - //d->control->width() is width of the line, not of the text - //And naturalTextWidth() is the text, not including the cursor int cursorWidth = d->control->cursorWidth(); if(d->cursorItem) cursorWidth = d->cursorItem->width(); - setImplicitWidth(d->control->naturalTextWidth()+2+cursorWidth); + //### Is QFontMetrics too slow? + QFontMetricsF fm(d->font); + setImplicitWidth(fm.width(d->control->displayText())+cursorWidth); setContentsSize(QSize(width(), height()));//Repaints if changed if(w==width() && h==height() && needsRedraw){ clearCache(); |