From 6c98c8b0c8739814d9367d5c29f5c4034ebda0b1 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 23 Sep 2009 12:56:29 +1000 Subject: QFxTextEdit test passes again --- src/declarative/fx/qfxtextedit.cpp | 3 ++- tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index f7b92a4..ce06348 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -1051,7 +1051,8 @@ void QFxTextEdit::updateSize() if(d->cursor) cursorWidth = d->cursor->width(); newWidth += cursorWidth; - newWidth += 3;// ### Need a better way of ensuring cursor is in width + if(!d->document->isEmpty()) + newWidth += 3;// ### Need a better way of accounting for space between char and cursor setImplicitWidth(newWidth); setImplicitHeight(d->text.isEmpty() ? fm.height() : (int)d->document->size().height()); diff --git a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp index ffbb09b..e38e0e7 100644 --- a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp +++ b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp @@ -130,7 +130,7 @@ void tst_qfxtextedit::width() QFxTextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), 0.); + QCOMPARE(textEditObject->width(), 1.);//+1 for cursor } for (int i = 0; i < standard.size(); i++) @@ -144,7 +144,7 @@ void tst_qfxtextedit::width() QFxTextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), qreal(metricWidth)); + QCOMPARE(textEditObject->width(), qreal(metricWidth + 1 + 3));//+3 is the current way of accounting for space between cursor and last character. } for (int i = 0; i < richText.size(); i++) @@ -160,7 +160,7 @@ void tst_qfxtextedit::width() QFxTextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), qreal(documentWidth)); + QCOMPARE(textEditObject->width(), qreal(documentWidth + 1 + 3)); } } -- cgit v0.12