aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2011-06-09 12:56:27 +0200
committerGunnar Sletta <gunnar.sletta@nokia.com>2011-06-09 12:56:27 +0200
commit4faeb7aa0e33d824afb4db1411e6880140bb828a (patch)
treea98703a11b8742d88b65617bf35b74f595c2783e /src
parenta081f12ad755d186596e1b4b98bf908be342c874 (diff)
parent452e13b5407fa4c36f9a573c305d41f551762b93 (diff)
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qtdeclarative-staging
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp54
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p.h5
2 files changed, 23 insertions, 36 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 98ec2050e9..b456d07c02 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -236,11 +236,11 @@ void QDeclarativeTextInput::setFont(const QFont &font)
if (oldFont != d->font) {
d->control->setFont(d->font);
+ updateSize();
+ updateCursorRectangle();
if(d->cursorItem){
d->cursorItem->setHeight(QFontMetrics(d->font).height());
- moveCursor();
}
- updateSize();
}
emit fontChanged(d->sourceFont);
}
@@ -359,8 +359,7 @@ void QDeclarativeTextInput::setHAlign(HAlignment align)
bool forceAlign = d->hAlignImplicit && d->effectiveLayoutMirror;
d->hAlignImplicit = false;
if (d->setHAlign(align, forceAlign) && isComponentComplete()) {
- updateRect();
- d->updateHorizontalScroll();
+ updateCursorRectangle();
}
}
@@ -369,8 +368,7 @@ void QDeclarativeTextInput::resetHAlign()
Q_D(QDeclarativeTextInput);
d->hAlignImplicit = true;
if (d->determineHorizontalAlignment() && isComponentComplete()) {
- updateRect();
- d->updateHorizontalScroll();
+ updateCursorRectangle();
}
}
@@ -423,8 +421,7 @@ void QDeclarativeTextInputPrivate::mirrorChange()
Q_Q(QDeclarativeTextInput);
if (q->isComponentComplete()) {
if (!hAlignImplicit && (hAlign == QDeclarativeTextInput::AlignRight || hAlign == QDeclarativeTextInput::AlignLeft)) {
- q->updateRect();
- updateHorizontalScroll();
+ q->updateCursorRectangle();
emit q->effectiveHorizontalAlignmentChanged();
}
}
@@ -683,7 +680,7 @@ void QDeclarativeTextInput::setAutoScroll(bool b)
d->autoScroll = b;
//We need to repaint so that the scrolling is taking into account.
updateSize(true);
- d->updateHorizontalScroll();
+ updateCursorRectangle();
emit autoScrollChanged(d->autoScroll);
}
@@ -947,10 +944,6 @@ void QDeclarativeTextInput::setCursorDelegate(QDeclarativeComponent* c)
d->cursorComponent = c;
if(!c){
//note that the components are owned by something else
- disconnect(d->control, SIGNAL(cursorPositionChanged(int,int)),
- this, SLOT(moveCursor()));
- disconnect(d->control, SIGNAL(updateMicroFocus()),
- this, SLOT(moveCursor()));
delete d->cursorItem;
}else{
d->startCreatingCursor();
@@ -962,10 +955,6 @@ void QDeclarativeTextInput::setCursorDelegate(QDeclarativeComponent* c)
void QDeclarativeTextInputPrivate::startCreatingCursor()
{
Q_Q(QDeclarativeTextInput);
- q->connect(control, SIGNAL(cursorPositionChanged(int,int)),
- q, SLOT(moveCursor()), Qt::UniqueConnection);
- q->connect(control, SIGNAL(updateMicroFocus()),
- q, SLOT(moveCursor()), Qt::UniqueConnection);
if(cursorComponent->isReady()){
q->createCursor();
}else if(cursorComponent->isLoading()){
@@ -1001,15 +990,6 @@ void QDeclarativeTextInput::createCursor()
d->cursorItem->setHeight(d->control->height()-1); // -1 to counter QLineControl's +1 which is not consistent with Text.
}
-void QDeclarativeTextInput::moveCursor()
-{
- Q_D(QDeclarativeTextInput);
- if(!d->cursorItem)
- return;
- d->updateHorizontalScroll();
- d->cursorItem->setX(d->control->cursorToX() - d->hscroll);
-}
-
/*!
\qmlmethod rect TextInput::positionToRectangle(int pos)
@@ -1118,8 +1098,6 @@ void QDeclarativeTextInput::inputMethodEvent(QInputMethodEvent *ev)
ev->ignore();
} else {
d->control->processInputMethodEvent(ev);
- updateSize();
- d->updateHorizontalScroll();
}
}
if (!ev->isAccepted())
@@ -1297,7 +1275,7 @@ void QDeclarativeTextInput::geometryChanged(const QRectF &newGeometry,
Q_D(QDeclarativeTextInput);
if (newGeometry.width() != oldGeometry.width()) {
updateSize();
- d->updateHorizontalScroll();
+ updateCursorRectangle();
}
QDeclarativePaintedItem::geometryChanged(newGeometry, oldGeometry);
}
@@ -1643,7 +1621,6 @@ void QDeclarativeTextInput::moveCursorSelection(int position)
{
Q_D(QDeclarativeTextInput);
d->control->moveCursor(position, true);
- d->updateHorizontalScroll();
}
/*!
@@ -1901,7 +1878,7 @@ void QDeclarativeTextInputPrivate::init()
canPaste = !control->isReadOnly() && QApplication::clipboard()->text().length() != 0;
#endif // QT_NO_CLIPBOARD
q->connect(control, SIGNAL(updateMicroFocus()),
- q, SLOT(updateMicroFocus()));
+ q, SLOT(updateCursorRectangle()));
q->connect(control, SIGNAL(displayTextChanged(QString)),
q, SLOT(updateRect()));
q->updateSize();
@@ -1917,9 +1894,7 @@ void QDeclarativeTextInputPrivate::init()
void QDeclarativeTextInput::cursorPosChanged()
{
Q_D(QDeclarativeTextInput);
- d->updateHorizontalScroll();
- updateRect();//TODO: Only update rect between pos's
- updateMicroFocus();
+ updateCursorRectangle();
emit cursorPositionChanged();
d->control->resetCursorBlinkTimer();
@@ -1935,6 +1910,17 @@ void QDeclarativeTextInput::cursorPosChanged()
}
}
+void QDeclarativeTextInput::updateCursorRectangle()
+{
+ Q_D(QDeclarativeTextInput);
+ d->updateHorizontalScroll();
+ updateRect();//TODO: Only update rect between pos's
+ updateMicroFocus();
+ emit cursorRectangleChanged();
+ if (d->cursorItem)
+ d->cursorItem->setX(d->control->cursorToX() - d->hscroll);
+}
+
void QDeclarativeTextInput::selectionChanged()
{
Q_D(QDeclarativeTextInput);
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
index aaf8859150..8b7fff9cfb 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
@@ -75,7 +75,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextInput : public QDeclarativeImplicitSizeP
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
- Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorPositionChanged)
+ Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
Q_PROPERTY(QDeclarativeComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged)
Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged)
@@ -221,6 +221,7 @@ public:
Q_SIGNALS:
void textChanged();
void cursorPositionChanged();
+ void cursorRectangleChanged();
void selectionStartChanged();
void selectionEndChanged();
void selectedTextChanged();
@@ -279,8 +280,8 @@ private Q_SLOTS:
void q_textChanged();
void selectionChanged();
void createCursor();
- void moveCursor();
void cursorPosChanged();
+ void updateCursorRectangle();
void updateRect(const QRect &r = QRect());
void q_canPasteChanged();