From a0b725d916ec794c1a0f02b37525a15ad27d145d Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 31 May 2010 15:38:45 +1000 Subject: Repaint all text when Ctrl+A is pressed in TextEdit QTextControl::updateRequest() with empty rect means update all. Task-number: QTBUG-11013 --- src/declarative/graphicsitems/qdeclarativetextedit.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 167db77..f02b7d1 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -1066,9 +1066,14 @@ void QDeclarativeTextEdit::drawContents(QPainter *painter, const QRect &bounds) void QDeclarativeTextEdit::updateImgCache(const QRectF &rf) { Q_D(const QDeclarativeTextEdit); - QRect r = rf.toRect(); - if (r != QRect(0,0,INT_MAX,INT_MAX)) // Don't translate "everything" - r = r.translated(0,d->yoff); + QRect r; + if (!rf.isValid()) { + r = QRect(0,0,INT_MAX,INT_MAX); + } else { + r = rf.toRect(); + if (r != QRect(0,0,INT_MAX,INT_MAX)) // Don't translate "everything" + r = r.translated(0,d->yoff); + } dirtyCache(r); emit update(); } -- cgit v0.12 From b8b1e9784583e3b5960b1966328299f8a1bec440 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 31 May 2010 15:45:01 +1000 Subject: Simplify selection setting. Make TextInput more like TextEdit. By making selectionStart/End read-only, and adding adding select(). Task-number: QTBUG-11056 --- .../modelviews/webview/content/FieldText.qml | 2 - examples/declarative/text/edit/edit.qml | 16 ++--- .../graphicsitems/qdeclarativetextedit.cpp | 68 ++++++++++++---------- .../graphicsitems/qdeclarativetextedit_p.h | 8 +-- .../graphicsitems/qdeclarativetextinput.cpp | 54 +++++++++++------ .../graphicsitems/qdeclarativetextinput_p.h | 16 ++--- .../tst_qdeclarativetextedit.cpp | 39 ++++--------- .../tst_qdeclarativetextinput.cpp | 55 ++++++----------- .../qdeclarativetextedit/MultilineEdit.qml | 3 +- .../qmlvisual/qdeclarativetextinput/LineEdit.qml | 3 +- 10 files changed, 125 insertions(+), 139 deletions(-) diff --git a/examples/declarative/modelviews/webview/content/FieldText.qml b/examples/declarative/modelviews/webview/content/FieldText.qml index c9adde5..17fa4cd 100644 --- a/examples/declarative/modelviews/webview/content/FieldText.qml +++ b/examples/declarative/modelviews/webview/content/FieldText.qml @@ -161,8 +161,6 @@ Item { color: "black" readOnly: false focus: true - selectionStart: 0 - selectionEnd: -1 } PropertyChanges { target: editRegion diff --git a/examples/declarative/text/edit/edit.qml b/examples/declarative/text/edit/edit.qml index 2774739..0be42e9 100644 --- a/examples/declarative/text/edit/edit.qml +++ b/examples/declarative/text/edit/edit.qml @@ -157,14 +157,16 @@ Rectangle { if (editor.state == "selection" && drag != "") { if (drag == "start") { var pos = edit.positionAt(mouse.x+x+startHandle.width/2,mouse.y+y); - if (edit.selectionEnd < pos) - edit.selectionEnd = pos; - edit.selectionStart = pos; + var e = edit.selectionEnd; + if (e < pos) + e = pos; + edit.select(pos,e); } else if (drag == "end") { var pos = edit.positionAt(mouse.x+x-endHandle.width/2,mouse.y+y); - if (edit.selectionStart > pos) - edit.selectionStart = pos; - edit.selectionEnd = pos; + var s = edit.selectionStart; + if (s > pos) + s = pos; + edit.select(s,pos); } } } @@ -226,7 +228,7 @@ Rectangle { height: 16 Text { anchors.centerIn: parent; text: "Deselect" } MouseArea { anchors.fill: parent; - onClicked: { edit.cursorPosition = edit.selectionEnd; edit.selectionStart = edit.selectionEnd; editor.state = "" } } + onClicked: { edit.cursorPosition = edit.selectionEnd; edit.select(edit.cursorPosition,edit.cursorPosition); editor.state = "" } } } } } diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index f8876f2..935b431 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -717,12 +717,9 @@ void QDeclarativeTextEdit::loadCursorDelegate() \qmlproperty int TextEdit::selectionStart The cursor position before the first character in the current selection. - Setting this and selectionEnd allows you to specify a selection in the - text edit. - Note that if selectionStart == selectionEnd then there is no current - selection. If you attempt to set selectionStart to a value outside of - the current text, selectionStart will not be changed. + This property is read-only. To change the selection, use select(start,end), + selectAll(), or selectWord(). \sa selectionEnd, cursorPosition, selectedText */ @@ -732,25 +729,13 @@ int QDeclarativeTextEdit::selectionStart() const return d->control->textCursor().selectionStart(); } -void QDeclarativeTextEdit::setSelectionStart(int s) -{ - Q_D(QDeclarativeTextEdit); - if(d->lastSelectionStart == s || s < 0 || s > text().length()) - return; - d->lastSelectionStart = s; - d->updateSelection();// Will emit the relevant signals -} - /*! \qmlproperty int TextEdit::selectionEnd The cursor position after the last character in the current selection. - Setting this and selectionStart allows you to specify a selection in the - text edit. - Note that if selectionStart == selectionEnd then there is no current - selection. If you attempt to set selectionEnd to a value outside of - the current text, selectionEnd will not be changed. + This property is read-only. To change the selection, use select(start,end), + selectAll(), or selectWord(). \sa selectionStart, cursorPosition, selectedText */ @@ -760,15 +745,6 @@ int QDeclarativeTextEdit::selectionEnd() const return d->control->textCursor().selectionEnd(); } -void QDeclarativeTextEdit::setSelectionEnd(int s) -{ - Q_D(QDeclarativeTextEdit); - if(d->lastSelectionEnd == s || s < 0 || s > text().length()) - return; - d->lastSelectionEnd = s; - d->updateSelection();// Will emit the relevant signals -} - /*! \qmlproperty string TextEdit::selectedText @@ -1018,6 +994,8 @@ void QDeclarativeTextEditPrivate::focusChanged(bool hasFocus) } /*! + \qmlmethod void TextEdit::selectAll() + Causes all text to be selected. */ void QDeclarativeTextEdit::selectAll() @@ -1027,6 +1005,8 @@ void QDeclarativeTextEdit::selectAll() } /*! + \qmlmethod void TextEdit::selectWord() + Causes the word closest to the current cursor position to be selected. */ void QDeclarativeTextEdit::selectWord() @@ -1038,6 +1018,35 @@ void QDeclarativeTextEdit::selectWord() } /*! + \qmlmethod void TextEdit::select(start,end) + + Causes the text from \a start to \a end to be selected. + + If either start or end is out of range, the selection is not changed. + + After calling this, selectionStart will become the lesser + and selectionEnd will become the greater (regardless of the order passed + to this method). + + \sa selectionStart, selectionEnd +*/ +void QDeclarativeTextEdit::select(int start, int end) +{ + Q_D(QDeclarativeTextEdit); + if (start < 0 || end < 0 || start > d->text.length() || end > d->text.length()) + return; + QTextCursor cursor = d->control->textCursor(); + cursor.beginEditBlock(); + cursor.setPosition(start, QTextCursor::MoveAnchor); + cursor.setPosition(end, QTextCursor::KeepAnchor); + cursor.endEditBlock(); + d->control->setTextCursor(cursor); + + // QTBUG-11100 + updateSelectionMarkers(); +} + +/*! \qmlmethod TextEdit::cut() Moves the currently selected text to the system clipboard. @@ -1254,7 +1263,6 @@ void QDeclarativeTextEditPrivate::updateSelection() QTextCursor cursor = control->textCursor(); bool startChange = (lastSelectionStart != cursor.selectionStart()); bool endChange = (lastSelectionEnd != cursor.selectionEnd()); - //### Is it worth calculating a more minimal set of movements? cursor.beginEditBlock(); cursor.setPosition(lastSelectionStart, QTextCursor::MoveAnchor); cursor.setPosition(lastSelectionEnd, QTextCursor::KeepAnchor); @@ -1264,8 +1272,6 @@ void QDeclarativeTextEditPrivate::updateSelection() q->selectionStartChanged(); if(endChange) q->selectionEndChanged(); - startChange = (lastSelectionStart != control->textCursor().selectionStart()); - endChange = (lastSelectionEnd != control->textCursor().selectionEnd()); } void QDeclarativeTextEdit::updateSelectionMarkers() diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h index a83b3db..3abfc35 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h @@ -82,8 +82,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition 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 WRITE setSelectionStart NOTIFY selectionStartChanged) - Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged) + Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged) + Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged) Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectionChanged) Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY focusOnPressChanged) Q_PROPERTY(bool showInputPanelOnFocus READ showInputPanelOnFocus WRITE setShowInputPanelOnFocus NOTIFY showInputPanelOnFocusChanged) @@ -160,10 +160,7 @@ public: void setCursorDelegate(QDeclarativeComponent*); int selectionStart() const; - void setSelectionStart(int); - int selectionEnd() const; - void setSelectionEnd(int); QString selectedText() const; @@ -230,6 +227,7 @@ Q_SIGNALS: public Q_SLOTS: void selectAll(); void selectWord(); + void select(int start, int end); void cut(); void copy(); void paste(); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 9a6a070..25a2b49 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -46,6 +46,7 @@ #include #include +#include #include #include #include @@ -429,10 +430,12 @@ void QDeclarativeTextInput::setCursorPosition(int cp) Returns a Rect which encompasses the cursor, but which may be larger than is required. Ignores custom cursor delegates. */ -QRect QDeclarativeTextInput::cursorRect() const +QRect QDeclarativeTextInput::cursorRectangle() const { Q_D(const QDeclarativeTextInput); - return d->control->cursorRect(); + QRect r = d->control->cursorRect(); + r.setHeight(r.height()-1); // Make consistent with TextEdit (QLineControl inexplicably adds 1) + return r; } /*! @@ -454,15 +457,6 @@ int QDeclarativeTextInput::selectionStart() const return d->lastSelectionStart; } -void QDeclarativeTextInput::setSelectionStart(int s) -{ - Q_D(QDeclarativeTextInput); - if(d->lastSelectionStart == s || s < 0 || s > text().length()) - return; - d->lastSelectionStart = s; - d->control->setSelection(s, d->lastSelectionEnd - s); -} - /*! \qmlproperty int TextInput::selectionEnd @@ -482,13 +476,12 @@ int QDeclarativeTextInput::selectionEnd() const return d->lastSelectionEnd; } -void QDeclarativeTextInput::setSelectionEnd(int s) +void QDeclarativeTextInput::select(int start, int end) { Q_D(QDeclarativeTextInput); - if(d->lastSelectionEnd == s || s < 0 || s > text().length()) + if (start < 0 || end < 0 || start > d->control->text().length() || end > d->control->text().length()) return; - d->lastSelectionEnd = s; - d->control->setSelection(d->lastSelectionStart, s - d->lastSelectionStart); + d->control->setSelection(start, end-start); } /*! @@ -833,6 +826,19 @@ void QDeclarativeTextInput::moveCursor() } /*! + \qmlmethod rect TextInput::positionToRectangle(int x) +*/ +QRectF QDeclarativeTextInput::positionToRectangle(int x) const +{ + Q_D(const QDeclarativeTextInput); + QFontMetrics fm = QFontMetrics(d->font); + return QRectF(d->control->cursorToX(x)-d->hscroll, + 0.0, + d->control->cursorWidth(), + cursorRectangle().height()); +} + +/*! \qmlmethod int TextInput::positionAt(int x) This function returns the character position at @@ -843,7 +849,7 @@ void QDeclarativeTextInput::moveCursor() This means that for all x values before the first character this function returns 0, and for all x values after the last character this function returns text.length. */ -int QDeclarativeTextInput::positionAt(int x) +int QDeclarativeTextInput::positionAt(int x) const { Q_D(const QDeclarativeTextInput); return d->control->xToPos(x - d->hscroll); @@ -1019,7 +1025,6 @@ void QDeclarativeTextInput::drawContents(QPainter *p, const QRect &r) d->hscroll -= minLB; offset = QPoint(d->hscroll, 0); } - d->control->draw(p, offset, r, flags); p->restore(); @@ -1057,12 +1062,27 @@ QVariant QDeclarativeTextInput::inputMethodQuery(Qt::InputMethodQuery property) } } +/*! + \qmlmethod void TextInput::selectAll() + + Causes all text to be selected. +*/ void QDeclarativeTextInput::selectAll() { Q_D(QDeclarativeTextInput); d->control->setSelection(0, d->control->text().length()); } +/*! + \qmlmethod void TextInput::selectWord() + + Causes the word closest to the current cursor position to be selected. +*/ +void QDeclarativeTextInput::selectWord() +{ + Q_D(QDeclarativeTextInput); + d->control->selectWordAtPos(d->control->cursor()); +} /*! \qmlproperty bool TextInput::smooth diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h index 6bb94c2..0b7ddd5 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h @@ -72,10 +72,10 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTextInput : public QDeclarativePaintedIte 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 cursorRect READ cursorRect NOTIFY cursorPositionChanged) + Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorPositionChanged) Q_PROPERTY(QDeclarativeComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged) - Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged) - Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged) + Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged) + Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged) Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged) Q_PROPERTY(int maximumLength READ maxLength WRITE setMaxLength NOTIFY maximumLengthChanged) @@ -110,7 +110,8 @@ public: }; //Auxilliary functions needed to control the TextInput from QML - Q_INVOKABLE int positionAt(int x); + Q_INVOKABLE int positionAt(int x) const; + Q_INVOKABLE QRectF positionToRectangle(int x) const; Q_INVOKABLE void moveCursorSelection(int pos); Q_INVOKABLE void openSoftwareInputPanel(); @@ -143,13 +144,10 @@ public: int cursorPosition() const; void setCursorPosition(int cp); - QRect cursorRect() const; + QRect cursorRectangle() const; int selectionStart() const; - void setSelectionStart(int); - int selectionEnd() const; - void setSelectionEnd(int); QString selectedText() const; @@ -231,6 +229,8 @@ protected: public Q_SLOTS: void selectAll(); + void selectWord(); + void select(int start, int end); private Q_SLOTS: void updateSize(bool needsRedraw = true); diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index d3e3c3a..47c5b63 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -551,11 +551,11 @@ void tst_qdeclarativetextedit::selection() //Test selection for(int i=0; i<= testStr.size(); i++) { - textEditObject->setSelectionEnd(i); + textEditObject->select(0,i); QCOMPARE(testStr.mid(0,i), textEditObject->selectedText()); } for(int i=0; i<= testStr.size(); i++) { - textEditObject->setSelectionStart(i); + textEditObject->select(i,testStr.size()); QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText()); } @@ -565,43 +565,26 @@ void tst_qdeclarativetextedit::selection() QVERIFY(textEditObject->selectionEnd() == 0); QVERIFY(textEditObject->selectedText().isNull()); - for(int i=0; i< testStr.size(); i++) { - textEditObject->setSelectionStart(i); - QCOMPARE(textEditObject->selectionEnd(), i); - QCOMPARE(testStr.mid(i,0), textEditObject->selectedText()); - textEditObject->setSelectionEnd(i+1); - QCOMPARE(textEditObject->selectionStart(), i); - QCOMPARE(testStr.mid(i,1), textEditObject->selectedText()); - } - - for(int i= testStr.size() - 1; i>0; i--) { - textEditObject->setSelectionEnd(i); - QCOMPARE(testStr.mid(i,0), textEditObject->selectedText()); - textEditObject->setSelectionStart(i-1); - QCOMPARE(testStr.mid(i-1,1), textEditObject->selectedText()); - } - //Test Error Ignoring behaviour textEditObject->setCursorPosition(0); QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->setSelectionStart(-10); + textEditObject->select(-10,0); QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->setSelectionStart(100); + textEditObject->select(100,101); QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->setSelectionEnd(-10); + textEditObject->select(0,-10); QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->setSelectionEnd(100); + textEditObject->select(0,100); QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->setSelectionStart(0); - textEditObject->setSelectionEnd(10); + textEditObject->select(0,10); QVERIFY(textEditObject->selectedText().size() == 10); - textEditObject->setSelectionStart(-10); + textEditObject->select(-10,0); QVERIFY(textEditObject->selectedText().size() == 10); - textEditObject->setSelectionStart(100); + textEditObject->select(100,101); QVERIFY(textEditObject->selectedText().size() == 10); - textEditObject->setSelectionEnd(-10); + textEditObject->select(0,-10); QVERIFY(textEditObject->selectedText().size() == 10); - textEditObject->setSelectionEnd(100); + textEditObject->select(0,100); QVERIFY(textEditObject->selectedText().size() == 10); } diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index c01cfa5..54bb9c1 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -322,11 +322,11 @@ void tst_qdeclarativetextinput::selection() //Test selection for(int i=0; i<= testStr.size(); i++) { - textinputObject->setSelectionEnd(i); + textinputObject->select(0,i); QCOMPARE(testStr.mid(0,i), textinputObject->selectedText()); } for(int i=0; i<= testStr.size(); i++) { - textinputObject->setSelectionStart(i); + textinputObject->select(i,testStr.size()); QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText()); } @@ -336,43 +336,26 @@ void tst_qdeclarativetextinput::selection() QVERIFY(textinputObject->selectionEnd() == 0); QVERIFY(textinputObject->selectedText().isNull()); - for(int i=0; i< testStr.size(); i++) { - textinputObject->setSelectionStart(i); - QCOMPARE(textinputObject->selectionEnd(), i); - QCOMPARE(testStr.mid(i,0), textinputObject->selectedText()); - textinputObject->setSelectionEnd(i+1); - QCOMPARE(textinputObject->selectionStart(), i); - QCOMPARE(testStr.mid(i,1), textinputObject->selectedText()); - } - - for(int i= testStr.size() - 1; i>0; i--) { - textinputObject->setSelectionEnd(i); - QCOMPARE(testStr.mid(i,0), textinputObject->selectedText()); - textinputObject->setSelectionStart(i-1); - QCOMPARE(testStr.mid(i-1,1), textinputObject->selectedText()); - } - //Test Error Ignoring behaviour textinputObject->setCursorPosition(0); QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->setSelectionStart(-10); + textinputObject->select(-10,0); QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->setSelectionStart(100); + textinputObject->select(100,110); QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->setSelectionEnd(-10); + textinputObject->select(0,-10); QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->setSelectionEnd(100); + textinputObject->select(0,100); QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->setSelectionStart(0); - textinputObject->setSelectionEnd(10); + textinputObject->select(0,10); QVERIFY(textinputObject->selectedText().size() == 10); - textinputObject->setSelectionStart(-10); + textinputObject->select(-10,10); QVERIFY(textinputObject->selectedText().size() == 10); - textinputObject->setSelectionStart(100); + textinputObject->select(100,101); QVERIFY(textinputObject->selectedText().size() == 10); - textinputObject->setSelectionEnd(-10); + textinputObject->select(0,-10); QVERIFY(textinputObject->selectedText().size() == 10); - textinputObject->setSelectionEnd(100); + textinputObject->select(0,100); QVERIFY(textinputObject->selectedText().size() == 10); delete textinputObject; @@ -565,8 +548,7 @@ void tst_qdeclarativetextinput::navigation() QVERIFY(input->hasFocus() == true); //QT-2944: If text is selected, ensure we deselect upon cursor motion input->setCursorPosition(input->text().length()); - input->setSelectionStart(0); - input->setSelectionEnd(input->text().length()); + input->select(0,input->text().length()); QVERIFY(input->selectionStart() != input->selectionEnd()); simulateKey(canvas, Qt::Key_Right); QVERIFY(input->selectionStart() == input->selectionEnd()); @@ -603,13 +585,13 @@ void tst_qdeclarativetextinput::cursorDelegate() //Test Delegate gets moved for(int i=0; i<= textInputObject->text().length(); i++){ textInputObject->setCursorPosition(i); - //+5 is because the TextInput cursorRect is just a 10xHeight area centered on cursor position - QCOMPARE(textInputObject->cursorRect().x() + 5, qRound(delegateObject->x())); - QCOMPARE(textInputObject->cursorRect().y(), qRound(delegateObject->y())); + //+5 is because the TextInput cursorRectangle is just a 10xHeight area centered on cursor position + QCOMPARE(textInputObject->cursorRectangle().x() + 5, qRound(delegateObject->x())); + QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); } textInputObject->setCursorPosition(0); - QCOMPARE(textInputObject->cursorRect().x()+5, qRound(delegateObject->x())); - QCOMPARE(textInputObject->cursorRect().y(), qRound(delegateObject->y())); + QCOMPARE(textInputObject->cursorRectangle().x()+5, qRound(delegateObject->x())); + QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); //Test Delegate gets deleted textInputObject->setCursorDelegate(0); QVERIFY(!textInputObject->findChild("cursorInstance")); @@ -881,8 +863,7 @@ void tst_qdeclarativetextinput::focusOutClearSelection() view.show(); QApplication::setActiveWindow(&view); QTest::qWaitForWindowShown(&view); - input.setSelectionStart(2); - input.setSelectionEnd(5); + input.select(2,5); //The selection should work QTRY_COMPARE(input.selectedText(), QLatin1String("llo")); input2.setFocus(true); diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetextedit/MultilineEdit.qml b/tests/auto/declarative/qmlvisual/qdeclarativetextedit/MultilineEdit.qml index 0273282..53538cb 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativetextedit/MultilineEdit.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativetextedit/MultilineEdit.qml @@ -65,8 +65,7 @@ Item { onReleased: { } onDoubleClicked: { - textEdit.selectionStart=0; - textEdit.selectionEnd=textEdit.text.length; + textEdit.selectAll() } z: textEdit.z + 1 } diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml b/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml index cc0ad3c..69f57c6 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml @@ -58,8 +58,7 @@ Item { onReleased: { } onDoubleClicked: { - textInp.selectionStart=0; - textInp.selectionEnd=textInp.text.length; + textInp.selectAll() } z: textInp.z + 1 } -- cgit v0.12 From e5cc765d2fa1ff68f1592ad475d6b8f4e5a6f667 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 31 May 2010 14:45:43 +1000 Subject: Document issues with rectangle border width of 1 where clipping is used --- doc/src/declarative/pics/rect-border-width.png | Bin 0 -> 356 bytes doc/src/snippets/declarative/rect-border-width.qml | 19 +++++++++++++++++++ .../graphicsitems/qdeclarativerectangle.cpp | 16 ++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 doc/src/declarative/pics/rect-border-width.png create mode 100644 doc/src/snippets/declarative/rect-border-width.qml diff --git a/doc/src/declarative/pics/rect-border-width.png b/doc/src/declarative/pics/rect-border-width.png new file mode 100644 index 0000000..c3c6c2c Binary files /dev/null and b/doc/src/declarative/pics/rect-border-width.png differ diff --git a/doc/src/snippets/declarative/rect-border-width.qml b/doc/src/snippets/declarative/rect-border-width.qml new file mode 100644 index 0000000..27a241d --- /dev/null +++ b/doc/src/snippets/declarative/rect-border-width.qml @@ -0,0 +1,19 @@ +import Qt 4.7 + +//![0] +Rectangle { + width: 100; height: 100 + color: "yellow" + + Rectangle { + anchor.fill: parent + anchors.margins: 10 + clip: true + + Rectangle { + anchors.fill: parent + border.width: 1 + } + } +} +//![0] diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp index 301ca00..de3dbcd 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp +++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp @@ -202,8 +202,20 @@ void QDeclarativeRectangle::doUpdate() A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color. - To keep the border smooth (rather than blurry), odd widths cause the rectangle to be painted at - a half-pixel offset; + If \c border.width is an odd number, the rectangle is painted at a half-pixel offset to retain + border smoothness. Also, the border is rendered evenly on either side of the + rectangle's boundaries, and the spare pixel is rendered to the right and below the + rectangle (as documented for QRect rendering). This can cause unintended effects if + \c border.width is 1 and the rectangle is \l{clip}{clipped} by a parent item: + + \table + \row + \o \snippet doc/src/snippets/declarative/rect-border-width.qml 0 + \o \image rect-border-width.png + \endtable + + Here, the innermost rectangle's border is clipped on the bottom and right edges by its + parent. To avoid this, the border width can be set to two instead of one. */ QDeclarativePen *QDeclarativeRectangle::border() { -- cgit v0.12 From 4759e47a2444d481156ad1a789e5affbc92e1b58 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 31 May 2010 16:59:48 +1000 Subject: Various doc fixes and improvements --- doc/src/declarative/basictypes.qdoc | 67 +++++++++++++++++---- doc/src/declarative/globalobject.qdoc | 2 +- doc/src/declarative/pics/repeater-modeldata.png | Bin 0 -> 2600 bytes doc/src/declarative/qml-intro.qdoc | 26 ++++---- .../snippets/declarative/repeater-modeldata.qml | 52 ++++++++++++++++ examples/declarative/sqllocalstorage/hello.qml | 2 +- .../tutorials/extending/chapter1-basics/app.qml | 1 + .../tutorials/extending/chapter2-methods/app.qml | 1 + .../tutorials/extending/chapter3-bindings/app.qml | 1 + .../extending/chapter4-customPropertyTypes/app.qml | 1 + .../graphicsitems/qdeclarativerepeater.cpp | 14 +++-- src/declarative/qml/qdeclarativeengine.cpp | 34 ++++++++--- 12 files changed, 159 insertions(+), 42 deletions(-) create mode 100644 doc/src/declarative/pics/repeater-modeldata.png create mode 100644 doc/src/snippets/declarative/repeater-modeldata.qml diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc index 8db1c35..43ae214 100644 --- a/doc/src/declarative/basictypes.qdoc +++ b/doc/src/declarative/basictypes.qdoc @@ -46,9 +46,9 @@ QML has a set of primitive types, as listed below, that are used throughout the \l {QML Elements}. - The simpler types in this list can also be used for defining a new - \c property in a component. See \l{Extending types from QML} for the - list of types that can be used for custom properties. + Some of these types can also be used for defining + \c property values in QML. See \l{Extending types from QML} for the + list of types that can be used for \c property values. \annotatedlist qmlbasictypes */ @@ -171,6 +171,13 @@ Rectangle { color: "#800000FF" } \endqml + Or with the \l{Qt::rgba()}{Qt.rgba()}, \l{Qt::hsla()}{Qt.hsla()}, \l{Qt::darker()}{Qt.darker()}, + \l{Qt::lighter()}{Qt.lighter()} or \l{Qt::tint()}{Qt.tint()} functions: + + \qml + Rectangle { color: Qt.rgba(255, 0, 0, 1) } + \endqml + \sa {QML Basic Types} */ @@ -184,9 +191,17 @@ Example: \qml - Widget { pos: "0,20" } + MyItem { position: "0,20" } \endqml + Or with the \l{Qt::point()}{Qt.point()} function: + + \qml + MyItem { position: Qt.point(0, 20) } + \endqml + + A point object has \c x and \c y attributes that contain the \c x and \c y values. + \sa {QML Basic Types} */ @@ -200,9 +215,17 @@ Example: \qml - Widget { size: "150x50" } + LayoutItem { preferredSize: "150x50" } + \endqml + + Or with the \l{Qt::size()}{Qt.size()} function: + + \qml + MyItem { position: Qt.size(150, 50) } \endqml + A size object has \c width and \c height attributes that contain the \c width and \c height values. + \sa {QML Basic Types} */ @@ -216,9 +239,18 @@ Example: \qml - Widget { geometry: "50,50,100x100" } + MyItem { geometry: "50,50,100x100" } \endqml + Or with the \l{Qt::rect()}{Qt.rect()} function: + + \qml + MyItem { position: Qt.rect(50, 50, 100, 100) } + \endqml + + A rect object has \c x, \c, y, \c width and \c height attributes that contain the + \c x, \c y, \c width and \c height values. + \sa {QML Basic Types} */ @@ -232,9 +264,12 @@ Example: \qml - DatePicker { minDate: "2000-01-01"; maxDate: "2020-12-31" } + MyDatePicker { minDate: "2000-01-01"; maxDate: "2020-12-31" } \endqml + To read a date value returned from a C++ extension class, use + \l{Qt::formatDate()}{Qt.formatDate()} and \l{Qt::formatDateTime()}{Qt.formatDateTime()}. + \sa {QML Basic Types} */ @@ -248,9 +283,12 @@ Example: \qml - TimePicker { time: "14:22:15" } + MyTimePicker { time: "14:22:15" } \endqml + To read a time value returned from a C++ extension class, use + \l{Qt::formatTime()}{Qt.formatTime()} and \l{Qt::formatDateTime()}{Qt.formatDateTime()}. + \sa {QML Basic Types} */ @@ -297,9 +335,9 @@ Actions are used like this: \qml - MouseArea { onClicked: MyItem.myaction.trigger() } - State { name: "enabled"; when: MyItem.myaction.enabled == true } - Text { text: MyItem.someaction.text } + MouseArea { onClicked: myaction.trigger() } + State { name: "enabled"; when: myaction.enabled == true } + Text { text: someaction.text } \endqml \sa {QML Basic Types} @@ -327,7 +365,7 @@ ] } \endqml - \c Child1, \c Child2 and \c Child3 will all be added to the children list + \c child1, \c child2 and \c child3 will all be added to the children list in the order in which they appear. \sa {QML Basic Types} @@ -345,7 +383,7 @@ Rotation { angle: 60; axis: "0,1,0" } \endqml - or with the \c{Qt.vector3d()} helper function: + or with the \c{Qt.vector3d()} function: \qml Rotation { angle: 60; axis: Qt.vector3d(0, 1, 0) } @@ -357,5 +395,8 @@ Rotation { angle: 60; axis.x: 0; axis.y: 1; axis.z: 0 } \endqml + A vector3d object has \c x, \c, y, and \c z attributes that contain the + \c x, \c y, \c z values. + \sa {QML Basic Types} */ diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc index 7d4f9b9..3121e95 100644 --- a/doc/src/declarative/globalobject.qdoc +++ b/doc/src/declarative/globalobject.qdoc @@ -49,7 +49,7 @@ Contains all the properties of the JavaScript global object, plus: \section1 Qt Object -The \l{qml-qt.html}{Qt object} provides useful enums and functions from Qt, for use in all QML +The \l{Qt}{Qt object} provides useful enums and functions from Qt, for use in all QML files. \section1 XMLHttpRequest diff --git a/doc/src/declarative/pics/repeater-modeldata.png b/doc/src/declarative/pics/repeater-modeldata.png new file mode 100644 index 0000000..817f35b Binary files /dev/null and b/doc/src/declarative/pics/repeater-modeldata.png differ diff --git a/doc/src/declarative/qml-intro.qdoc b/doc/src/declarative/qml-intro.qdoc index 64a4949..848e094 100644 --- a/doc/src/declarative/qml-intro.qdoc +++ b/doc/src/declarative/qml-intro.qdoc @@ -864,49 +864,49 @@ paused, and reaching the end of the media. They allow the developer to connect, some QML that will handle this event. -\section1 Analyzing An Example: Dial +\section1 Analyzing An Example: Dial Control -In the Qt \e {examples/declarative/toys} folder you will find a folder -\e {dial} which contains the \e dial example. +In the Qt \e {examples/declarative/ui-components} folder you will find a folder +\e {dialcontrol} which contains the \e dialcontrol example. \image qml-dial.png "QML Dial example with Slider" In essence this small application has a sliding bar that you can slide using a mouse, and a graphical dial that responds to the position of the slider. -The code for the example is in two parts: Dial.qml and dial-example.qml. +The code for the example is in two parts: Dial.qml and dialcontrol.qml. -\e {Dial.qml} can be found in the \e content sub-directory. It defines a Dial +\e {Dial.qml} can be found in the \e content sub-directory. It defines a \c Dial component similar to an odometer. Eventually, the example will hook up a slider component so that moving the slider will change the position of a needle on the dial. -The code for the Dial, identified by the name of the file, contains four images +The code for the \c Dial, identified by the name of the file, contains four images in overlapping order: the background (numbers and divisions), the shadow of the needle, the needle itself, and finally the 'glass' overlay (containing transparent layers). -The needle_shadow.png image has a Rotation assigned to the \e transform +The \c needle_shadow.png image has a \l Rotation assigned to the \e transform attribute of the \l Image. The rotation is set to match the angle of the needle image angle value \e {needleRotation.angle}. Both the needle and the needle_shadow have the same default \e x and \e y values but the rotation origin for the needle is slightly different so that a shadow will be evident as the needle moves. -\snippet ../../examples/declarative/toys/dial/content/Dial.qml needle_shadow +\snippet ../../examples/declarative/ui-components/dialcontrol/content/Dial.qml needle_shadow And the needle -\snippet ../../examples/declarative/toys/dial/content/Dial.qml needle +\snippet ../../examples/declarative/ui-components/dialcontrol/content/Dial.qml needle The final image is the overlay which simply has a position defined. -\snippet ../../examples/declarative/toys/dial/content/Dial.qml overlay +\snippet ../../examples/declarative/ui-components/dialcontrol/content/Dial.qml overlay -\e {dial-example.qml} in the \e {examples/declarative/toys/dial} directory is the +\e {dialcontrol.qml} in the \e {examples/declarative/ui-components/dialcontrol} directory is the main file of the example. It defines the visual environment that the Dial will fit into. Because the \e Dial component and the images live in the \e -content sub-directory we will have to import this into \e dial-example. So the +content sub-directory we will have to import this into \e dialcontrol.qml. So the start of the file looks like \code @@ -919,7 +919,7 @@ a gray color. Inside this rectangle is our component \e Dial and a \l Rectangle. Inside the rectangle called 'container' is another rectangle with the interesting name 'slider'. -\snippet ../../examples/declarative/toys/dial/dial-example.qml 0 +\snippet ../../examples/declarative/ui-components/dialcontrol/dialcontrol.qml 0 The Dial component, named 'dial, is \e anchored to the center of the main rectangle. The \c value attribute of 'dial' is set to a value based on the diff --git a/doc/src/snippets/declarative/repeater-modeldata.qml b/doc/src/snippets/declarative/repeater-modeldata.qml new file mode 100644 index 0000000..3b4cc6d --- /dev/null +++ b/doc/src/snippets/declarative/repeater-modeldata.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt 4.7 + +//! [0] +Column { + Repeater { + model: ["apples", "oranges", "pears"] + Text { text: "Data: " + modelData } + } +} +//! [0] + diff --git a/examples/declarative/sqllocalstorage/hello.qml b/examples/declarative/sqllocalstorage/hello.qml index 0913d42..421a74c 100644 --- a/examples/declarative/sqllocalstorage/hello.qml +++ b/examples/declarative/sqllocalstorage/hello.qml @@ -68,4 +68,4 @@ Text { Component.onCompleted: findGreetings() } - +//![0] diff --git a/examples/declarative/tutorials/extending/chapter1-basics/app.qml b/examples/declarative/tutorials/extending/chapter1-basics/app.qml index 7de32f2..9af155c 100644 --- a/examples/declarative/tutorials/extending/chapter1-basics/app.qml +++ b/examples/declarative/tutorials/extending/chapter1-basics/app.qml @@ -55,3 +55,4 @@ Rectangle { text: aMusician.name + " plays the " + aMusician.instrument } } +//![0] diff --git a/examples/declarative/tutorials/extending/chapter2-methods/app.qml b/examples/declarative/tutorials/extending/chapter2-methods/app.qml index 495413f..02d33c2 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/app.qml +++ b/examples/declarative/tutorials/extending/chapter2-methods/app.qml @@ -57,3 +57,4 @@ Rectangle { onClicked: aMusician.perform() } } +//![0] diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml index 46408cb..8bf6ecf 100644 --- a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml +++ b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml @@ -69,3 +69,4 @@ Rectangle { } } } +//![0] diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml index 09662d6..d76f801 100644 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml @@ -51,3 +51,4 @@ Item { Component.onCompleted: console.log("Reddy plays the " + reddy.instrument.type) } +//![0] diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index 04076f8..691cfa2 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -80,14 +80,20 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() The index is always exposed as an accessible \c index property. In the case of an object or string list, the data element (of type string or object) is available as the \c modelData property. In the case of a Qt model, - all roles are available as named properties just like in the view classes. The - following example shows how to use the index property inside the instantiated - items. + all roles are available as named properties just like in the view classes. - \snippet doc/src/snippets/declarative/repeater-index.qml 0 + The following example shows how to use the \c index property inside the instantiated + items: + \snippet doc/src/snippets/declarative/repeater-index.qml 0 \image repeater-index.png + The repeater could also use the \c modelData property to reference the data for a + particular index: + + \snippet doc/src/snippets/declarative/repeater-modeldata.qml 0 + \image repeater-modeldata.png + Items instantiated by the Repeater are inserted, in order, as children of the Repeater's parent. The insertion starts immediately after the repeater's position in its parent stacking list. This is to allow diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 8679e76..d8c842b 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -155,14 +155,26 @@ void QDeclarativeEnginePrivate::defineModule() \qmlclass Qt QDeclarativeEnginePrivate \brief The QML global Qt object provides useful enums and functions from Qt. -The Qt object provides useful enums and functions from Qt, for use in all QML files. +The \c Qt object provides useful enums and functions from Qt, for use in all QML files. + +The \c Qt object is not a QML element; it cannot be instantiated. It is a global object +with enums and functions. To use it, call the members of the global \c Qt object directly. +For example: + +\qml +import Qt 4.7 + +Text { + color: Qt.rgba(255, 0, 0, 1) + text: Qt.md5("hello, world") +} +\endqml -You do not create instances of this type, but instead use the members of the global "Qt" object. \section1 Enums The Qt object contains all enums in the Qt namespace. For example, you can -access the AlignLeft member of the Qt::AlignmentFlag enum with \c Qt.AlignLeft. +access the \c AlignLeft member of the \c Qt::AlignmentFlag enum with \c Qt.AlignLeft. For a full list of enums, see the \l{Qt Namespace} documentation. @@ -172,7 +184,7 @@ data types. This is primarily useful when setting the properties of an item when the property has one of the following types: \list -\o \c color - use \l{Qt::rgba()}{Qt.rgba()}, \l{Qt::darker()}{Qt.darker()}, \l{Qt::lighter()}{Qt.lighter()} or \l{Qt::tint()}{Qt.tint()} +\o \c color - use \l{Qt::rgba()}{Qt.rgba()}, \l{Qt::hsla()}{Qt.hsla()}, \l{Qt::darker()}{Qt.darker()}, \l{Qt::lighter()}{Qt.lighter()} or \l{Qt::tint()}{Qt.tint()} \o \c rect - use \l{Qt::rect()}{Qt.rect()} \o \c point - use \l{Qt::point()}{Qt.point()} \o \c size - use \l{Qt::size()}{Qt.size()} @@ -200,8 +212,8 @@ items from files or strings. See \l{Dynamic Object Management} for an overview of their use. \list - \o \l{Qt::createComponent}{object Qt.createComponent(url)} - \o \l{Qt::createQmlObject}{object Qt.createQmlObject(string qml, object parent, string filepath)} + \o \l{Qt::createComponent()}{object Qt.createComponent(url)} + \o \l{Qt::createQmlObject()}{object Qt.createQmlObject(string qml, object parent, string filepath)} \endlist */ @@ -1034,7 +1046,7 @@ QString QDeclarativeEnginePrivate::urlToLocalFileOrQrc(const QUrl& url) /*! \qmlmethod object Qt::createComponent(url) -Returns a \l Component object created from the QML file at the specified \a url, +Returns a \l Component object created using the QML file at the specified \a url, or \c null if there was an error in creating the component. Call \l {Component::createObject()}{Component.createObject()} on the returned @@ -1360,7 +1372,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr /*! \qmlmethod color Qt::rgba(real red, real green, real blue, real alpha) -Returns a Color with the specified \c red, \c green, \c blue and \c alpha components. +Returns a color with the specified \c red, \c green, \c blue and \c alpha components. All components should be in the range 0-1 inclusive. */ QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine *engine) @@ -1388,7 +1400,7 @@ QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine /*! \qmlmethod color Qt::hsla(real hue, real saturation, real lightness, real alpha) -Returns a Color with the specified \c hue, \c saturation, \c lightness and \c alpha components. +Returns a color with the specified \c hue, \c saturation, \c lightness and \c alpha components. All components should be in the range 0-1 inclusive. */ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine *engine) @@ -1416,7 +1428,9 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine /*! \qmlmethod rect Qt::rect(int x, int y, int width, int height) -Returns a Rect with the top-left corner at \c x, \c y and the specified \c width and \c height. +Returns a \c rect with the top-left corner at \c x, \c y and the specified \c width and \c height. + +The returned object has \c x, \c y, \c width and \c height attributes with the given values. */ QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine *engine) { -- cgit v0.12 From 51f56d93578be5021fe449da1165cf0c539343b9 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 31 May 2010 16:48:24 +0200 Subject: Updated WebKit to c58dc2f491a824ac56e31c440fcf7fe16dab09c4 Integrate https://trac.webkit.org/changeset/60435 - [Qt] Escape backslashes in the .pro files by Ossi. --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 10 ++++++++++ src/3rdparty/webkit/WebCore/WebCore.pro | 2 +- .../webkit/WebKit/qt/Api/DerivedSources.pro | 6 +++--- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 2 +- src/3rdparty/webkit/WebKit/qt/ChangeLog | 21 +++++++++++++++++++++ src/3rdparty/webkit/WebKit/qt/docs/docs.pri | 2 +- 8 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 49b1cbe..8cb0e53 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -c58dc2f491a824ac56e31c440fcf7fe16dab09c4 +f59a934694947496cedecc5256a71bff60c43c4c diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 1db0c55..fb78e36 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - 531b0d7cd2af830f0d17b83b6e4a489794481539 + c58dc2f491a824ac56e31c440fcf7fe16dab09c4 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index daf10fa..ff7d214 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,13 @@ +2010-05-31 Oswald Buddenhagen + + Reviewed by Simon Hausmann. + + [Qt] Escape backslashes in the .pro files + + qmake in Qt 4.7 warns about unescaped backspaces and deprecates them. + + * WebCore.pro: + 2010-05-28 Antti Koivisto Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 5def728..63e78a7 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -159,7 +159,7 @@ defineTest(addExtraCompiler) { for(file,input) { base = $$basename(file) - base ~= s/\..+// + base ~= s/\\..+// newfile=$$replace(outputRule,\\$\\{QMAKE_FILE_BASE\\},$$base) SOURCES += $$newfile } diff --git a/src/3rdparty/webkit/WebKit/qt/Api/DerivedSources.pro b/src/3rdparty/webkit/WebKit/qt/Api/DerivedSources.pro index 389fb5f..22d4c8d 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/DerivedSources.pro +++ b/src/3rdparty/webkit/WebKit/qt/Api/DerivedSources.pro @@ -28,7 +28,7 @@ qtheader_module.commands += echo $${QUOTE}$${LITERAL_HASH}define QT_QTWEBKIT_MOD qtheader_module.commands += echo $${QUOTE}$${LITERAL_HASH}include $${ESCAPE}$${QUOTE} >> $${qtheader_module.target} && WEBKIT_CLASS_HEADERS = $${LITERAL_DOLLAR}$${LITERAL_DOLLAR}$${LITERAL_DOLLAR}$${LITERAL_DOLLAR}PWD/QtWebKit -regex = ".*\sclass\sQWEBKIT_EXPORT\s(\w+)\s(.*)" +regex = ".*\\sclass\\sQWEBKIT_EXPORT\\s(\\w+)\\s(.*)" for(HEADER, WEBKIT_API_HEADERS) { # 1. Append to QtWebKit header that includes all other header files @@ -70,7 +70,7 @@ for(HEADER, WEBKIT_API_HEADERS) { res = $$find(src, $$regex) isEmpty(res):break() - exp = $$replace(src, $$regex, "EXPORTED_CLASS = \1") + exp = $$replace(src, $$regex, "EXPORTED_CLASS = \\1") eval($$exp) CLASS_TARGET = "qtheader_$${EXPORTED_CLASS}" @@ -87,7 +87,7 @@ for(HEADER, WEBKIT_API_HEADERS) { # Qt's QRegExp does not support inline non-greedy matching, # so we'll have to work around it by updating the haystack - src = $$replace(src, $$regex, "\2") + src = $$replace(src, $$regex, "\\2") src_words = $$join(src, $${LITERAL_WHITESPACE}) } } diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index a61ca2e..564c6fe 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -3620,7 +3620,7 @@ QString QWebPage::userAgentForUrl(const QUrl&) const languageName = d->client->ownerWidget()->locale().name(); else languageName = QLocale().name(); - languageName[2] = QLatin1Char('-'); + languageName.replace(QLatin1Char('_'), QLatin1Char('-')); // Application name/version QString appName = QCoreApplication::applicationName(); diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index cc2d39a..b6cbf92 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,24 @@ +2010-05-31 Oswald Buddenhagen + + Reviewed by Simon Hausmann. + + [Qt] Escape backslashes in the .pro files + + qmake in Qt 4.7 warns about unescaped backspaces and deprecates them. + + * Api/DerivedSources.pro: + * docs/docs.pri: + +2010-05-19 Denis Dzyubenko + + Reviewed by Kenneth Rohde Christiansen. + + When creating the UA, do not sassmue the language code is a + two-letter iso639-1 code. + + * Api/qwebpage.cpp: + (QWebPage::userAgentForUrl): + 2010-05-28 Antti Koivisto Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/WebKit/qt/docs/docs.pri b/src/3rdparty/webkit/WebKit/qt/docs/docs.pri index 804817b..a56ddb4 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/docs.pri +++ b/src/3rdparty/webkit/WebKit/qt/docs/docs.pri @@ -3,7 +3,7 @@ include(../../../WebKit.pri) unix { QDOC = SRCDIR=$$PWD/../../.. OUTPUT_DIR=$$OUTPUT_DIR $$(QTDIR)/bin/qdoc3 } else { - QDOC = $$(QTDIR)\bin\qdoc3.exe + QDOC = $$(QTDIR)\\bin\\qdoc3.exe } unix { -- cgit v0.12 From 1fede5dccd56541835046035bb2a8d28d4781e0f Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 31 May 2010 19:51:15 +0200 Subject: Fix Typo --- src/declarative/graphicsitems/qdeclarativetextedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 935b431..2651ee5 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -570,7 +570,7 @@ int QDeclarativeTextEdit::positionAt(int x, int y) const } /*! - \qmlmethod int TextEdit::moveCursorSeletion(int pos) + \qmlmethod int TextEdit::moveCursorSelection(int pos) Moves the cursor to \a position and updates the selection accordingly. (To only move the cursor, set the \l cursorPosition property.) -- cgit v0.12 From 6bd67cf30b1574a114d9852820fe0fb8d3d10c50 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 31 May 2010 20:04:44 +0200 Subject: Fix zoom bug in QML Web Browser demo Zooming out no longer zooms to smaller than the window size. --- demos/declarative/webbrowser/content/FlickableWebView.qml | 4 ++-- demos/declarative/webbrowser/webbrowser.qml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/demos/declarative/webbrowser/content/FlickableWebView.qml b/demos/declarative/webbrowser/content/FlickableWebView.qml index 34e8fff..3a1b515 100644 --- a/demos/declarative/webbrowser/content/FlickableWebView.qml +++ b/demos/declarative/webbrowser/content/FlickableWebView.qml @@ -96,8 +96,8 @@ Flickable { function doZoom(zoom,centerX,centerY) { if (centerX) { - var sc = zoom/contentsScale; - scaleAnim.to = zoom; + var sc = zoom*contentsScale; + scaleAnim.to = sc; flickVX.from = flickable.contentX flickVX.to = Math.max(0,Math.min(centerX-flickable.width/2,webView.width*sc-flickable.width)) finalX.value = flickVX.to diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 36e03bf..a923c92 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -47,7 +47,7 @@ import "content" Rectangle { id: webBrowser - property string urlString : "http://qt.nokia.com/" + property string urlString : "http://www.nokia.com/" width: 800; height: 600 color: "#343434" -- cgit v0.12 From fe77b0e466cf1a19663285d240a634e674e022f1 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 31 May 2010 20:42:41 +0200 Subject: Fix some bugs in the QML Web Browser buttons Now with fewer warnings! Also, the stop button works. --- demos/declarative/webbrowser/content/Button.qml | 2 +- demos/declarative/webbrowser/content/FlickableWebView.qml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/demos/declarative/webbrowser/content/Button.qml b/demos/declarative/webbrowser/content/Button.qml index 976502c..4642cc7 100644 --- a/demos/declarative/webbrowser/content/Button.qml +++ b/demos/declarative/webbrowser/content/Button.qml @@ -49,7 +49,7 @@ Item { Image { id: icon; anchors.centerIn: parent - opacity: action.enabled ? 1.0 : 0.4 + opacity: if(action != undefined) {action.enabled ? 1.0 : 0.4} else 0 } MouseArea { diff --git a/demos/declarative/webbrowser/content/FlickableWebView.qml b/demos/declarative/webbrowser/content/FlickableWebView.qml index 3a1b515..62da2ea 100644 --- a/demos/declarative/webbrowser/content/FlickableWebView.qml +++ b/demos/declarative/webbrowser/content/FlickableWebView.qml @@ -48,6 +48,7 @@ Flickable { property alias progress: webView.progress property alias url: webView.url property alias back: webView.back + property alias stop: webView.stop property alias reload: webView.reload property alias forward: webView.forward -- cgit v0.12 From 3842b53597526bcfc313f208ace808f3f20951ed Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Tue, 1 Jun 2010 10:17:02 +1000 Subject: Fix doc --- doc/src/snippets/declarative/rect-border-width.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/snippets/declarative/rect-border-width.qml b/doc/src/snippets/declarative/rect-border-width.qml index 27a241d..1c42226 100644 --- a/doc/src/snippets/declarative/rect-border-width.qml +++ b/doc/src/snippets/declarative/rect-border-width.qml @@ -6,7 +6,7 @@ Rectangle { color: "yellow" Rectangle { - anchor.fill: parent + anchors.fill: parent anchors.margins: 10 clip: true -- cgit v0.12 From bc1fb594d24b54b9c83994817348b0163ef1a9c5 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 1 Jun 2010 10:31:36 +1000 Subject: Fix example code and image --- doc/src/declarative/pics/repeater-modeldata.png | Bin 2600 -> 3394 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/doc/src/declarative/pics/repeater-modeldata.png b/doc/src/declarative/pics/repeater-modeldata.png index 817f35b..6d8df0d 100644 Binary files a/doc/src/declarative/pics/repeater-modeldata.png and b/doc/src/declarative/pics/repeater-modeldata.png differ -- cgit v0.12 From ff93c3562f2b73abb69b1698f71fc9538ca5d999 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 1 Jun 2010 11:36:29 +1000 Subject: Fix positionAt when autoScroll is use. Task-number: QTBUG-11054 --- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 25a2b49..3a1acc2 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -852,7 +852,7 @@ QRectF QDeclarativeTextInput::positionToRectangle(int x) const int QDeclarativeTextInput::positionAt(int x) const { Q_D(const QDeclarativeTextInput); - return d->control->xToPos(x - d->hscroll); + return d->control->xToPos(x + d->hscroll); } void QDeclarativeTextInputPrivate::focusChanged(bool hasFocus) -- cgit v0.12 From 5f6b50f99a6457c208c7f186db45a2dba690bace Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 1 Jun 2010 12:39:15 +1000 Subject: Test positionAt. Task-number: QTBUG-11127 Task-number: QTBUG-11054 --- .../tst_qdeclarativetextinput.cpp | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 54bb9c1..c943c89 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -63,6 +63,8 @@ private slots: void color(); void selection(); + void positionAt(); + void maxLength(); void masks(); void validators(); @@ -361,6 +363,47 @@ void tst_qdeclarativetextinput::selection() delete textinputObject; } +void tst_qdeclarativetextinput::positionAt() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/positionAt.qml"); + QVERIFY(canvas->rootObject() != 0); + canvas->show(); + canvas->setFocus(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + + QDeclarativeTextInput *textinputObject = qobject_cast(canvas->rootObject()); + QVERIFY(textinputObject != 0); + + // Check autoscrolled... + QFontMetrics fm(textinputObject->font()); + + int pos = textinputObject->positionAt(textinputObject->width()/2); + int diff = abs(fm.width(textinputObject->text()) - (fm.width(textinputObject->text().left(pos))+textinputObject->width()/2)); + + // some tollerance for different fonts. +#ifdef Q_OS_LINUX + QVERIFY(diff < 2); +#else + QVERIFY(diff < 5); +#endif + + // Check without autoscroll... + QEXPECT_FAIL("", "QTBUG-11127", Abort); + textinputObject->setAutoScroll(false); + pos = textinputObject->positionAt(textinputObject->width()/2); + diff = abs(fm.width(textinputObject->text().left(pos))-textinputObject->width()/2); + + // some tollerance for different fonts. +#ifdef Q_OS_LINUX + QVERIFY(diff < 2); +#else + QVERIFY(diff < 5); +#endif + + delete canvas; +} + void tst_qdeclarativetextinput::maxLength() { //QString componentStr = "import Qt 4.7\nTextInput { maximumLength: 10; }"; -- cgit v0.12 From 91cb226780d05f0f7d8fd1875121427ade52c1a8 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 1 Jun 2010 13:06:05 +1000 Subject: Avoid refilling view during model change. The view position is reset to 0 after clear()ing, but this results in refill() being called, effectively undoing the clear(). Fix is to make the model invalid before resetting position. Task-number: QTBUG-11105 --- .../graphicsitems/qdeclarativelistview.cpp | 6 ++- .../tst_qdeclarativelistview.cpp | 48 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 78c56d6..01928a1 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1466,13 +1466,15 @@ void QDeclarativeListView::setModel(const QVariant &model) disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); } d->clear(); + QDeclarativeVisualModel *oldModel = d->model; + d->model = 0; d->setPosition(0); d->modelVariant = model; QObject *object = qvariant_cast(model); QDeclarativeVisualModel *vim = 0; if (object && (vim = qobject_cast(object))) { if (d->ownModel) { - delete d->model; + delete oldModel; d->ownModel = false; } d->model = vim; @@ -1480,6 +1482,8 @@ void QDeclarativeListView::setModel(const QVariant &model) if (!d->ownModel) { d->model = new QDeclarativeVisualDataModel(qmlContext(this), this); d->ownModel = true; + } else { + d->model = oldModel; } if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) dataModel->setModel(model); diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 203760e..2aef9bb 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -91,6 +91,7 @@ private slots: void modelChanges(); void QTBUG_9791(); void manualHighlight(); + void QTBUG_11105(); private: template void items(); @@ -1493,6 +1494,53 @@ void tst_QDeclarativeListView::manualHighlight() QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); } +void tst_QDeclarativeListView::QTBUG_11105() +{ + QDeclarativeView *canvas = createView(); + + TestModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); + qApp->processEvents(); + + QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QDeclarativeItem *viewport = listview->viewport(); + QTRY_VERIFY(viewport != 0); + + // Confirm items positioned correctly + int itemCount = findItems(viewport, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QDeclarativeItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_VERIFY(item->y() == i*20); + } + + listview->positionViewAtIndex(20, QDeclarativeListView::Beginning); + QCOMPARE(listview->contentY(), 280.); + + TestModel model2; + for (int i = 0; i < 5; i++) + model2.addItem("Item" + QString::number(i), ""); + + ctxt->setContextProperty("testModel", &model2); + + itemCount = findItems(viewport, "wrapper").count(); + QCOMPARE(itemCount, 5); + + delete canvas; +} + void tst_QDeclarativeListView::qListModelInterface_items() { items(); -- cgit v0.12 From 785ccda71652de47a161ff31c1a7543ef3cb4953 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 1 Jun 2010 13:16:28 +1000 Subject: License. Pass headers test --- doc/src/snippets/declarative/rect-border-width.qml | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/doc/src/snippets/declarative/rect-border-width.qml b/doc/src/snippets/declarative/rect-border-width.qml index 1c42226..73ce9f6 100644 --- a/doc/src/snippets/declarative/rect-border-width.qml +++ b/doc/src/snippets/declarative/rect-border-width.qml @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + import Qt 4.7 //![0] -- cgit v0.12 From 08d09e02109f18d2a22fa48f331cd7bcfacc154f Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 1 Jun 2010 13:24:21 +1000 Subject: Ensure text color set by S60 input method works for QML Items and QGraphicsWidgets. For QGraphicsWidgets use palette as per QWidget. For QML items leave the color unset so that the default pen is used. Task-number: QTBUG-10997 Reviewed-by: Sami Merila --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 41 ++++++++++++++++++++----- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index d081cfd..4cdc4ad 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -44,6 +44,9 @@ #include "qcoefepinputcontext_p.h" #include #include +#include +#include +#include #include #include @@ -320,12 +323,14 @@ TCoeInputCapabilities QCoeFepInputContext::inputCapabilities() return TCoeInputCapabilities(m_textCapabilities, this, 0); } -static QTextCharFormat qt_TCharFormat2QTextCharFormat(const TCharFormat &cFormat) +static QTextCharFormat qt_TCharFormat2QTextCharFormat(const TCharFormat &cFormat, bool validStyleColor) { QTextCharFormat qFormat; - QBrush foreground(QColor(cFormat.iFontPresentation.iTextColor.Internal())); - qFormat.setForeground(foreground); + if (validStyleColor) { + QBrush foreground(QColor(cFormat.iFontPresentation.iTextColor.Internal())); + qFormat.setForeground(foreground); + } qFormat.setFontStrikeOut(cFormat.iFontPresentation.iStrikethrough == EStrikethroughOn); qFormat.setFontUnderline(cFormat.iFontPresentation.iUnderline == EUnderlineOn); @@ -484,10 +489,30 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) void QCoeFepInputContext::applyFormat(QList *attributes) { TCharFormat cFormat; - const QColor styleTextColor = focusWidget() ? focusWidget()->palette().text().color() : - QApplication::palette("QLineEdit").text().color(); - const TLogicalRgb fontColor(TRgb(styleTextColor.red(), styleTextColor.green(), styleTextColor.blue(), styleTextColor.alpha())); - cFormat.iFontPresentation.iTextColor = fontColor; + QColor styleTextColor; + if (QWidget *focused = focusWidget()) { + QGraphicsView *gv = qobject_cast(focused); + if (!gv) // could be either the QGV or its viewport that has focus + gv = qobject_cast(focused->parentWidget()); + if (gv) { + if (QGraphicsScene *scene = gv->scene()) { + if (QGraphicsItem *focusItem = scene->focusItem()) { + if (focusItem->isWidget()) { + styleTextColor = static_cast(focusItem)->palette().text().color(); + } + } + } + } else { + styleTextColor = focused->palette().text().color(); + } + } else { + styleTextColor = QApplication::palette("QLineEdit").text().color(); + } + + if (styleTextColor.isValid()) { + const TLogicalRgb fontColor(TRgb(styleTextColor.red(), styleTextColor.green(), styleTextColor.blue(), styleTextColor.alpha())); + cFormat.iFontPresentation.iTextColor = fontColor; + } TInt numChars = 0; TInt charPos = 0; @@ -501,7 +526,7 @@ void QCoeFepInputContext::applyFormat(QList *attri attributes->append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, charPos, numChars, - QVariant(qt_TCharFormat2QTextCharFormat(cFormat)))); + QVariant(qt_TCharFormat2QTextCharFormat(cFormat, styleTextColor.isValid())))); charPos += numChars; if (charPos >= m_preeditString.size()) { break; -- cgit v0.12 From 3eafb8d13a51d72af053e19fa4bc66b83f81a923 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 1 Jun 2010 15:51:02 +1000 Subject: Optimization for sci file loading. Reviewed-by: Martin Jones --- src/declarative/graphicsitems/qdeclarativescalegrid.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativescalegrid.cpp b/src/declarative/graphicsitems/qdeclarativescalegrid.cpp index fe89190..a053aa0 100644 --- a/src/declarative/graphicsitems/qdeclarativescalegrid.cpp +++ b/src/declarative/graphicsitems/qdeclarativescalegrid.cpp @@ -130,8 +130,9 @@ QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(QIODevice *data) int b = -1; QString imgFile; - while(!data->atEnd()) { - QString line = QString::fromUtf8(data->readLine().trimmed()); + QByteArray raw; + while(raw = data->readLine(), !raw.isEmpty()) { + QString line = QString::fromUtf8(raw.trimmed()); if (line.isEmpty() || line.startsWith(QLatin1Char('#'))) continue; -- cgit v0.12 From 0400d1474e65a5fd849c1610bdf0717af295f704 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 1 Jun 2010 15:51:40 +1000 Subject: Documentation. --- src/declarative/util/qdeclarativepropertychanges.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp index d99de7a..08f4750 100644 --- a/src/declarative/util/qdeclarativepropertychanges.cpp +++ b/src/declarative/util/qdeclarativepropertychanges.cpp @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE /*! \qmlclass PropertyChanges QDeclarativePropertyChanges \since 4.7 - \brief The PropertyChanges element describes new property values for a state. + \brief The PropertyChanges element describes new property bindings or values for a state. PropertyChanges provides a state change that modifies the properties of an item. @@ -89,6 +89,21 @@ QT_BEGIN_NAMESPACE MouseArea { anchors.fill: parent; onClicked: myText.state = 'myState' } } \endqml + + By default, PropertyChanges will establish new bindings where appropriate. + For example, the following creates a new binding for myItem's height property. + + \qml + PropertyChanges { + target: myItem + height: parent.height + } + \endqml + + If you don't want a binding to be established (and instead just want to assign + the value of the binding at the time the state is entered), + you should set the PropertyChange's \l{PropertyChanges::explicit}{explicit} + property to \c true. State-specific script for signal handlers can also be specified: -- cgit v0.12 From f5aeb6a627ecde5da8c3674b0ba83582f5e4ec84 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 1 Jun 2010 17:09:17 +1000 Subject: Missed file. --- tests/auto/declarative/qdeclarativetextinput/data/positionAt.qml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativetextinput/data/positionAt.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/positionAt.qml b/tests/auto/declarative/qdeclarativetextinput/data/positionAt.qml new file mode 100644 index 0000000..2800351 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextinput/data/positionAt.qml @@ -0,0 +1,8 @@ +import Qt 4.7 + +TextInput{ + focus: true + objectName: "myInput" + width: 50 + text: "This is a long piece of text" +} -- cgit v0.12 From 2e1e1cff3696c93f983db78c99e564a791d5d0ef Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Tue, 1 Jun 2010 09:39:57 +0200 Subject: Avoid unnecessary detach / deep copy in QGraphicsItem::scroll(). QGraphicsItem::scroll() scrolls the cache pixmap when cacheMode is enabled (for ItemCoordinateCache only). Because the pixmap exists both in the cache and in a temp QPixmap copy, the ref count is 2, so the scroll operation has to do a deep copy. To avoid this, we remove the pixmap from the cache before and reinsert it again after calling QPixmap::scroll(). Reviewed-by: Alexis Menard --- src/gui/graphicsview/qgraphicsitem.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 36d21a6..d284a29 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -5687,11 +5687,13 @@ void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect) return; } + // Find pixmap in cache, then remove to avoid deep copy when modifying.s QPixmap cachedPixmap; if (!QPixmapCache::find(cache->key, &cachedPixmap)) { update(rect); return; } + QPixmapCache::remove(cache->key); QRegion exposed; const bool scrollEntirePixmap = rect.isNull(); @@ -5707,7 +5709,8 @@ void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect) cachedPixmap.scroll(dx, dy, scrollRect.translated(-cache->boundingRect.topLeft()), &exposed); } - QPixmapCache::replace(cache->key, cachedPixmap); + // Reinsert into cache. + cache->key = QPixmapCache::insert(cachedPixmap); // Translate the existing expose. for (int i = 0; i < cache->exposed.size(); ++i) { -- cgit v0.12 From 7b581310ceb106664077052abeabbde217ea30dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 1 Jun 2010 09:19:16 +0200 Subject: Make sure we don't pull inn /usr/X11 stuff in the qws mkspek conf Reviewed-by: paul --- mkspecs/common/qws.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mkspecs/common/qws.conf b/mkspecs/common/qws.conf index 96341a7..225f0ff 100644 --- a/mkspecs/common/qws.conf +++ b/mkspecs/common/qws.conf @@ -14,6 +14,10 @@ QMAKE_INCDIR_X11 = QMAKE_LIBDIR_X11 = QMAKE_INCDIR_OPENGL = QMAKE_LIBDIR_OPENGL = +QMAKE_INCDIR_OPENGL_ES1 = +QMAKE_LIBDIR_OPENGL_ES1 = +QMAKE_INCDIR_OPENGL_ES2 = +QMAKE_LIBDIR_OPENGL_ES2 = QMAKE_LIBS_X11 = QMAKE_LIBS_X11SM = QMAKE_LIBS_OPENGL = -- cgit v0.12 From 1b6d41deebdd8103e2d8abb53bd2bb1dd26bd0ae Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Tue, 1 Jun 2010 10:50:30 +0200 Subject: Fix bug in QGraphicsItem::scroll() when called with no QRectF argument. With a null rect argument, QGraphicsItem::scroll() is supposed to scroll the whole item. When using ItemCoordinateCache, currently the only supported mode for scroll optimization, we simple scrolled the whole cache pixmap. Problem: The cache pixmap has a border of 2 pixels. So we scroll the contents _and_ the border. This leaves white/transparent horizontal and vertical line artifacts when scrolling. This change unifies the two cases - partial and full scrolling - into one (shorter) approach that works without scrolling the margin as well. Reviewed-by: Alexis Menard --- src/gui/graphicsview/qgraphicsitem.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index d284a29..9d7354a 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -5695,19 +5695,12 @@ void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect) } QPixmapCache::remove(cache->key); + QRect scrollRect = (rect.isNull() ? boundingRect() : rect).toAlignedRect(); + if (!scrollRect.intersects(cache->boundingRect)) + return; // Nothing to scroll. + QRegion exposed; - const bool scrollEntirePixmap = rect.isNull(); - if (scrollEntirePixmap) { - // Scroll entire pixmap. - cachedPixmap.scroll(dx, dy, cachedPixmap.rect(), &exposed); - } else { - if (!rect.intersects(cache->boundingRect)) - return; // Nothing to scroll. - // Scroll sub-rect of pixmap. The rect is in item coordinates - // so we have to translate it to pixmap coordinates. - QRect scrollRect = rect.toAlignedRect(); - cachedPixmap.scroll(dx, dy, scrollRect.translated(-cache->boundingRect.topLeft()), &exposed); - } + cachedPixmap.scroll(dx, dy, scrollRect.translated(-cache->boundingRect.topLeft()), &exposed); // Reinsert into cache. cache->key = QPixmapCache::insert(cachedPixmap); @@ -5715,7 +5708,7 @@ void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect) // Translate the existing expose. for (int i = 0; i < cache->exposed.size(); ++i) { QRectF &e = cache->exposed[i]; - if (!scrollEntirePixmap && !e.intersects(rect)) + if (!rect.isNull() && !e.intersects(rect)) continue; e.translate(dx, dy); } -- cgit v0.12 From 805126ebc2aa9a683edefbc21d4ee7362ae26f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 1 Jun 2010 10:50:47 +0200 Subject: Fixed a problem where QPixmaps where re-bound in non-sharing contexts. If you have two non-sharing GL contexts and try to draw the same QPixmap in both of them, they will wind up competing for a spot in the texture cache. Make the context group a part of the cache key to avoid that. Task-number: QT-3462 Reviewed-by: Kim --- src/opengl/qgl.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++------- src/opengl/qgl_p.h | 36 +++++++++++++++++++++++------------- 2 files changed, 67 insertions(+), 20 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 922a96c..c8502c2 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -91,6 +91,7 @@ #include "qcolormap.h" #include "qfile.h" #include "qlibrary.h" +#include QT_BEGIN_NAMESPACE @@ -1515,10 +1516,33 @@ bool operator!=(const QGLFormat& a, const QGLFormat& b) return !(a == b); } +struct QGLContextGroupList { + void append(QGLContextGroup *group) { + QMutexLocker locker(&m_mutex); + m_list.append(group); + } + + void remove(QGLContextGroup *group) { + QMutexLocker locker(&m_mutex); + m_list.removeOne(group); + } + + QList m_list; + QMutex m_mutex; +}; + +Q_GLOBAL_STATIC(QGLContextGroupList, qt_context_groups) + /***************************************************************************** QGLContext implementation *****************************************************************************/ +QGLContextGroup::QGLContextGroup(const QGLContext *context) + : m_context(context), m_guards(0), m_refs(1) +{ + qt_context_groups()->append(this); +} + QGLContextGroup::~QGLContextGroup() { // Clear any remaining QGLSharedResourceGuard objects on the group. @@ -1528,6 +1552,7 @@ QGLContextGroup::~QGLContextGroup() guard->m_id = 0; guard = guard->m_next; } + qt_context_groups()->remove(this); } void QGLContextGroup::addGuard(QGLSharedResourceGuard *guard) @@ -1736,7 +1761,7 @@ void QGLTextureCache::insert(QGLContext* ctx, qint64 key, QGLTexture* texture, i QWriteLocker locker(&m_lock); if (m_cache.totalCost() + cost > m_cache.maxCost()) { // the cache is full - make an attempt to remove something - const QList keys = m_cache.keys(); + const QList keys = m_cache.keys(); int i = 0; while (i < m_cache.count() && (m_cache.totalCost() + cost > m_cache.maxCost())) { @@ -1746,13 +1771,26 @@ void QGLTextureCache::insert(QGLContext* ctx, qint64 key, QGLTexture* texture, i ++i; } } - m_cache.insert(key, texture, cost); + const QGLTextureCacheKey cacheKey = {key, QGLContextPrivate::contextGroup(ctx)}; + m_cache.insert(cacheKey, texture, cost); +} + +void QGLTextureCache::remove(qint64 key) +{ + QWriteLocker locker(&m_lock); + QMutexLocker groupLocker(&qt_context_groups()->m_mutex); + QList::const_iterator it = qt_context_groups()->m_list.constBegin(); + while (it != qt_context_groups()->m_list.constEnd()) { + const QGLTextureCacheKey cacheKey = {key, *it}; + m_cache.remove(cacheKey); + ++it; + } } bool QGLTextureCache::remove(QGLContext* ctx, GLuint textureId) { QWriteLocker locker(&m_lock); - QList keys = m_cache.keys(); + QList keys = m_cache.keys(); for (int i = 0; i < keys.size(); ++i) { QGLTexture *tex = m_cache.object(keys.at(i)); if (tex->id == textureId && tex->context == ctx) { @@ -1767,9 +1805,9 @@ bool QGLTextureCache::remove(QGLContext* ctx, GLuint textureId) void QGLTextureCache::removeContextTextures(QGLContext* ctx) { QWriteLocker locker(&m_lock); - QList keys = m_cache.keys(); + QList keys = m_cache.keys(); for (int i = 0; i < keys.size(); ++i) { - const qint64 &key = keys.at(i); + const QGLTextureCacheKey &key = keys.at(i); if (m_cache.object(key)->context == ctx) m_cache.remove(key); } @@ -1782,7 +1820,6 @@ void QGLTextureCache::removeContextTextures(QGLContext* ctx) void QGLTextureCache::cleanupTexturesForCacheKey(qint64 cacheKey) { qt_gl_texture_cache()->remove(cacheKey); - Q_ASSERT(qt_gl_texture_cache()->getTexture(cacheKey) == 0); } @@ -2425,7 +2462,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G QGLTexture *QGLContextPrivate::textureCacheLookup(const qint64 key, GLenum target) { Q_Q(QGLContext); - QGLTexture *texture = QGLTextureCache::instance()->getTexture(key); + QGLTexture *texture = QGLTextureCache::instance()->getTexture(q, key); if (texture && texture->target == target && (texture->context == q || QGLContext::areSharing(q, texture->context))) { diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index d92f963..16c225f 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -230,7 +230,7 @@ public: static void addShare(const QGLContext *context, const QGLContext *share); static void removeShare(const QGLContext *context); private: - QGLContextGroup(const QGLContext *context) : m_context(context), m_guards(0), m_refs(1) { } + QGLContextGroup(const QGLContext *context); QGLExtensionFuncs m_extensionFuncs; const QGLContext *m_context; // context group's representative @@ -522,17 +522,33 @@ public: QSize bindCompressedTexturePVR(const char *buf, int len); }; +struct QGLTextureCacheKey { + qint64 key; + QGLContextGroup *group; +}; + +inline bool operator==(const QGLTextureCacheKey &a, const QGLTextureCacheKey &b) +{ + return a.key == b.key && a.group == b.group; +} + +inline uint qHash(const QGLTextureCacheKey &key) +{ + return qHash(key.key) ^ qHash(key.group); +} + + class Q_AUTOTEST_EXPORT QGLTextureCache { public: QGLTextureCache(); ~QGLTextureCache(); void insert(QGLContext *ctx, qint64 key, QGLTexture *texture, int cost); - inline void remove(quint64 key); + void remove(qint64 key); inline int size(); inline void setMaxCost(int newMax); inline int maxCost(); - inline QGLTexture* getTexture(quint64 key); + inline QGLTexture* getTexture(QGLContext *ctx, qint64 key); bool remove(QGLContext *ctx, GLuint textureId); void removeContextTextures(QGLContext *ctx); @@ -542,7 +558,7 @@ public: static void cleanupBeforePixmapDestruction(QPixmapData* pixmap); private: - QCache m_cache; + QCache m_cache; QReadWriteLock m_lock; }; @@ -563,19 +579,13 @@ int QGLTextureCache::maxCost() return m_cache.maxCost(); } -QGLTexture* QGLTextureCache::getTexture(quint64 key) +QGLTexture* QGLTextureCache::getTexture(QGLContext *ctx, qint64 key) { QReadLocker locker(&m_lock); - return m_cache.object(key); + const QGLTextureCacheKey cacheKey = {key, QGLContextPrivate::contextGroup(ctx)}; + return m_cache.object(cacheKey); } -void QGLTextureCache::remove(quint64 key) -{ - QWriteLocker locker(&m_lock); - m_cache.remove(key); -} - - extern Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine(); bool qt_gl_preferGL2Engine(); -- cgit v0.12 From f5cc4e9a020e78f0bf0d929ff2780b5bf01749ae Mon Sep 17 00:00:00 2001 From: Andreas Hartmetz Date: Tue, 1 Jun 2010 10:35:30 +0200 Subject: Added environment variable graphicssystem switch. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add environment variable switch for graphicssystem so a default can be set at runtime without passing a command-line parameter. Merge-request: 622 Reviewed-by: Samuel Rødal --- src/gui/kernel/qapplication.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index a2c058a..09a3bfe 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -780,6 +780,9 @@ void QApplicationPrivate::construct( qt_is_gui_used = (qt_appType != QApplication::Tty); process_cmdline(); + // the environment variable has the lowest precedence of runtime graphicssystem switches + if (graphics_system_name.isEmpty()) + graphics_system_name = QString::fromLocal8Bit(qgetenv("QT_GRAPHICSSYSTEM")); // Must be called before initialize() qt_init(this, qt_appType #ifdef Q_WS_X11 @@ -1560,10 +1563,18 @@ QStyle* QApplication::setStyle(const QString& style) on-screen widgets and QPixmaps. The available systems are \c{"native"}, \c{"raster"} and \c{"opengl"}. - This function call overrides both the application commandline - \c{-graphicssystem} switch and the configure \c{-graphicssystem} switch. + There are several ways to set the graphics backend, in order of decreasing + precedence: + \list + \o the application commandline \c{-graphicssystem} switch + \o QApplication::setGraphicsSystem() + \o the QT_GRAPHICSSYSTEM environment variable + \o the Qt configure \c{-graphicssystem} switch + \endlist + If the highest precedence switch sets an invalid name, the error will be + ignored and the default backend will be used. - \warning This function must be called before the QApplication constructor + \warning This function is only effective before the QApplication constructor is called. \note The \c{"opengl"} option is currently experimental. -- cgit v0.12 From 94f0369e21cb4db41f6f10358ba1967fe1d0e8a1 Mon Sep 17 00:00:00 2001 From: John Brooks Date: Sun, 2 May 2010 00:19:25 -0600 Subject: Doc: QAbstractItemModel: note unexpected behavior with beginMoveRows The meaning of the destinationChild parameter differs when moving down in the same parent, contrary to statements by the previous docs. Reviewed-by: Olivier Goffart Merge-Request: 600 --- src/corelib/kernel/qabstractitemmodel.cpp | 92 +++++++++++++++++-------------- 1 file changed, 52 insertions(+), 40 deletions(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 24c26b6..b0e2f48 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -2508,29 +2508,35 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star When reimplementing a subclass, this method simplifies moving entities in your model. This method is responsible for moving persistent indexes in the model, which you would otherwise be - required to do yourself. - - Using beginMoveRows and endMoveRows is an alternative to emitting - layoutAboutToBeChanged and layoutChanged directly along with - changePersistentIndexes. layoutAboutToBeChanged is emitted by - this method for compatibility reasons. + required to do yourself. Using beginMoveRows and endMoveRows + is an alternative to emitting layoutAboutToBeChanged and + layoutChanged directly along with changePersistentIndexes. + layoutAboutToBeChanged is emitted by this method for compatibility + reasons. The \a sourceParent index corresponds to the parent from which the - rows are moved; \a sourceFirst and \a sourceLast are the row - numbers of the rows to be moved. The \a destinationParent index - corresponds to the parent into which the rows are moved. The \a + rows are moved; \a sourceFirst and \a sourceLast are the first and last + row numbers of the rows to be moved. The \a destinationParent index + corresponds to the parent into which those rows are moved. The \a destinationChild is the row to which the rows will be moved. That is, the index at row \a sourceFirst in \a sourceParent will become - row \a destinationChild in \a destinationParent. Its siblings will - be moved correspondingly. - - Note that \a sourceParent and \a destinationParent may be the - same, in which case you must ensure that the \a destinationChild is - not within the range of \a sourceFirst and \a sourceLast. You - must also ensure that you do not attempt to move a row to one of - its own children or ancestors. This method returns false if either - condition is true, in which case you should abort your move - operation. + row \a destinationChild in \a destinationParent, followed by all other + rows up to \a sourceLast. + + However, when moving rows down in the same parent (\a sourceParent + and \a destinationParent are equal), the rows will be placed before the + \a destinationChild index. That is, if you wish to move rows 0 and 1 so + they will become rows 1 and 2, \a destinationChild should be 3. In this + case, the new index for the source row \c i (which is between + \a sourceFirst and \a sourceLast) is equal to + \c {(destinationChild-sourceLast-1+i)}. + + Note that if \a sourceParent and \a destinationParent are the same, + you must ensure that the \a destinationChild is not within the range + of \a sourceFirst and \a sourceLast + 1. You must also ensure that you + do not attempt to move a row to one of its own children or ancestors. + This method returns false if either condition is true, in which case you + should abort your move operation. \table 80% \row @@ -2761,29 +2767,35 @@ void QAbstractItemModel::endRemoveColumns() When reimplementing a subclass, this method simplifies moving entities in your model. This method is responsible for moving persistent indexes in the model, which you would otherwise be - required to do yourself. - - Using beginMoveColumns and endMoveColumns is an alternative to - emitting layoutAboutToBeChanged and layoutChanged directly along - with changePersistentIndexes. layoutAboutToBeChanged is emitted - by this method for compatibility reasons. + required to do yourself. Using beginMoveRows and endMoveRows + is an alternative to emitting layoutAboutToBeChanged and + layoutChanged directly along with changePersistentIndexes. + layoutAboutToBeChanged is emitted by this method for compatibility + reasons. The \a sourceParent index corresponds to the parent from which the - columns are moved; \a sourceFirst and \a sourceLast are the column - numbers of the columns to be moved. The \a destinationParent index - corresponds to the parent into which the columns are moved. The \a - destinationChild is the column to which the columns will be - moved. That is, the index at column \a sourceFirst in \a - sourceParent will become column \a destinationChild in \a - destinationParent. Its siblings will be moved correspondingly. - - Note that \a sourceParent and \a destinationParent may be the - same, in which case you must ensure that the \a destinationChild - is not within the range of \a sourceFirst and \a sourceLast. You - must also ensure that you do not attempt to move a row to one of - its own chilren or ancestors. This method returns false if either - condition is true, in which case you should abort your move - operation. + columns are moved; \a sourceFirst and \a sourceLast are the first and last + column numbers of the columns to be moved. The \a destinationParent index + corresponds to the parent into which those columns are moved. The \a + destinationChild is the column to which the columns will be moved. That + is, the index at column \a sourceFirst in \a sourceParent will become + column \a destinationChild in \a destinationParent, followed by all other + columns up to \a sourceLast. + + However, when moving columns down in the same parent (\a sourceParent + and \a destinationParent are equal), the columnss will be placed before the + \a destinationChild index. That is, if you wish to move columns 0 and 1 so + they will become columns 1 and 2, \a destinationChild should be 3. In this + case, the new index for the source column \c i (which is between + \a sourceFirst and \a sourceLast) is equal to + \c {(destinationChild-sourceLast-1+i)}. + + Note that if \a sourceParent and \a destinationParent are the same, + you must ensure that the \a destinationChild is not within the range + of \a sourceFirst and \a sourceLast + 1. You must also ensure that you + do not attempt to move a column to one of its own children or ancestors. + This method returns false if either condition is true, in which case you + should abort your move operation. \sa endMoveColumns() -- cgit v0.12 From 4e85c1015c2dfa58560e0567af4fa17a412441a5 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Tue, 1 Jun 2010 12:16:17 +0200 Subject: Doc: Fixed a typo Task-number: QTBUG-10951 --- doc/src/examples/waitconditions.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/examples/waitconditions.qdoc b/doc/src/examples/waitconditions.qdoc index 1d3ff84..d4f680e 100644 --- a/doc/src/examples/waitconditions.qdoc +++ b/doc/src/examples/waitconditions.qdoc @@ -92,7 +92,7 @@ Together, the wait conditions, the mutex, and the \c numUsedBytes counter ensure that the producer is never more than \c BufferSize bytes ahead of the consumer, and that the consumer never reads - data that the consumer hasn't generated yet. + data that the producer hasn't generated yet. \section1 Producer Class -- cgit v0.12