Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / qtquick1 / graphicsitems / qdeclarativetextedit.cpp
index 27ef543..b0c9a0a 100644 (file)
@@ -1,8 +1,7 @@
 /****************************************************************************
 **
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
 **
 ** This file is part of the QtDeclarative module of the Qt Toolkit.
 **
@@ -35,6 +34,7 @@
 **
 **
 **
+**
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
@@ -58,7 +58,7 @@
 #include <QPainter>
 #include <QtGui/QInputPanel>
 
-#include <private/qtextcontrol_p.h>
+#include <private/qwidgettextcontrol_p.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -130,10 +130,10 @@ QString QDeclarative1TextEdit::text() const
 
 #ifndef QT_NO_TEXTHTMLPARSER
     if (d->richText)
-        return d->document->toHtml();
+        return d->control->toHtml();
     else
 #endif
-        return d->document->toPlainText();
+        return d->control->toPlainText();
 }
 
 /*!
@@ -555,9 +555,12 @@ bool QDeclarative1TextEditPrivate::determineHorizontalAlignment()
     if (hAlignImplicit && q->isComponentComplete()) {
         bool alignToRight;
         if (text.isEmpty()) {
-            const QString preeditText = control->textCursor().block().layout()->preeditAreaText();
+            QTextCursor cursor = control->textCursor();
+            const QString preeditText = cursor.block().isValid()
+                    ? control->textCursor().block().layout()->preeditAreaText()
+                    : QString();
             alignToRight = preeditText.isEmpty()
-                    ? QApplication::keyboardInputDirection() == Qt::RightToLeft
+                    ? qApp->inputPanel()->inputDirection() == Qt::RightToLeft
                     : preeditText.isRightToLeft();
         } else {
             alignToRight = rightToLeftText;
@@ -1545,12 +1548,12 @@ void QDeclarative1TextEditPrivate::init()
     q->setFlag(QGraphicsItem::ItemHasNoContents, false);
     q->setFlag(QGraphicsItem::ItemAcceptsInputMethod);
 
-    control = new QTextControl(q);
+    control = new QWidgetTextControl(q);
     control->setIgnoreUnusedNavigationEvents(true);
     control->setTextInteractionFlags(Qt::TextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::TextSelectableByKeyboard | Qt::TextEditable));
     control->setDragEnabled(false);
 
-    // QTextControl follows the default text color
+    // QWidgetTextControl follows the default text color
     // defined by the platform, declarative text
     // should be black by default
     QPalette pal = control->palette();
@@ -1607,23 +1610,6 @@ void QDeclarative1TextEdit::moveCursorDelegate()
     d->cursor->setY(cursorRect.y());
 }
 
-void QDeclarative1TextEditPrivate::updateSelection()
-{
-    Q_Q(QDeclarative1TextEdit);
-    QTextCursor cursor = control->textCursor();
-    bool startChange = (lastSelectionStart != cursor.selectionStart());
-    bool endChange = (lastSelectionEnd != cursor.selectionEnd());
-    cursor.beginEditBlock();
-    cursor.setPosition(lastSelectionStart, QTextCursor::MoveAnchor);
-    cursor.setPosition(lastSelectionEnd, QTextCursor::KeepAnchor);
-    cursor.endEditBlock();
-    control->setTextCursor(cursor);
-    if(startChange)
-        q->selectionStartChanged();
-    if(endChange)
-        q->selectionEndChanged();
-}
-
 void QDeclarative1TextEdit::updateSelectionMarkers()
 {
     Q_D(QDeclarative1TextEdit);
@@ -1783,9 +1769,8 @@ void QDeclarative1TextEditPrivate::updateDefaultTextOption()
     customizing when you want the input keyboard to be shown and hidden in
     your application.
 
-    By default the opening of input panels follows the platform style. On Symbian^1 and
-    Symbian^3 -based devices the panels are opened by clicking TextEdit. On other platforms
-    the panels are automatically opened when TextEdit element gains active focus. Input panels are
+    By default the opening of input panels follows the platform style.
+    The panels are automatically opened when TextEdit element gains active focus. Input panels are
     always closed if no editor has active focus.
 
     You can disable the automatic behavior by setting the property \c activeFocusOnPress to false
@@ -1833,9 +1818,8 @@ void QDeclarative1TextEdit::openSoftwareInputPanel()
     for customizing when you want the input keyboard to be shown and hidden in
     your application.
 
-    By default the opening of input panels follows the platform style. On Symbian^1 and
-    Symbian^3 -based devices the panels are opened by clicking TextEdit. On other platforms
-    the panels are automatically opened when TextEdit element gains active focus. Input panels are
+    By default the opening of input panels follows the platform style.
+    The panels are automatically opened when TextEdit element gains active focus. Input panels are
     always closed if no editor has active focus.
 
     You can disable the automatic behavior by setting the property \c activeFocusOnPress to false