summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-04-21 13:18:20 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-04-21 13:18:20 (GMT)
commit87c03292dce257f1f72d3fdc4e9457f1e1269ce2 (patch)
tree2f18f87f0fc96349b3ae36687a8e4b31a0e089be /src
parent43bce78bd5a41115ab5a541243cc3edcecd2904e (diff)
parentf14ac31c86eeb53d0b08c799ad0ad895d17475d6 (diff)
downloadQt-87c03292dce257f1f72d3fdc4e9457f1e1269ce2.zip
Qt-87c03292dce257f1f72d3fdc4e9457f1e1269ce2.tar.gz
Qt-87c03292dce257f1f72d3fdc4e9457f1e1269ce2.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Document section behavior when not ordered by section Fix TextInput cursor position unchanged when selection length is 0. Fix TextInput echoMode clearing inputMethodHints set by the user. Elide has unexpected effect on Text's implicitWidth
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp8
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp23
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext_p_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp40
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p.h5
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p_p.h4
-rw-r--r--src/gui/widgets/qlinecontrol.cpp10
7 files changed, 73 insertions, 18 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 7c01293..2e9822e 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -2302,11 +2302,19 @@ void QDeclarativeListView::setCacheBuffer(int b)
depending on the "size" property of the model item. The \c sectionHeading
delegate component provides the light blue bar that marks the beginning of
each section.
+
\snippet examples/declarative/modelviews/listview/sections.qml 0
\image qml-listview-sections-example.png
+ \note Adding sections to a ListView does not automatically re-order the
+ list items by the section criteria.
+ If the model is not ordered by section, then it is possible that
+ the sections created will not be unique; each boundary between
+ differing sections will result in a section header being created
+ even if that section exists elsewhere.
+
\sa {declarative/modelviews/listview}{ListView examples}
*/
QDeclarativeViewSection *QDeclarativeListView::sectionCriteria()
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index 720692c..1d51840 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -101,7 +101,8 @@ QDeclarativeTextPrivate::QDeclarativeTextPrivate()
format(QDeclarativeText::AutoText), wrapMode(QDeclarativeText::NoWrap), lineHeight(1),
lineHeightMode(QDeclarativeText::ProportionalHeight), lineCount(1), truncated(false), maximumLineCount(INT_MAX),
maximumLineCountValid(false), imageCacheDirty(true), updateOnComponentComplete(true), richText(false), singleline(false),
- cacheAllTextAsImage(true), internalWidthUpdate(false), requireImplicitWidth(false), hAlignImplicit(true), rightToLeftText(false), naturalWidth(0), doc(0)
+ cacheAllTextAsImage(true), internalWidthUpdate(false), requireImplicitWidth(false), hAlignImplicit(true),
+ rightToLeftText(false), layoutTextElided(false), naturalWidth(0), doc(0)
{
cacheAllTextAsImage = enableImageCache();
QGraphicsItemPrivate::acceptedMouseButtons = Qt::LeftButton;
@@ -217,6 +218,7 @@ void QDeclarativeTextPrivate::updateLayout()
return;
}
+ layoutTextElided = false;
// Setup instance of QTextLayout for all cases other than richtext
if (!richText) {
layout.clearLayout();
@@ -227,10 +229,13 @@ void QDeclarativeTextPrivate::updateLayout()
singleline = !tmp.contains(QChar::LineSeparator);
if (singleline && !maximumLineCountValid && elideMode != QDeclarativeText::ElideNone && q->widthValid()) {
QFontMetrics fm(font);
- tmp = fm.elidedText(tmp,(Qt::TextElideMode)elideMode,q->width()); // XXX still worth layout...?
- if (tmp != text && !truncated) {
- truncated = true;
- emit q->truncatedChanged();
+ tmp = fm.elidedText(tmp,(Qt::TextElideMode)elideMode,q->width());
+ if (tmp != text) {
+ layoutTextElided = true;
+ if (!truncated) {
+ truncated = true;
+ emit q->truncatedChanged();
+ }
}
}
layout.setText(tmp);
@@ -377,6 +382,12 @@ QRect QDeclarativeTextPrivate::setupTextLayout()
if (requireImplicitWidth && q->widthValid()) {
// requires an extra layout
+ QString elidedText;
+ if (layoutTextElided) {
+ // We have provided elided text to the layout, but we must calculate unelided width.
+ elidedText = layout.text();
+ layout.setText(text);
+ }
layout.beginLayout();
forever {
QTextLine line = layout.createLine();
@@ -390,6 +401,8 @@ QRect QDeclarativeTextPrivate::setupTextLayout()
br = br.united(line.naturalTextRect());
}
naturalWidth = br.width();
+ if (layoutTextElided)
+ layout.setText(elidedText);
}
if (maximumLineCountValid) {
diff --git a/src/declarative/graphicsitems/qdeclarativetext_p_p.h b/src/declarative/graphicsitems/qdeclarativetext_p_p.h
index e3ab62a..6a3d581 100644
--- a/src/declarative/graphicsitems/qdeclarativetext_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetext_p_p.h
@@ -116,6 +116,7 @@ public:
bool requireImplicitWidth:1;
bool hAlignImplicit:1;
bool rightToLeftText:1;
+ bool layoutTextElided:1;
QRect layedOutTextRect;
QSize paintedSize;
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index e1c2107..ee241d6 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -862,6 +862,20 @@ bool QDeclarativeTextInput::hasAcceptableInput() const
state.
*/
+void QDeclarativeTextInputPrivate::updateInputMethodHints()
+{
+ Q_Q(QDeclarativeTextInput);
+ Qt::InputMethodHints hints = inputMethodHints;
+ uint echo = control->echoMode();
+ if (echo == QDeclarativeTextInput::Password || echo == QDeclarativeTextInput::NoEcho)
+ hints |= Qt::ImhHiddenText;
+ else if (echo == QDeclarativeTextInput::PasswordEchoOnEdit)
+ hints &= ~Qt::ImhHiddenText;
+ if (echo != QDeclarativeTextInput::Normal)
+ hints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ q->setInputMethodHints(hints);
+}
+
/*!
\qmlproperty enumeration TextInput::echoMode
@@ -884,21 +898,27 @@ void QDeclarativeTextInput::setEchoMode(QDeclarativeTextInput::EchoMode echo)
Q_D(QDeclarativeTextInput);
if (echoMode() == echo)
return;
- Qt::InputMethodHints imHints = inputMethodHints();
- if (echo == Password || echo == NoEcho)
- imHints |= Qt::ImhHiddenText;
- else
- imHints &= ~Qt::ImhHiddenText;
- if (echo != Normal)
- imHints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
- else
- imHints &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
- setInputMethodHints(imHints);
d->control->setEchoMode((uint)echo);
+ d->updateInputMethodHints();
q_textChanged();
emit echoModeChanged(echoMode());
}
+Qt::InputMethodHints QDeclarativeTextInput::imHints() const
+{
+ Q_D(const QDeclarativeTextInput);
+ return d->inputMethodHints;
+}
+
+void QDeclarativeTextInput::setIMHints(Qt::InputMethodHints hints)
+{
+ Q_D(QDeclarativeTextInput);
+ if (d->inputMethodHints == hints)
+ return;
+ d->inputMethodHints = hints;
+ d->updateInputMethodHints();
+}
+
/*!
\qmlproperty Component TextInput::cursorDelegate
The delegate for the cursor in the TextInput.
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
index 8c873b3..ec70e43 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
@@ -86,7 +86,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextInput : public QDeclarativeImplicitSizeP
Q_PROPERTY(QValidator* validator READ validator WRITE setValidator NOTIFY validatorChanged)
#endif
Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask NOTIFY inputMaskChanged)
- Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
+ Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ imHints WRITE setIMHints)
Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged)
Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged)
@@ -215,6 +215,9 @@ public:
bool isInputMethodComposing() const;
+ Qt::InputMethodHints imHints() const;
+ void setIMHints(Qt::InputMethodHints hints);
+
Q_SIGNALS:
void textChanged();
void cursorPositionChanged();
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
index fd4da2e..ed53e8f 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
@@ -73,7 +73,7 @@ public:
QDeclarativeTextInputPrivate() : control(new QLineControl(QString())),
color((QRgb)0), style(QDeclarativeText::Normal),
styleColor((QRgb)0), hAlign(QDeclarativeTextInput::AlignLeft),
- mouseSelectionMode(QDeclarativeTextInput::SelectCharacters),
+ mouseSelectionMode(QDeclarativeTextInput::SelectCharacters), inputMethodHints(Qt::ImhNone),
hscroll(0), oldScroll(0), oldValidity(false), focused(false), focusOnPress(true),
showInputPanelOnFocus(true), clickCausedFocus(false), cursorVisible(false),
autoScroll(true), selectByMouse(false), canPaste(false), hAlignImplicit(true)
@@ -108,6 +108,7 @@ public:
void mirrorChange();
int calculateTextWidth();
bool sendMouseEventToInputContext(QGraphicsSceneMouseEvent *event, QEvent::Type eventType);
+ void updateInputMethodHints();
QLineControl* control;
@@ -120,6 +121,7 @@ public:
QColor styleColor;
QDeclarativeTextInput::HAlignment hAlign;
QDeclarativeTextInput::SelectionMode mouseSelectionMode;
+ Qt::InputMethodHints inputMethodHints;
QPointer<QDeclarativeComponent> cursorComponent;
QPointer<QDeclarativeItem> cursorItem;
QPointF pressPos;
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index d03e5de..202ea7a 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -254,12 +254,20 @@ void QLineControl::setSelection(int start, int length)
m_selstart = start;
m_selend = qMin(start + length, (int)m_text.length());
m_cursor = m_selend;
- } else {
+ } else if (length < 0){
if (start == m_selend && start + length == m_selstart)
return;
m_selstart = qMax(start + length, 0);
m_selend = start;
m_cursor = m_selstart;
+ } else if (m_selstart != m_selend) {
+ m_selstart = 0;
+ m_selend = 0;
+ m_cursor = start;
+ } else {
+ m_cursor = start;
+ emitCursorPositionChanged();
+ return;
}
emit selectionChanged();
emitCursorPositionChanged();