From 67666e78b2667ef6220372d2042f0477adfb09f3 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 1 Jun 2010 21:19:27 +0200 Subject: Slight addition to the docs. --- doc/src/declarative/qtbinding.qdoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc index 7d696d7..784c59a 100644 --- a/doc/src/declarative/qtbinding.qdoc +++ b/doc/src/declarative/qtbinding.qdoc @@ -269,5 +269,10 @@ For example: \c [project/main.qml] \snippet doc/src/snippets/declarative/qtbinding/resources/main.qml 0 +Note that the resource system cannot be accessed from QML directly. If the main QML file is +loaded as a resource, all files specifed as relative paths in QML will also be loaded from +the resource system. Using the resource system is completely transparent to the QML layer. +This also means that if the main QML file is not loaded as a resource then files in the resource +system cannot be accessed from QML. */ -- cgit v0.12 From 01506a3b212d449d65df1131b49af0e174e45275 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 3 Jun 2010 19:47:54 +0200 Subject: Enhance docs --- doc/src/declarative/extending.qdoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index 574b0b2..af5b437 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -425,6 +425,9 @@ value will not be accessible from script. \l {Extending QML - Signal Support Example} shows the complete code used to implement the onPartyStarted signal property. +If you want to use signals from items not created in QML, you can access their +signals with the \l {Connections} element. + \section1 Property Value Sources \snippet examples/declarative/cppextensions/referenceexamples/valuesource/example.qml 0 -- cgit v0.12 From cfbca0bd925b76fff533dc093c67ad72dbd73de5 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 16 Jun 2010 16:33:19 +1000 Subject: Stopping a flick resulted in the next click being consumed. Task-number: QTBUG-11390 --- src/declarative/graphicsitems/qdeclarativeflickable.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index fdc1444..6dfd4d9 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -1214,6 +1214,7 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) default: break; } + stealThisEvent = d->stealMouse; // Update stealThisEvent and grabber in case changed by function calls above grabber = qobject_cast(s->mouseGrabberItem()); if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) { d->clearDelayedPress(); -- cgit v0.12 From 1937adaab5861ced44813c6a4b0bff1c3750ecd3 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 16 Jun 2010 17:25:13 +1000 Subject: Move knowledge of QGraphicsObject out of qml engine --- demos/declarative/snake/content/Link.qml | 2 ++ .../graphicsitems/qdeclarativeitemsmodule.cpp | 16 ++++++++++++++ src/declarative/qml/qdeclarativecomponent.cpp | 25 +++++++++++++--------- src/declarative/qml/qdeclarativeengine.cpp | 11 +++++----- src/declarative/qml/qdeclarativemetatype.cpp | 19 ++++++++++++++++ src/declarative/qml/qdeclarativemetatype_p.h | 2 ++ src/declarative/qml/qdeclarativeprivate.h | 4 ++++ 7 files changed, 64 insertions(+), 15 deletions(-) diff --git a/demos/declarative/snake/content/Link.qml b/demos/declarative/snake/content/Link.qml index 9aa6006..f4d7165 100644 --- a/demos/declarative/snake/content/Link.qml +++ b/demos/declarative/snake/content/Link.qml @@ -73,12 +73,14 @@ Item { id:link } } + /* transform: Rotation { id: actualImageRotation origin.x: width/2; origin.y: height/2; angle: rotation * 90 Behavior on angle { NumberAnimation { duration: spawned ? 200 : 0} } } + */ } Image { diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp index 0be8dac..b198077 100644 --- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp @@ -79,8 +79,24 @@ #endif #include "private/qdeclarativeanchors_p.h" +static QDeclarativePrivate::AutoParentResult qgraphicsobject_autoParent(QObject *obj, QObject *parent) +{ + QGraphicsObject* gobj = qobject_cast(obj); + if (!gobj) + return QDeclarativePrivate::IncompatibleObject; + + QGraphicsObject* gparent = qobject_cast(parent); + if (!gparent) + return QDeclarativePrivate::IncompatibleParent; + + gobj->setParentItem(gparent); + return QDeclarativePrivate::Parented; +} + void QDeclarativeItemModule::defineModule() { + QDeclarativePrivate::registerAutoParentFunction(qgraphicsobject_autoParent); + #ifdef QT_NO_MOVIE qmlRegisterTypeNotAvailable("Qt",4,7,"AnimatedImage", qApp->translate("QDeclarativeAnimatedImage","Qt was built without support for QMovie")); diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 55ee783..b4919ff 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -60,7 +60,6 @@ #include #include #include -#include QT_BEGIN_NAMESPACE @@ -579,20 +578,26 @@ QScriptValue QDeclarativeComponent::createObject(QObject* parent) if (!ret) return QScriptValue(QScriptValue::NullValue); - QGraphicsObject* gobj = qobject_cast(ret); - bool needParent = (gobj != 0); - if(parent){ + + if (parent) { ret->setParent(parent); - if (gobj) { - QGraphicsObject* gparent = qobject_cast(parent); - if(gparent){ - gobj->setParentItem(gparent); + QList functions = QDeclarativeMetaType::parentFunctions(); + + bool needParent = false; + + for (int ii = 0; ii < functions.count(); ++ii) { + QDeclarativePrivate::AutoParentResult res = functions.at(ii)(ret, parent); + if (res == QDeclarativePrivate::Parented) { needParent = false; + break; + } else if (res == QDeclarativePrivate::IncompatibleParent) { + needParent = true; } } + + if (needParent) + qWarning("QDeclarativeComponent: Created graphical object was not placed in the graphics scene."); } - if(needParent) - qWarning("QDeclarativeComponent: Created graphical object was not placed in the graphics scene."); QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(d->engine); QDeclarativeData::get(ret, true)->setImplicitDestructible(); diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 0715624..5c4d229 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -93,7 +93,6 @@ #include #include #include -#include #include #include @@ -1195,10 +1194,12 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS Q_ASSERT(obj); obj->setParent(parentArg); - QGraphicsObject* gobj = qobject_cast(obj); - QGraphicsObject* gparent = qobject_cast(parentArg); - if(gobj && gparent) - gobj->setParentItem(gparent); + + QList functions = QDeclarativeMetaType::parentFunctions(); + for (int ii = 0; ii < functions.count(); ++ii) { + if (QDeclarativePrivate::Parented == functions.at(ii)(obj, parentArg)) + break; + } QDeclarativeData::get(obj, true)->setImplicitDestructible(); return activeEnginePriv->objectClass->newQObject(obj, QMetaType::QObjectStar); diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp index 5fcb7ee..c32cab6 100644 --- a/src/declarative/qml/qdeclarativemetatype.cpp +++ b/src/declarative/qml/qdeclarativemetatype.cpp @@ -112,6 +112,8 @@ struct QDeclarativeMetaTypeData QBitArray objects; QBitArray interfaces; QBitArray lists; + + QList parentFunctions; }; Q_GLOBAL_STATIC(QDeclarativeMetaTypeData, metaTypeData) Q_GLOBAL_STATIC(QReadWriteLock, metaTypeDataLock) @@ -483,6 +485,16 @@ int QDeclarativeType::index() const return d->m_index; } +int QDeclarativePrivate::registerAutoParentFunction(AutoParentFunction function) +{ + QWriteLocker lock(metaTypeDataLock()); + QDeclarativeMetaTypeData *data = metaTypeData(); + + data->parentFunctions.append(function); + + return data->parentFunctions.count() - 1; +} + int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterInterface &interface) { if (interface.version > 0) @@ -583,6 +595,13 @@ bool QDeclarativeMetaType::isModule(const QByteArray &module, int versionMajor, ((*it).vmajor_min == versionMajor && (*it).vminor_min <= versionMinor)))); } +QList QDeclarativeMetaType::parentFunctions() +{ + QReadLocker lock(metaTypeDataLock()); + QDeclarativeMetaTypeData *data = metaTypeData(); + return data->parentFunctions; +} + QObject *QDeclarativeMetaType::toQObject(const QVariant &v, bool *ok) { if (!isQObject(v.userType())) { diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h index bf6a700..4c98b6f 100644 --- a/src/declarative/qml/qdeclarativemetatype_p.h +++ b/src/declarative/qml/qdeclarativemetatype_p.h @@ -99,6 +99,8 @@ public: static StringConverter customStringConverter(int); static bool isModule(const QByteArray &module, int versionMajor, int versionMinor); + + static QList parentFunctions(); }; class QDeclarativeTypePrivate; diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h index e657dd5..cd859fe 100644 --- a/src/declarative/qml/qdeclarativeprivate.h +++ b/src/declarative/qml/qdeclarativeprivate.h @@ -214,6 +214,10 @@ namespace QDeclarativePrivate const char *iid; }; + enum AutoParentResult { Parented, IncompatibleObject, IncompatibleParent }; + typedef AutoParentResult (*AutoParentFunction)(QObject *object, QObject *parent); + + int Q_DECLARATIVE_EXPORT registerAutoParentFunction(AutoParentFunction); int Q_DECLARATIVE_EXPORT registerType(const RegisterType &); int Q_DECLARATIVE_EXPORT registerType(const RegisterInterface &); -- cgit v0.12 From 183abff6ffcb020b8f0c4041cc82bba0d3b03863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Wed, 16 Jun 2010 10:05:44 +0200 Subject: Fixed problem with wrong size hints when items were removed. The reason was that the row/column count was not updated after an item was removed. (Note that qgraphicslinearlayout already did this, so we just follow the same pattern, except that the code for QGraphicsGridLayout is a bit more complex... Task-number: QTBUG-10314 Reviewed-by: Alexis Menard --- src/gui/graphicsview/qgraphicsgridlayout.cpp | 12 +++ src/gui/graphicsview/qgraphicslinearlayout.cpp | 2 +- src/gui/graphicsview/qgridlayoutengine_p.h | 4 +- .../tst_qgraphicsgridlayout.cpp | 86 ++++++++++++++++------ 4 files changed, 79 insertions(+), 25 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsgridlayout.cpp b/src/gui/graphicsview/qgraphicsgridlayout.cpp index 6ca799d..83db3ec 100644 --- a/src/gui/graphicsview/qgraphicsgridlayout.cpp +++ b/src/gui/graphicsview/qgraphicsgridlayout.cpp @@ -572,6 +572,18 @@ void QGraphicsGridLayout::removeAt(int index) if (QGraphicsLayoutItem *layoutItem = gridItem->layoutItem()) layoutItem->setParentLayoutItem(0); d->engine.removeItem(gridItem); + + // recalculate rowInfo.count if we remove an item that is on the right/bottommost row + for (int j = 0; j < NOrientations; ++j) { + // 0: Hor, 1: Ver + const Qt::Orientation orient = (j == 0 ? Qt::Horizontal : Qt::Vertical); + const int oldCount = d->engine.rowCount(orient); + if (gridItem->lastRow(orient) == oldCount - 1) { + const int newCount = d->engine.effectiveLastRow(orient) + 1; + d->engine.removeRows(newCount, oldCount - newCount, orient); + } + } + delete gridItem; invalidate(); } diff --git a/src/gui/graphicsview/qgraphicslinearlayout.cpp b/src/gui/graphicsview/qgraphicslinearlayout.cpp index 9722683..b828722 100644 --- a/src/gui/graphicsview/qgraphicslinearlayout.cpp +++ b/src/gui/graphicsview/qgraphicslinearlayout.cpp @@ -147,7 +147,7 @@ void QGraphicsLinearLayoutPrivate::removeGridItem(QGridLayoutItem *gridItem) { int index = gridItem->firstRow(orientation); engine.removeItem(gridItem); - engine.removeRow(index, orientation); + engine.removeRows(index, 1, orientation); } void QGraphicsLinearLayoutPrivate::fixIndex(int *index) const diff --git a/src/gui/graphicsview/qgridlayoutengine_p.h b/src/gui/graphicsview/qgridlayoutengine_p.h index cbf704e..9ac9a8e 100644 --- a/src/gui/graphicsview/qgridlayoutengine_p.h +++ b/src/gui/graphicsview/qgridlayoutengine_p.h @@ -363,8 +363,8 @@ public: QGridLayoutItem *itemAt(int row, int column, Qt::Orientation orientation = Qt::Vertical) const; inline void insertRow(int row, Qt::Orientation orientation = Qt::Vertical) { insertOrRemoveRows(row, +1, orientation); } - inline void removeRow(int row, Qt::Orientation orientation = Qt::Vertical) - { insertOrRemoveRows(row, -1, orientation); } + inline void removeRows(int row, int count, Qt::Orientation orientation) + { insertOrRemoveRows(row, -count, orientation); } void invalidate(); void setGeometries(const QLayoutStyleInfo &styleInfo, const QRectF &contentsGeometry); diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 8127f84..b9a5c66 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -741,31 +741,73 @@ void tst_QGraphicsGridLayout::setColumnFixedWidth() // public qreal columnSpacing(int column) const void tst_QGraphicsGridLayout::columnSpacing() { - QGraphicsScene scene; - QGraphicsView view(&scene); - QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); - QGraphicsGridLayout *layout = new QGraphicsGridLayout(); - scene.addItem(widget); - widget->setLayout(layout); - populateLayout(layout, 3, 2); - layout->setContentsMargins(0, 0, 0, 0); - layout->setSpacing(0); - QCOMPARE(layout->columnSpacing(0), 0.0); + { + QGraphicsScene scene; + QGraphicsView view(&scene); + QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); + QGraphicsGridLayout *layout = new QGraphicsGridLayout(); + scene.addItem(widget); + widget->setLayout(layout); + populateLayout(layout, 3, 2); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + QCOMPARE(layout->columnSpacing(0), 0.0); + + layout->setColumnSpacing(0, 20); + view.show(); + widget->show(); + widget->resize(widget->effectiveSizeHint(Qt::PreferredSize)); + QApplication::processEvents(); - layout->setColumnSpacing(0, 20); - view.show(); - widget->show(); - widget->resize(widget->effectiveSizeHint(Qt::PreferredSize)); - QApplication::processEvents(); + QCOMPARE(layout->itemAt(0,0)->geometry().left(), 0.0); + QCOMPARE(layout->itemAt(0,0)->geometry().right(), 25.0); + QCOMPARE(layout->itemAt(0,1)->geometry().left(), 45.0); + QCOMPARE(layout->itemAt(0,1)->geometry().right(), 70.0); + QCOMPARE(layout->itemAt(0,2)->geometry().left(), 70.0); + QCOMPARE(layout->itemAt(0,2)->geometry().right(), 95.0); - QCOMPARE(layout->itemAt(0,0)->geometry().left(), 0.0); - QCOMPARE(layout->itemAt(0,0)->geometry().right(), 25.0); - QCOMPARE(layout->itemAt(0,1)->geometry().left(), 45.0); - QCOMPARE(layout->itemAt(0,1)->geometry().right(), 70.0); - QCOMPARE(layout->itemAt(0,2)->geometry().left(), 70.0); - QCOMPARE(layout->itemAt(0,2)->geometry().right(), 95.0); + delete widget; + } + + { + // don't include items and spacings that was previously part of the layout + // (horizontal) + QGraphicsGridLayout *layout = new QGraphicsGridLayout; + populateLayout(layout, 3, 1); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + layout->setColumnSpacing(0, 10); + layout->setColumnSpacing(1, 10); + layout->setColumnSpacing(2, 10); + layout->setColumnSpacing(3, 10); + QCOMPARE(layout->preferredSize(), QSizeF(95, 25)); + layout->removeAt(2); + QCOMPARE(layout->preferredSize(), QSizeF(60, 25)); + layout->removeAt(1); + QCOMPARE(layout->preferredSize(), QSizeF(25, 25)); + delete layout; + } + { + // don't include items and spacings that was previously part of the layout + // (vertical) + QGraphicsGridLayout *layout = new QGraphicsGridLayout; + populateLayout(layout, 2, 2); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + layout->setColumnSpacing(0, 10); + layout->setColumnSpacing(1, 10); + layout->setRowSpacing(0, 10); + layout->setRowSpacing(1, 10); + QCOMPARE(layout->preferredSize(), QSizeF(60, 60)); + layout->removeAt(3); + QCOMPARE(layout->preferredSize(), QSizeF(60, 60)); + layout->removeAt(2); + QCOMPARE(layout->preferredSize(), QSizeF(60, 25)); + layout->removeAt(1); + QCOMPARE(layout->preferredSize(), QSizeF(25, 25)); + delete layout; + } - delete widget; } // public int columnStretchFactor(int column) const -- cgit v0.12 From bc4c5a2d9c5d3841948bc4443f2229d8d6ec0e95 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 16 Jun 2010 12:18:40 +0200 Subject: Fix autoScroll implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The scrolling should not be calculated inside the paint event, this leads to some incorrect behaviour. It is now calculated separately when needed. Patch actually written by Alexis, and I reviewed it. Task-number: QTBUG-11127 Reviewed-by: Alexis Ménard --- .../graphicsitems/qdeclarativetextinput.cpp | 88 +++++++++++++--------- .../graphicsitems/qdeclarativetextinput_p_p.h | 1 + .../tst_qdeclarativetextinput.cpp | 1 - 3 files changed, 54 insertions(+), 36 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index cba01ef..033e12c 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -100,6 +100,7 @@ void QDeclarativeTextInput::setText(const QString &s) if(s == text()) return; d->control->setText(s); + d->updateHorizontalScroll(); //emit textChanged(); } @@ -337,6 +338,7 @@ void QDeclarativeTextInput::setHAlign(HAlignment align) return; d->hAlign = align; updateRect(); + d->updateHorizontalScroll(); emit horizontalAlignmentChanged(d->hAlign); } @@ -554,7 +556,9 @@ void QDeclarativeTextInput::setAutoScroll(bool b) return; d->autoScroll = b; - + d->updateHorizontalScroll(); + //We need to repaint so that the scrolling is taking into account. + updateSize(true); emit autoScrollChanged(d->autoScroll); } @@ -836,6 +840,7 @@ void QDeclarativeTextInput::moveCursor() Q_D(QDeclarativeTextInput); if(!d->cursorItem) return; + d->updateHorizontalScroll(); d->cursorItem->setX(d->control->cursorToX() - d->hscroll); } @@ -845,7 +850,6 @@ void QDeclarativeTextInput::moveCursor() 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(), @@ -1006,61 +1010,73 @@ void QDeclarativeTextInput::geometryChanged(const QRectF &newGeometry, QDeclarativePaintedItem::geometryChanged(newGeometry, oldGeometry); } -void QDeclarativeTextInput::drawContents(QPainter *p, const QRect &r) +void QDeclarativeTextInputPrivate::updateHorizontalScroll() { - Q_D(QDeclarativeTextInput); - p->setRenderHint(QPainter::TextAntialiasing, true); - p->save(); - p->setPen(QPen(d->color)); - int flags = QLineControl::DrawText; - if(!isReadOnly() && d->cursorVisible && !d->cursorItem) - flags |= QLineControl::DrawCursor; - if (d->control->hasSelectedText()) - flags |= QLineControl::DrawSelections; - QPoint offset = QPoint(0,0); - QFontMetrics fm = QFontMetrics(d->font); - int cix = qRound(d->control->cursorToX()); - QRect br(boundingRect().toRect()); + Q_Q(QDeclarativeTextInput); + QFontMetrics fm = QFontMetrics(font); + int cix = qRound(control->cursorToX()); + QRect br(q->boundingRect().toRect()); //###Is this using bearing appropriately? int minLB = qMax(0, -fm.minLeftBearing()); int minRB = qMax(0, -fm.minRightBearing()); - int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB; - if (d->autoScroll) { + int widthUsed = qRound(control->naturalTextWidth()) + 1 + minRB; + if (autoScroll) { if ((minLB + widthUsed) <= br.width()) { // text fits in br; use hscroll for alignment - switch (d->hAlign & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) { + switch (hAlign & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) { case Qt::AlignRight: - d->hscroll = widthUsed - br.width() + 1; + hscroll = widthUsed - br.width() + 1; break; case Qt::AlignHCenter: - d->hscroll = (widthUsed - br.width()) / 2; + hscroll = (widthUsed - br.width()) / 2; break; default: // Left - d->hscroll = 0; + hscroll = 0; break; } - d->hscroll -= minLB; - } else if (cix - d->hscroll >= br.width()) { + hscroll -= minLB; + } else if (cix - hscroll >= br.width()) { // text doesn't fit, cursor is to the right of br (scroll right) - d->hscroll = cix - br.width() + 1; - } else if (cix - d->hscroll < 0 && d->hscroll < widthUsed) { + hscroll = cix - br.width() + 1; + } else if (cix - hscroll < 0 && hscroll < widthUsed) { // text doesn't fit, cursor is to the left of br (scroll left) - d->hscroll = cix; - } else if (widthUsed - d->hscroll < br.width()) { + hscroll = cix; + } else if (widthUsed - hscroll < br.width()) { // text doesn't fit, text document is to the left of br; align // right - d->hscroll = widthUsed - br.width() + 1; + hscroll = widthUsed - br.width() + 1; + } + } else { + if(hAlign == QDeclarativeTextInput::AlignRight){ + hscroll = q->width() - widthUsed; + }else if(hAlign == QDeclarativeTextInput::AlignHCenter){ + hscroll = (q->width() - widthUsed) / 2; + } else { + hscroll = 0; } + hscroll -= minLB; + } +} + +void QDeclarativeTextInput::drawContents(QPainter *p, const QRect &r) +{ + Q_D(QDeclarativeTextInput); + p->setRenderHint(QPainter::TextAntialiasing, true); + p->save(); + p->setPen(QPen(d->color)); + int flags = QLineControl::DrawText; + if(!isReadOnly() && d->cursorVisible && !d->cursorItem) + flags |= QLineControl::DrawCursor; + if (d->control->hasSelectedText()) + flags |= QLineControl::DrawSelections; + QPoint offset = QPoint(0,0); + QFontMetrics fm = QFontMetrics(d->font); + QRect br(boundingRect().toRect()); + if (d->autoScroll) { // the y offset is there to keep the baseline constant in case we have script changes in the text. offset = br.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent()); } else { - if(d->hAlign == AlignRight){ - d->hscroll = width() - widthUsed; - }else if(d->hAlign == AlignHCenter){ - d->hscroll = (width() - widthUsed) / 2; - } - d->hscroll -= minLB; offset = QPoint(d->hscroll, 0); } d->control->draw(p, offset, r, flags); @@ -1230,6 +1246,7 @@ void QDeclarativeTextInput::moveCursorSelection(int position) { Q_D(QDeclarativeTextInput); d->control->moveCursor(position, true); + d->updateHorizontalScroll(); } /*! @@ -1420,6 +1437,7 @@ void QDeclarativeTextInput::selectionChanged() void QDeclarativeTextInput::q_textChanged() { Q_D(QDeclarativeTextInput); + d->updateHorizontalScroll(); updateSize(); emit textChanged(); if(hasAcceptableInput() != d->oldValidity){ diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h index 6865147..8b74bcc 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h @@ -99,6 +99,7 @@ public: void init(); void startCreatingCursor(); void focusChanged(bool hasFocus); + void updateHorizontalScroll(); QLineControl* control; diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 3143580..a55b42e 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -396,7 +396,6 @@ void tst_qdeclarativetextinput::positionAt() #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); -- cgit v0.12 From 50f4129a2664ed72de899f4477b47f91488c04d9 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 16 Jun 2010 12:20:41 +0200 Subject: Minor demo fixes Found some minor demo issues while testing a TextInput change. --- demos/declarative/samegame/samegame.qml | 2 ++ .../declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml index 9a721da..9c4bfa8 100644 --- a/demos/declarative/samegame/samegame.qml +++ b/demos/declarative/samegame/samegame.qml @@ -115,6 +115,8 @@ Rectangle { id: nameInputText anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } focus: false + autoScroll: false + maximumLength: 24 onTextChanged: { var newWidth = nameInputText.width + dialogText.width + 40; if ( (newWidth > nameInputDialog.width && newWidth < screen.width) diff --git a/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml b/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml index 69f57c6..e863262 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativetextinput/LineEdit.qml @@ -30,13 +30,14 @@ Item { y: 5 //Below function implements all scrolling logic onCursorPositionChanged: { - if(cursorRect.x < leftMargin - textInp.x){//Cursor went off the front - textInp.x = leftMargin - Math.max(0, cursorRect.x); - }else if(cursorRect.x > parent.width - leftMargin - rightMargin - textInp.x){//Cusor went off the end - textInp.x = leftMargin - Math.max(0, cursorRect.x - (parent.width - leftMargin - rightMargin)); + if(cursorRectangle.x < leftMargin - textInp.x){//Cursor went off the front + textInp.x = leftMargin - Math.max(0, cursorRectangle.x); + }else if(cursorRectangle.x > parent.width - leftMargin - rightMargin - textInp.x){//Cusor went off the end + textInp.x = leftMargin - Math.max(0, cursorRectangle.x - (parent.width - leftMargin - rightMargin)); } } + autoScroll: false //It is preferable to implement your own scrolling text:"" horizontalAlignment: TextInput.AlignLeft font.pixelSize:15 -- cgit v0.12 From 28e23016eca537beae2da833603f3063b3bc5bcd Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Wed, 16 Jun 2010 11:59:34 +0200 Subject: Removed unnecessary lines of code. Reviewed-by: Gunnar --- src/gui/painting/qpaintengineex.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index ff82d59..e0746fb 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -494,11 +494,9 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) } else { d->activeStroker->moveTo(points[0], points[1]); points += 2; - ++types; while (points < lastPoint) { d->activeStroker->lineTo(points[0], points[1]); points += 2; - ++types; } if (path.hasImplicitClose()) d->activeStroker->lineTo(path.points()[0], path.points()[1]); @@ -561,12 +559,10 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) QPointF p = ((QPointF *)points)[0] * state()->matrix; d->activeStroker->moveTo(p.x(), p.y()); points += 2; - ++types; while (points < lastPoint) { QPointF p = ((QPointF *)points)[0] * state()->matrix; d->activeStroker->lineTo(p.x(), p.y()); points += 2; - ++types; } if (path.hasImplicitClose()) d->activeStroker->lineTo(p.x(), p.y()); -- cgit v0.12 From 64e60dab167afc68cfb94a8eb0b7469eea9a4291 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Wed, 16 Jun 2010 12:03:02 +0200 Subject: Fixed full-rule on clipped painter paths. The fill-rule of the original path was not copied into the clipped path. Reviewed-by: Gunnar --- src/gui/painting/qoutlinemapper.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp index 1b01960..962f34c 100644 --- a/src/gui/painting/qoutlinemapper.cpp +++ b/src/gui/painting/qoutlinemapper.cpp @@ -354,6 +354,10 @@ void QOutlineMapper::clipElements(const QPointF *elements, // this part of code hardly every used, it shouldn't matter. QPainterPath path; + + if (!(m_outline.flags & QT_FT_OUTLINE_EVEN_ODD_FILL)) + path.setFillRule(Qt::WindingFill); + if (types) { for (int i=0; i Date: Wed, 16 Jun 2010 12:10:03 +0200 Subject: Fixed infinite recursion when drawing very large painter paths. Task-number: QTBUG-11291 Reviewed-by: Gunnar --- src/gui/painting/qoutlinemapper.cpp | 8 ++++++-- src/gui/painting/qoutlinemapper_p.h | 4 +++- src/gui/painting/qpaintengine_raster.cpp | 11 +++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp index 962f34c..bf03545 100644 --- a/src/gui/painting/qoutlinemapper.cpp +++ b/src/gui/painting/qoutlinemapper.cpp @@ -234,12 +234,12 @@ void QOutlineMapper::endOutline() // Check for out of dev bounds... - const bool do_clip = (controlPointRect.left() < -QT_RASTER_COORD_LIMIT + const bool do_clip = !m_in_clip_elements && ((controlPointRect.left() < -QT_RASTER_COORD_LIMIT || controlPointRect.right() > QT_RASTER_COORD_LIMIT || controlPointRect.top() < -QT_RASTER_COORD_LIMIT || controlPointRect.bottom() > QT_RASTER_COORD_LIMIT || controlPointRect.width() > QT_RASTER_COORD_LIMIT - || controlPointRect.height() > QT_RASTER_COORD_LIMIT); + || controlPointRect.height() > QT_RASTER_COORD_LIMIT)); if (do_clip) { clipElements(elements, elementTypes(), element_count); @@ -353,6 +353,8 @@ void QOutlineMapper::clipElements(const QPointF *elements, // instead of going through convenience functionallity, but since // this part of code hardly every used, it shouldn't matter. + m_in_clip_elements = true; + QPainterPath path; if (!(m_outline.flags & QT_FT_OUTLINE_EVEN_ODD_FILL)) @@ -393,6 +395,8 @@ void QOutlineMapper::clipElements(const QPointF *elements, else convertPath(clippedPath); m_txop = old_txop; + + m_in_clip_elements = false; } QT_END_NAMESPACE diff --git a/src/gui/painting/qoutlinemapper_p.h b/src/gui/painting/qoutlinemapper_p.h index 39b7593..f64d03b 100644 --- a/src/gui/painting/qoutlinemapper_p.h +++ b/src/gui/painting/qoutlinemapper_p.h @@ -95,7 +95,8 @@ public: m_tags(0), m_contours(0), m_polygon_dev(0), - m_round_coords(false) + m_round_coords(false), + m_in_clip_elements(false) { } @@ -235,6 +236,7 @@ public: qreal m_dy; bool m_valid; + bool m_in_clip_elements; private: bool m_round_coords; diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index f10f12f..a212718 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -459,13 +459,12 @@ bool QRasterPaintEngine::begin(QPaintDevice *device) QRasterPaintEngineState *s = state(); ensureOutlineMapper(); - d->outlineMapper->m_clip_rect = d->deviceRect.adjusted(-10, -10, 10, 10); - - // This is the upp - QRect bounds(-QT_RASTER_COORD_LIMIT, -QT_RASTER_COORD_LIMIT, - QT_RASTER_COORD_LIMIT*2 - 1, QT_RASTER_COORD_LIMIT * 2 - 1); - d->outlineMapper->m_clip_rect = bounds.intersected(d->outlineMapper->m_clip_rect); + d->outlineMapper->m_clip_rect = d->deviceRect; + if (d->outlineMapper->m_clip_rect.width() > QT_RASTER_COORD_LIMIT) + d->outlineMapper->m_clip_rect.setWidth(QT_RASTER_COORD_LIMIT); + if (d->outlineMapper->m_clip_rect.height() > QT_RASTER_COORD_LIMIT) + d->outlineMapper->m_clip_rect.setHeight(QT_RASTER_COORD_LIMIT); d->rasterizer->setClipRect(d->deviceRect); -- cgit v0.12 From 59ec66675b725f56111e4b133e79828bc6d5d95a Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 16 Jun 2010 12:27:53 +0200 Subject: Write TextInput.positionToRectangle docs. Also renamed the argument to be more accurate. Task-number: QTBUG-11168 --- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 12 +++++++++--- src/declarative/graphicsitems/qdeclarativetextinput_p.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 033e12c..9e5dfb5 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -845,12 +845,18 @@ void QDeclarativeTextInput::moveCursor() } /*! - \qmlmethod rect TextInput::positionToRectangle(int x) + \qmlmethod rect TextInput::positionToRectangle(int pos) + + This function takes a character position and returns the rectangle that the + cursor would occupy, if it was placed at that character position. + + This is similar to setting the cursorPosition, and then querying the cursor + rectangle, but the cursorPosition is not changed. */ -QRectF QDeclarativeTextInput::positionToRectangle(int x) const +QRectF QDeclarativeTextInput::positionToRectangle(int pos) const { Q_D(const QDeclarativeTextInput); - return QRectF(d->control->cursorToX(x)-d->hscroll, + return QRectF(d->control->cursorToX(pos)-d->hscroll, 0.0, d->control->cursorWidth(), cursorRectangle().height()); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h index c539bd3..03f55ae 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h @@ -112,7 +112,7 @@ public: //Auxilliary functions needed to control the TextInput from QML Q_INVOKABLE int positionAt(int x) const; - Q_INVOKABLE QRectF positionToRectangle(int x) const; + Q_INVOKABLE QRectF positionToRectangle(int pos) const; Q_INVOKABLE void moveCursorSelection(int pos); Q_INVOKABLE void openSoftwareInputPanel(); -- cgit v0.12 From 0842309e6e04d34c027374d0793dc60d3ec6e28b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 16 Jun 2010 13:41:46 +0200 Subject: Fix crash on Mac OS X when drawing text with Qt::TextBypassShaping set On Mac we end up in a code path where logClusters is 0, and the fallback path for when CoreText fails to shape text didn't take this into account. Reviewed-by: Simon Hausmann --- src/gui/text/qfontengine_mac.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index 3be6d28..7ceed61 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -237,7 +237,8 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay *nglyphs = len; for (int i = 0; i < len; ++i) { outGlyphs[i] = 0; - logClusters[i] = i; + if (logClusters) + logClusters[i] = i; outAdvances_x[i] = QFixed(); outAdvances_y[i] = QFixed(); outAttributes[i].clusterStart = true; -- cgit v0.12 From 6d4e14ef0437ce8f73bddbcb267cf5ef708fbdec Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Wed, 16 Jun 2010 15:16:16 +0200 Subject: Micro cleanup Use Qt::WA_DeleteOnClose to clean up the top-level window Reviewed-by: Alan Alpert --- tools/qml/main.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 0cce1cc..a75023b 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -347,8 +347,9 @@ int main(int argc, char ** argv) wflags |= Qt::WindowStaysOnTopHint; QDeclarativeViewer *viewer = new QDeclarativeViewer(0, wflags); + viewer->setAttribute(Qt::WA_DeleteOnClose, true); if (!scriptopts.isEmpty()) { - QStringList options = + QStringList options = scriptopts.split(QLatin1Char(','), QString::SkipEmptyParts); QDeclarativeViewer::ScriptOptions scriptOptions = 0; @@ -451,7 +452,5 @@ int main(int argc, char ** argv) viewer->setUseGL(useGL); viewer->raise(); - int rv = app.exec(); - delete viewer; - exit(rv); + return app.exec(); } -- cgit v0.12 From 6d178306f71564471cc08eb7dc98743c3752cac4 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Wed, 16 Jun 2010 15:17:33 +0200 Subject: Fix the N900 device orientation backend Use D-Bus calls instead of polling Reviewed-by: Alan Alpert --- tools/qml/deviceorientation_maemo.cpp | 123 +++++++++++++++------------------- tools/qml/qml.pri | 1 + 2 files changed, 56 insertions(+), 68 deletions(-) diff --git a/tools/qml/deviceorientation_maemo.cpp b/tools/qml/deviceorientation_maemo.cpp index 7948e2a..443edc8 100644 --- a/tools/qml/deviceorientation_maemo.cpp +++ b/tools/qml/deviceorientation_maemo.cpp @@ -40,100 +40,87 @@ ****************************************************************************/ #include "deviceorientation.h" -#include -#include +#include + +#include +#include class MaemoOrientation : public DeviceOrientation { Q_OBJECT public: MaemoOrientation() - : DeviceOrientation(),m_current(Portrait), m_lastSeen(Portrait), m_lastSeenCount(0) + : o(UnknownOrientation) { - m_current = get(); - if (m_current == UnknownOrientation) - m_current = Portrait; + // enable the orientation sensor + QDBusConnection::systemBus().call( + QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, + MCE_REQUEST_IF, MCE_ACCELEROMETER_ENABLE_REQ)); + + // query the initial orientation + QDBusMessage reply = QDBusConnection::systemBus().call( + QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, + MCE_REQUEST_IF, MCE_DEVICE_ORIENTATION_GET)); + if (reply.type() == QDBusMessage::ErrorMessage) { + qWarning("Unable to retrieve device orientation: %s", qPrintable(reply.errorMessage())); + } else { + o = toOrientation(reply.arguments().value(0).toString()); + } - startTimer(100); + // connect to the orientation change signal + QDBusConnection::systemBus().connect(QString(), MCE_SIGNAL_PATH, MCE_SIGNAL_IF, + MCE_DEVICE_ORIENTATION_SIG, + this, + SLOT(deviceOrientationChanged(QString))); } - Orientation orientation() const { - return m_current; + ~MaemoOrientation() + { + // disable the orientation sensor + QDBusConnection::systemBus().call( + QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, + MCE_REQUEST_IF, MCE_ACCELEROMETER_DISABLE_REQ)); } - void setOrientation(Orientation) { } - -protected: - virtual void timerEvent(QTimerEvent *) + inline Orientation orientation() const { - Orientation c = get(); - - if (c == m_lastSeen) { - m_lastSeenCount++; - } else { - m_lastSeenCount = 0; - m_lastSeen = c; - } - - if (m_lastSeen != UnknownOrientation && m_lastSeen != m_current && m_lastSeenCount > 4) { - m_current = m_lastSeen; - emit orientationChanged(); - printf("%d\n", m_current); - } + return o; } -signals: - void changed(); - -private: - Orientation m_current; - Orientation m_lastSeen; - int m_lastSeenCount; - - Orientation get() + void setOrientation(Orientation o) { - Orientation o = UnknownOrientation; - - int ax, ay, az; - - read(&ax, &ay, &az); + } - if (abs(az) > 850) { - o = UnknownOrientation; - } else if (ax < -750) { - o = Portrait; - } else if (ax > 750) { - o = PortraitInverted; - } else if (ay < -750) { - o = Landscape; - } else if (ay > 750) { - o = LandscapeInverted; - } +private Q_SLOTS: + void deviceOrientationChanged(const QString &newOrientation) + { + o = toOrientation(newOrientation); - return o; + emit orientationChanged(); +// printf("%d\n", o); } - int read(int *ax,int *ay,int *az) +private: + static Orientation toOrientation(const QString &nativeOrientation) { - static const char *accel_filename = "/sys/class/i2c-adapter/i2c-3/3-001d/coord"; - - FILE *fd; - int rs; - fd = fopen(accel_filename, "r"); - if(fd==NULL){ printf("liqaccel, cannot open for reading\n"); return -1;} - rs=fscanf((FILE*) fd,"%i %i %i",ax,ay,az); - fclose(fd); - if(rs != 3){ printf("liqaccel, cannot read information\n"); return -2;} - return 0; + if (nativeOrientation == MCE_ORIENTATION_LANDSCAPE) + return Landscape; + else if (nativeOrientation == MCE_ORIENTATION_LANDSCAPE_INVERTED) + return LandscapeInverted; + else if (nativeOrientation == MCE_ORIENTATION_PORTRAIT) + return Portrait; + else if (nativeOrientation == MCE_ORIENTATION_PORTRAIT_INVERTED) + return PortraitInverted; + return UnknownOrientation; } -}; +private: + Orientation o; +}; DeviceOrientation* DeviceOrientation::instance() { - static MaemoOrientation *o = 0; - if (!o) - o = new MaemoOrientation; + static MaemoOrientation *o = new MaemoOrientation; return o; } diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri index cff65be..58d8cc1 100644 --- a/tools/qml/qml.pri +++ b/tools/qml/qml.pri @@ -18,6 +18,7 @@ SOURCES += $$PWD/qmlruntime.cpp \ RESOURCES = $$PWD/qmlruntime.qrc maemo5 { + QT += dbus SOURCES += $$PWD/deviceorientation_maemo.cpp } else { SOURCES += $$PWD/deviceorientation.cpp -- cgit v0.12 From 3addea6e74a1f02b6e0a416bdb98b06c00e98e62 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 16 Jun 2010 15:54:18 +0300 Subject: Provide 'make unsigned_sis' target for Symbian mkspecs Rationale for this is that currently there is no simple way to create a sis package that can be properly signed via Symbian open signed mechanism, as 'make sis' will by default use self-signed certificates and automatically patch capabilities of binaries to remove non-self-signable ones. Task-number: QTBUG-11455 Reviewed-by: Janne Koskinen --- bin/createpackage.pl | 33 +++++++++++++++++++++++------ bin/patch_capabilities.pl | 3 ++- doc/src/platforms/symbian-introduction.qdoc | 2 ++ mkspecs/features/sis_targets.prf | 25 ++++++++++++++++++++++ 4 files changed, 56 insertions(+), 7 deletions(-) diff --git a/bin/createpackage.pl b/bin/createpackage.pl index 939c38e..8b787cb 100755 --- a/bin/createpackage.pl +++ b/bin/createpackage.pl @@ -78,6 +78,7 @@ Where supported options are as follows: as a comments. Also empty lines are ignored. The paths in can be absolute or relative to . [-u|unsigned] = Preserves the unsigned package. + [-o|only-unsigned] = Creates only unsigned package. [-s|stub] = Generates stub sis for ROM. [-n|sisname ] = Specifies the final sis name. Where parameters are as follows: @@ -121,11 +122,13 @@ my $certfile = ""; my $preserveUnsigned = ""; my $stub = ""; my $signed_sis_name = ""; +my $onlyUnsigned = ""; unless (GetOptions('i|install' => \$install, 'p|preprocess' => \$preprocessonly, 'c|certfile=s' => \$certfile, 'u|unsigned' => \$preserveUnsigned, + 'o|only-unsigned' => \$onlyUnsigned, 's|stub' => \$stub, 'n|sisname=s' => \$signed_sis_name,)) { Usage(); @@ -292,7 +295,10 @@ if($stub) { # Create stub SIS. system ("makesis -s $pkgoutput $stub_sis_name"); } else { - if ($certtext eq "Self Signed" && !@certificates && $templatepkg !~ m/_installer\.pkg$/i) { + if ($certtext eq "Self Signed" + && !@certificates + && $templatepkg !~ m/_installer\.pkg$/i + && !$onlyUnsigned) { print("Auto-patching capabilities for self signed package.\n"); system ("patch_capabilities $pkgoutput"); } @@ -302,6 +308,25 @@ if($stub) { system ("makesis $pkgoutput $unsigned_sis_name") and die ("makesis failed"); print("\n"); + my $targetInsert = ""; + if ($targetplatform ne "-") { + $targetInsert = " for $targetplatform"; + } + + if ($onlyUnsigned) { + stat($unsigned_sis_name); + if( -e _ ) { + print ("Successfully created unsigned package ${unsigned_sis_name}${targetInsert}!\n"); + } else { + print ("\nUnsigned package creation failed!\n"); + } + + if (!$preservePkgOutput) { + unlink $pkgoutput; + } + exit; + } + # Sign SIS with certificate info given as an argument. my $relcert = File::Spec->abs2rel($certificate); my $relkey = File::Spec->abs2rel($key); @@ -311,11 +336,7 @@ if($stub) { # Check if creating signed SIS Succeeded stat($signed_sis_name); if( -e _ ) { - my $targetInsert = ""; - if ($targetplatform ne "-") { - $targetInsert = "for $targetplatform "; - } - print ("Successfully created $signed_sis_name ${targetInsert}using certificate: $certtext!\n"); + print ("Successfully created signed package ${signed_sis_name}${targetInsert} using certificate: $certtext!\n"); # Sign with additional certificates & keys for my $row ( @certificates ) { diff --git a/bin/patch_capabilities.pl b/bin/patch_capabilities.pl index 9741bc3..501939a 100755 --- a/bin/patch_capabilities.pl +++ b/bin/patch_capabilities.pl @@ -269,7 +269,8 @@ if (@ARGV) } print ("\n"); - print ("NOTE: A patched package should not be used for distribution!\n"); + print ("NOTE: A patched package may not work as expected due to reduced capabilities.\n"); + print (" Therefore it should not be used for any kind of Symbian signing or distribution!\n"); print ("\n"); } } diff --git a/doc/src/platforms/symbian-introduction.qdoc b/doc/src/platforms/symbian-introduction.qdoc index 6ffc568..316764b 100644 --- a/doc/src/platforms/symbian-introduction.qdoc +++ b/doc/src/platforms/symbian-introduction.qdoc @@ -127,6 +127,7 @@ \row \o \c run \o Run the application on the emulator. \row \o \c runonphone \o Run the application on a device. \row \o \c sis \o Create signed \c .sis file for project. + \row \o \c unsigned_sis \o Create unsigned \c .sis file for project. \row \o \c installer_sis \o Create signed \l{Smart Installer}{smart installer} \c .sis file for project. Smart installer will attempt to download @@ -193,6 +194,7 @@ \row \o -p \o Only preprocess the template \c .pkg file. \row \o -c \o Read certificate information from a file. \row \o -u \o Preserves unsigned package. + \row \o -o \o Creates only unsigned package. \row \o -s \o Generates stub sis for ROM. \row \o -n \o Specifies the final sis name. \endtable diff --git a/mkspecs/features/sis_targets.prf b/mkspecs/features/sis_targets.prf index b149a22..37b758b 100644 --- a/mkspecs/features/sis_targets.prf +++ b/mkspecs/features/sis_targets.prf @@ -32,6 +32,24 @@ equals(GENERATE_SIS_TARGETS, true) { ok_sis_target.commands = createpackage.bat $(QT_SIS_OPTIONS) $$basename(TARGET)_template.pkg \ $(QT_SIS_TARGET) $(QT_SIS_CERTIFICATE) $(QT_SIS_KEY) $(QT_SIS_PASSPHRASE) + unsigned_sis_target.target = unsigned_sis + unsigned_sis_target.commands = $(if $(wildcard $$basename(TARGET)_template.pkg), \ + $(if $(wildcard $$make_cache_name), \ + $(MAKE) -f $(MAKEFILE) ok_unsigned_sis MAKEFILES=$$make_cache_name \ + , \ + $(if $(QT_SIS_TARGET), \ + $(MAKE) -f $(MAKEFILE) ok_unsigned_sis \ + , \ + $(MAKE) -f $(MAKEFILE) fail_sis_nocache \ + ) \ + ) \ + , \ + $(MAKE) -f $(MAKEFILE) fail_sis_nopkg \ + ) + + ok_unsigned_sis_target.target = ok_unsigned_sis + ok_unsigned_sis_target.commands = createpackage.bat $(QT_SIS_OPTIONS) -o $$basename(TARGET)_template.pkg $(QT_SIS_TARGET) + target_sis_target.target = $${sis_destdir}$${TARGET}.sis target_sis_target.commands = $(MAKE) -f $(MAKEFILE) sis @@ -74,6 +92,8 @@ equals(GENERATE_SIS_TARGETS, true) { QMAKE_EXTRA_TARGETS += sis_target \ ok_sis_target \ + unsigned_sis_target \ + ok_unsigned_sis_target \ target_sis_target \ installer_sis_target \ ok_installer_sis_target \ @@ -114,6 +134,10 @@ equals(GENERATE_SIS_TARGETS, true) { - $(QT_SIS_CERTIFICATE) $(QT_SIS_KEY) $(QT_SIS_PASSPHRASE) sis_target.depends = first + unsigned_sis_target.target = unsigned_sis + unsigned_sis_target.commands = createpackage $(QT_SIS_OPTIONS) -o $$basename(TARGET)_template.pkg + unsigned_sis_target.depends = first + target_sis_target.target = $${sis_destdir}$${TARGET}.sis target_sis_target.commands = $(MAKE) -f $(MAKEFILE) sis @@ -128,6 +152,7 @@ equals(GENERATE_SIS_TARGETS, true) { } QMAKE_EXTRA_TARGETS += sis_target \ + unsigned_sis_target \ target_sis_target \ installer_sis_target } -- cgit v0.12 From 7a577ff67388413a882435c5cbd1ad6d1fa8393d Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 17 Jun 2010 10:26:13 +1000 Subject: clearFocus() shouldn't mess with focus if it doesn't have focus removing an item from the view caused the focus to change even if the removed item didn't have focus. Task-number: QTBUG-11341 Reviewed-by: Yoann Lopes --- src/gui/graphicsview/qgraphicsitem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 8042c46..c9176d1 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3277,7 +3277,8 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim */ void QGraphicsItem::clearFocus() { - d_ptr->clearFocusHelper(/* giveFocusToParent = */ true); + if (hasFocus()) + d_ptr->clearFocusHelper(/* giveFocusToParent = */ true); } /*! -- cgit v0.12 From b294bedf9d6fdabca9fd384f1b2d910c02ec1c50 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 17 Jun 2010 13:51:26 +1000 Subject: Add test for model data changes. --- .../qdeclarativerepeater/data/repeater2.qml | 5 ++- .../tst_qdeclarativerepeater.cpp | 44 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml b/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml index c8b863c..7f2f85a 100644 --- a/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml +++ b/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml @@ -9,12 +9,13 @@ Rectangle { Item { objectName: "myDelegate" height: 20 + width: 240 Text { - y: index*20 + objectName: "myName" text: name } Text { - y: index*20 + objectName: "myNumber" x: 100 text: number } diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp index 3cc68f4..7299a43 100644 --- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp +++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -75,6 +76,8 @@ private slots: private: QDeclarativeView *createView(); template + T *findItem(QGraphicsObject *parent, const QString &objectName, int index); + template T *findItem(QGraphicsObject *parent, const QString &id); }; @@ -312,6 +315,20 @@ void tst_QDeclarativeRepeater::dataModel() testModel.removeItem(2); QCOMPARE(container->childItems().count(), 4); + // Check that model changes are propagated + QDeclarativeText *text = findItem(canvas->rootObject(), "myName", 1); + QVERIFY(text); + QCOMPARE(text->text(), QString("two")); + + testModel.modifyItem(1, "Item two", "_2"); + text = findItem(canvas->rootObject(), "myName", 1); + QVERIFY(text); + QCOMPARE(text->text(), QString("Item two")); + + text = findItem(canvas->rootObject(), "myNumber", 1); + QVERIFY(text); + QCOMPARE(text->text(), QString("_2")); + delete testObject; delete canvas; } @@ -387,6 +404,33 @@ QDeclarativeView *tst_QDeclarativeRepeater::createView() } template +T *tst_QDeclarativeRepeater::findItem(QGraphicsObject *parent, const QString &objectName, int index) +{ + const QMetaObject &mo = T::staticMetaObject; + //qDebug() << parent->childItems().count() << "children"; + for (int i = 0; i < parent->childItems().count(); ++i) { + QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); + if(!item) + continue; + //qDebug() << "try" << item; + if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { + if (index != -1) { + QDeclarativeExpression e(qmlContext(item), item, "index"); + if (e.evaluate().toInt() == index) + return static_cast(item); + } else { + return static_cast(item); + } + } + item = findItem(item, objectName, index); + if (item) + return static_cast(item); + } + + return 0; +} + +template T *tst_QDeclarativeRepeater::findItem(QGraphicsObject *parent, const QString &objectName) { const QMetaObject &mo = T::staticMetaObject; -- cgit v0.12 From a6b0458c5ab5bc8ad6c868425820e0bf0e932336 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 17 Jun 2010 13:57:15 +1000 Subject: doc: add note that items with width or height of 0 are not positioned. --- src/declarative/graphicsitems/qdeclarativepositioners.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index ad61bab..b9231a1 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -358,6 +358,8 @@ Column { positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Column. + Items with a width or height of 0 will not be positioned. + \sa Row, {declarative/positioners}{Positioners example} */ /*! @@ -502,6 +504,8 @@ Row { positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Row. + Items with a width or height of 0 will not be positioned. + \sa Column, {declarative/positioners}{Positioners example} */ /*! @@ -657,6 +661,8 @@ Grid { positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Grid. + Items with a width or height of 0 will not be positioned. + \sa Flow, {declarative/positioners}{Positioners example} */ /*! @@ -913,6 +919,8 @@ void QDeclarativeGrid::reportConflictingAnchors() positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Flow. + Items with a width or height of 0 will not be positioned. + \sa Grid, {declarative/positioners}{Positioners example} */ /*! -- cgit v0.12 From 21af6bbee63bdac4907013d0abb0908086d85217 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 17 Jun 2010 03:22:38 +0200 Subject: Specialize peek() for QBuffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids going through the generic implementation in QIODevice and avoids a 16kB buffer allocation from QIODevicePrivateLinearBuffer. Reviewed-by: João Abecasis --- src/corelib/io/qbuffer.cpp | 18 ++++++++++++++++ src/corelib/io/qiodevice.cpp | 49 ++++++++++++++++++++++++++++---------------- src/corelib/io/qiodevice_p.h | 4 +++- 3 files changed, 52 insertions(+), 19 deletions(-) diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp index c1ff353..73c71ea 100644 --- a/src/corelib/io/qbuffer.cpp +++ b/src/corelib/io/qbuffer.cpp @@ -62,6 +62,9 @@ public: QByteArray defaultBuf; int ioIndex; + virtual qint64 peek(char *data, qint64 maxSize); + virtual QByteArray peek(qint64 maxSize); + #ifndef QT_NO_QOBJECT // private slots void _q_emitSignals(); @@ -83,6 +86,21 @@ void QBufferPrivate::_q_emitSignals() } #endif +qint64 QBufferPrivate::peek(char *data, qint64 maxSize) +{ + qint64 readBytes = qMin(maxSize, static_cast(buf->size()) - pos); + memcpy(data, buf->constData() + pos, readBytes); + return readBytes; +} + +QByteArray QBufferPrivate::peek(qint64 maxSize) +{ + qint64 readBytes = qMin(maxSize, static_cast(buf->size()) - pos); + if (pos == 0 && maxSize >= buf->size()) + return *buf; + return QByteArray(buf->constData() + pos, readBytes); +} + /*! \class QBuffer \reentrant diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index d2e4f75..ea60792 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1442,6 +1442,35 @@ bool QIODevicePrivate::putCharHelper(char c) return q_func()->write(&c, 1) == 1; } +/*! + \internal +*/ +qint64 QIODevicePrivate::peek(char *data, qint64 maxSize) +{ + qint64 readBytes = q_func()->read(data, maxSize); + if (readBytes <= 0) + return readBytes; + + buffer.ungetBlock(data, readBytes); + pos -= readBytes; + return readBytes; +} + +/*! + \internal +*/ +QByteArray QIODevicePrivate::peek(qint64 maxSize) +{ + QByteArray result = q_func()->read(maxSize); + + if (result.isEmpty()) + return result; + + buffer.ungetBlock(result.constData(), result.size()); + pos -= result.size(); + return result; +} + /*! \fn bool QIODevice::getChar(char *c) Reads one character from the device and stores it in \a c. If \a c @@ -1476,14 +1505,7 @@ bool QIODevice::getChar(char *c) */ qint64 QIODevice::peek(char *data, qint64 maxSize) { - Q_D(QIODevice); - qint64 readBytes = read(data, maxSize); - if (readBytes <= 0) - return readBytes; - - d->buffer.ungetBlock(data, readBytes); - d->pos -= readBytes; - return readBytes; + return d_func()->peek(data, maxSize); } /*! @@ -1505,16 +1527,7 @@ qint64 QIODevice::peek(char *data, qint64 maxSize) */ QByteArray QIODevice::peek(qint64 maxSize) { - Q_D(QIODevice); - QByteArray result = read(maxSize); - - if (result.isEmpty()) - return result; - - d->buffer.ungetBlock(result.constData(), result.size()); - d->pos -= result.size(); - - return result; + return d_func()->peek(maxSize); } /*! diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h index 225a0b9..4a25562 100644 --- a/src/corelib/io/qiodevice_p.h +++ b/src/corelib/io/qiodevice_p.h @@ -231,7 +231,9 @@ public: accessMode = q_func()->isSequential() ? Sequential : RandomAccess; return accessMode == Sequential; } - + + virtual qint64 peek(char *data, qint64 maxSize); + virtual QByteArray peek(qint64 maxSize); #ifdef QT_NO_QOBJECT QIODevice *q_ptr; -- cgit v0.12 From b7468f5df0d3f98d56282283127c4b1a28749f7b Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 18 Jun 2010 09:19:04 +1000 Subject: Fixed tst_QNetworkDiskCache creating badly named directories. This code was intending to create a uniquely named directory containing the PID of the test, but it was accidentally creating a directory with a name possibly containing unprintable characters. --- tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp index 5bbe8f6..245a5c6 100644 --- a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp +++ b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp @@ -642,7 +642,7 @@ void tst_QNetworkDiskCache::crashWhenParentingCache() QNetworkAccessManager *manager = new QNetworkAccessManager(); QNetworkDiskCache *diskCache = new QNetworkDiskCache(manager); // parent to qnam! // we expect the temp dir to be cleaned at some point anyway - diskCache->setCacheDirectory(QDir::tempPath() + "/cacheDir_" + QCoreApplication::applicationPid()); + diskCache->setCacheDirectory(QString("%1/cacheDir_%2").arg(QDir::tempPath()).arg(QCoreApplication::applicationPid())); manager->setCache(diskCache); QUrl url("http://127.0.0.1:" + QString::number(server.serverPort())); -- cgit v0.12 From 1448e36be786648a7764255c24edddc636315427 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 17 Jun 2010 18:09:51 +0200 Subject: Fix for emitting changed signal in QClipboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the app that owns the selection quits and there is no clipboard manager running we emit the changed signal whenever the timestamp of the event we got is greater than our timestamp. Task-number: QTBUG-8157 Reviewed-by: Thiago Macieira Author: Luboš Luňák --- src/gui/kernel/qclipboard_x11.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qclipboard_x11.cpp b/src/gui/kernel/qclipboard_x11.cpp index 3bdc971..9fcc718 100644 --- a/src/gui/kernel/qclipboard_x11.cpp +++ b/src/gui/kernel/qclipboard_x11.cpp @@ -1518,7 +1518,7 @@ bool qt_xfixes_selection_changed(Window selectionOwner, Time timestamp) (unsigned int)(d ? d->timestamp : 0), (unsigned int)timestamp); #endif if (!owner || (selectionOwner && selectionOwner != owner->internalWinId()) || - (!selectionOwner && d->timestamp != CurrentTime && d->timestamp < timestamp)) + (!selectionOwner && (d->timestamp == CurrentTime || d->timestamp < timestamp))) return qt_check_selection_sentinel(); return false; } @@ -1532,7 +1532,7 @@ bool qt_xfixes_clipboard_changed(Window clipboardOwner, Time timestamp) (unsigned int)(d ? d->timestamp : 0), (unsigned int)timestamp); #endif if (!owner || (clipboardOwner && clipboardOwner != owner->internalWinId()) || - (!clipboardOwner && d->timestamp != CurrentTime && d->timestamp < timestamp)) + (!clipboardOwner && (d->timestamp == CurrentTime || d->timestamp < timestamp))) return qt_check_clipboard_sentinel(); return false; } -- cgit v0.12 From 81b03ee252a22c9b053c376302428e5430523900 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 18 Jun 2010 13:03:14 +0200 Subject: Updated Harfbuzz from git+ssh://git.freedesktop.org/git/harfbuzz to 508b02a252b524d34f3ed970eef3bdb6350a2b77 * Andreas' compression for HB_ValueRecord * Re-enable packing for RVCT --- src/3rdparty/harfbuzz/src/harfbuzz-dump.c | 8 +-- src/3rdparty/harfbuzz/src/harfbuzz-global.h | 2 +- src/3rdparty/harfbuzz/src/harfbuzz-gpos-private.h | 39 ++++++----- src/3rdparty/harfbuzz/src/harfbuzz-gpos.c | 85 +++++++++++------------ src/3rdparty/harfbuzz/src/harfbuzz-shaper.h | 8 +-- 5 files changed, 72 insertions(+), 70 deletions(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-dump.c b/src/3rdparty/harfbuzz/src/harfbuzz-dump.c index a1ef6b6..54d42e9 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-dump.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-dump.c @@ -519,13 +519,13 @@ Dump_ValueRecord (HB_ValueRecord *ValueRecord, FILE *stream, int indent, HB_Type if (value_format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE) DUMP_FINT (ValueRecord, XAdvance); if (value_format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE) - RECURSE (Device, Device, &*ValueRecord->XPlacementDevice); + RECURSE (Device, Device, &*ValueRecord->DeviceTables[VR_X_PLACEMENT_DEVICE]); if (value_format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE) - RECURSE (Device, Device, &*ValueRecord->YPlacementDevice); + RECURSE (Device, Device, &*ValueRecord->DeviceTables[VR_Y_PLACEMENT_DEVICE]); if (value_format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE) - RECURSE (Device, Device, &*ValueRecord->XAdvanceDevice); + RECURSE (Device, Device, &*ValueRecord->DeviceTables[VR_X_ADVANCE_DEVICE]); if (value_format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE) - RECURSE (Device, Device, &*ValueRecord->YAdvanceDevice); + RECURSE (Device, Device, &*ValueRecord->DeviceTables[VR_Y_ADVANCE_DEVICE]); #ifdef HB_SUPPORT_MULTIPLE_MASTER if (value_format & HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT) DUMP_FUINT (ValueRecord, XIdPlacement); diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-global.h b/src/3rdparty/harfbuzz/src/harfbuzz-global.h index bccd6a2..5b2b679 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-global.h +++ b/src/3rdparty/harfbuzz/src/harfbuzz-global.h @@ -39,7 +39,7 @@ #define HB_END_HEADER /* nothing */ #endif -#if defined(__GNUC__) || defined(_MSC_VER) +#if defined(__GNUC__) || defined(__ARMCC__) || defined(__CC_ARM) || defined(_MSC_VER) #define HB_USE_PACKED_STRUCTS #endif diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-gpos-private.h b/src/3rdparty/harfbuzz/src/harfbuzz-gpos-private.h index d513c27..3a4952b 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-gpos-private.h +++ b/src/3rdparty/harfbuzz/src/harfbuzz-gpos-private.h @@ -38,6 +38,11 @@ HB_BEGIN_HEADER /* shared tables */ +#define VR_X_PLACEMENT_DEVICE 0 +#define VR_Y_PLACEMENT_DEVICE 1 +#define VR_X_ADVANCE_DEVICE 2 +#define VR_Y_ADVANCE_DEVICE 3 + struct HB_ValueRecord_ { HB_Short XPlacement; /* horizontal adjustment for @@ -48,14 +53,10 @@ struct HB_ValueRecord_ advance */ HB_Short YAdvance; /* vertical adjustment for advance */ - HB_Device* XPlacementDevice; /* device table for horizontal - placement */ - HB_Device* YPlacementDevice; /* device table for vertical - placement */ - HB_Device* XAdvanceDevice; /* device table for horizontal - advance */ - HB_Device* YAdvanceDevice; /* device table for vertical - advance */ + + HB_Device** DeviceTables; /* device tables for placement + and advance */ + #ifdef HB_SUPPORT_MULTIPLE_MASTER HB_UShort XIdPlacement; /* horizontal placement metric ID */ HB_UShort YIdPlacement; /* vertical placement metric ID */ @@ -70,6 +71,8 @@ typedef struct HB_ValueRecord_ HB_ValueRecord; /* Mask values to scan the value format of the ValueRecord structure. We always expand compressed ValueRecords of the font. */ +#define HB_GPOS_FORMAT_HAVE_DEVICE_TABLES 0x00F0 + #define HB_GPOS_FORMAT_HAVE_X_PLACEMENT 0x0001 #define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT 0x0002 #define HB_GPOS_FORMAT_HAVE_X_ADVANCE 0x0004 @@ -533,18 +536,18 @@ typedef struct HB_ContextPos_ HB_ContextPos; struct HB_ChainPosRule_ { + HB_UShort* Backtrack; /* array of backtrack glyph IDs */ + HB_UShort* Input; /* array of input glyph IDs */ + HB_UShort* Lookahead; /* array of lookahead glyph IDs */ + HB_PosLookupRecord* PosLookupRecord; + /* array of PosLookupRecords */ HB_UShort BacktrackGlyphCount; /* total number of backtrack glyphs */ - HB_UShort* Backtrack; /* array of backtrack glyph IDs */ HB_UShort InputGlyphCount; /* total number of input glyphs */ - HB_UShort* Input; /* array of input glyph IDs */ HB_UShort LookaheadGlyphCount; /* total number of lookahead glyphs */ - HB_UShort* Lookahead; /* array of lookahead glyph IDs */ HB_UShort PosCount; /* number of PosLookupRecords */ - HB_PosLookupRecord* PosLookupRecord; - /* array of PosLookupRecords */ }; typedef struct HB_ChainPosRule_ HB_ChainPosRule; @@ -574,20 +577,20 @@ typedef struct HB_ChainContextPosFormat1_ HB_ChainContextPosFormat1; struct HB_ChainPosClassRule_ { + HB_UShort* Backtrack; /* array of backtrack classes */ + HB_UShort* Input; /* array of context classes */ + HB_UShort* Lookahead; /* array of lookahead classes */ + HB_PosLookupRecord* PosLookupRecord; + /* array of substitution lookups */ HB_UShort BacktrackGlyphCount; /* total number of backtrack classes */ - HB_UShort* Backtrack; /* array of backtrack classes */ HB_UShort InputGlyphCount; /* total number of context classes */ - HB_UShort* Input; /* array of context classes */ HB_UShort LookaheadGlyphCount; /* total number of lookahead classes */ - HB_UShort* Lookahead; /* array of lookahead classes */ HB_UShort PosCount; /* number of PosLookupRecords */ - HB_PosLookupRecord* PosLookupRecord; - /* array of substitution lookups */ }; typedef struct HB_ChainPosClassRule_ HB_ChainPosClassRule; diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c b/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c index 61e42fd..1933f3d 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c @@ -256,6 +256,20 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, else vr->YAdvance = 0; + if ( format & HB_GPOS_FORMAT_HAVE_DEVICE_TABLES ) + { + if ( ALLOC_ARRAY( vr->DeviceTables, 4, HB_Device ) ) + return error; + vr->DeviceTables[VR_X_ADVANCE_DEVICE] = 0; + vr->DeviceTables[VR_Y_ADVANCE_DEVICE] = 0; + vr->DeviceTables[VR_X_PLACEMENT_DEVICE] = 0; + vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] = 0; + } + else + { + vr->DeviceTables = 0; + } + if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE ) { if ( ACCESS_Frame( 2L ) ) @@ -271,18 +285,11 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, cur_offset = FILE_Pos(); if ( FILE_Seek( new_offset ) || - ( error = _HB_OPEN_Load_Device( &vr->XPlacementDevice, + ( error = _HB_OPEN_Load_Device( &vr->DeviceTables[VR_X_PLACEMENT_DEVICE], stream ) ) != HB_Err_Ok ) return error; (void)FILE_Seek( cur_offset ); } - else - goto empty1; - } - else - { - empty1: - vr->XPlacementDevice = 0; } if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE ) @@ -300,18 +307,11 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, cur_offset = FILE_Pos(); if ( FILE_Seek( new_offset ) || - ( error = _HB_OPEN_Load_Device( &vr->YPlacementDevice, + ( error = _HB_OPEN_Load_Device( &vr->DeviceTables[VR_Y_PLACEMENT_DEVICE], stream ) ) != HB_Err_Ok ) goto Fail3; (void)FILE_Seek( cur_offset ); } - else - goto empty2; - } - else - { - empty2: - vr->YPlacementDevice = 0; } if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE ) @@ -329,18 +329,11 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, cur_offset = FILE_Pos(); if ( FILE_Seek( new_offset ) || - ( error = _HB_OPEN_Load_Device( &vr->XAdvanceDevice, + ( error = _HB_OPEN_Load_Device( &vr->DeviceTables[VR_X_ADVANCE_DEVICE], stream ) ) != HB_Err_Ok ) goto Fail2; (void)FILE_Seek( cur_offset ); } - else - goto empty3; - } - else - { - empty3: - vr->XAdvanceDevice = 0; } if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE ) @@ -358,18 +351,11 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, cur_offset = FILE_Pos(); if ( FILE_Seek( new_offset ) || - ( error = _HB_OPEN_Load_Device( &vr->YAdvanceDevice, + ( error = _HB_OPEN_Load_Device( &vr->DeviceTables[VR_Y_ADVANCE_DEVICE], stream ) ) != HB_Err_Ok ) goto Fail1; (void)FILE_Seek( cur_offset ); } - else - goto empty4; - } - else - { - empty4: - vr->YAdvanceDevice = 0; } if ( format & HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT ) @@ -447,13 +433,15 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr, return HB_Err_Ok; Fail1: - _HB_OPEN_Free_Device( &vr->YAdvanceDevice ); + _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_ADVANCE_DEVICE] ); Fail2: - _HB_OPEN_Free_Device( &vr->XAdvanceDevice ); + _HB_OPEN_Free_Device( &vr->DeviceTables[VR_X_ADVANCE_DEVICE] ); Fail3: - _HB_OPEN_Free_Device( &vr->YPlacementDevice ); + _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] ); + + FREE( vr->DeviceTables ); return error; } @@ -462,13 +450,14 @@ static void Free_ValueRecord( HB_ValueRecord* vr, HB_UShort format ) { if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE ) - _HB_OPEN_Free_Device( &vr->YAdvanceDevice ); + _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_ADVANCE_DEVICE] ); if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE ) - _HB_OPEN_Free_Device( &vr->XAdvanceDevice ); + _HB_OPEN_Free_Device( &vr->DeviceTables[VR_X_ADVANCE_DEVICE] ); if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE ) - _HB_OPEN_Free_Device( &vr->YPlacementDevice ); + _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] ); if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE ) - _HB_OPEN_Free_Device( &vr->XPlacementDevice ); + _HB_OPEN_Free_Device( &vr->DeviceTables[VR_X_PLACEMENT_DEVICE] ); + FREE( vr->DeviceTables ); } @@ -511,24 +500,34 @@ static HB_Error Get_ValueRecord( GPOS_Instance* gpi, { /* pixel -> fractional pixel */ + if ( format & HB_GPOS_FORMAT_HAVE_DEVICE_TABLES ) + { + if ( ALLOC_ARRAY( vr->DeviceTables, 4, HB_Device ) ) + return error; + vr->DeviceTables[VR_X_ADVANCE_DEVICE] = 0; + vr->DeviceTables[VR_Y_ADVANCE_DEVICE] = 0; + vr->DeviceTables[VR_X_PLACEMENT_DEVICE] = 0; + vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] = 0; + } + if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE ) { - _HB_OPEN_Get_Device( &vr->XPlacementDevice, x_ppem, &pixel_value ); + _HB_OPEN_Get_Device( &vr->DeviceTables[VR_X_PLACEMENT_DEVICE], x_ppem, &pixel_value ); gd->x_pos += pixel_value << 6; } if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE ) { - _HB_OPEN_Get_Device( &vr->YPlacementDevice, y_ppem, &pixel_value ); + _HB_OPEN_Get_Device( &vr->DeviceTables[VR_Y_PLACEMENT_DEVICE], y_ppem, &pixel_value ); gd->y_pos += pixel_value << 6; } if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE ) { - _HB_OPEN_Get_Device( &vr->XAdvanceDevice, x_ppem, &pixel_value ); + _HB_OPEN_Get_Device( &vr->DeviceTables[VR_X_ADVANCE_DEVICE], x_ppem, &pixel_value ); gd->x_advance += pixel_value << 6; } if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE ) { - _HB_OPEN_Get_Device( &vr->YAdvanceDevice, y_ppem, &pixel_value ); + _HB_OPEN_Get_Device( &vr->DeviceTables[VR_Y_ADVANCE_DEVICE], y_ppem, &pixel_value ); gd->y_advance += pixel_value << 6; } } diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h index 32f5781..ab5c07a 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h +++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h @@ -258,6 +258,10 @@ typedef struct HB_Font_ { void *userData; } HB_FontRec; +#ifdef HB_USE_PACKED_STRUCTS +#pragma pack(pop) +#endif + typedef struct HB_ShaperItem_ HB_ShaperItem; struct HB_ShaperItem_ { @@ -285,10 +289,6 @@ struct HB_ShaperItem_ { HB_Bool HB_ShapeItem(HB_ShaperItem *item); -#ifdef HB_USE_PACKED_STRUCTS -#pragma pack(pop) -#endif - HB_END_HEADER #endif -- cgit v0.12 From 618a64c9aa855625e34635c368c18e53aa3cffe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Fri, 18 Jun 2010 14:21:17 +0200 Subject: doc: Fixed type of Package::name Reviewed-by: Alan Alpert --- src/declarative/util/qdeclarativepackage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/util/qdeclarativepackage.cpp b/src/declarative/util/qdeclarativepackage.cpp index b149120..1e49ad9 100644 --- a/src/declarative/util/qdeclarativepackage.cpp +++ b/src/declarative/util/qdeclarativepackage.cpp @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE */ /*! - \qmlattachedproperty bool Package::name + \qmlattachedproperty string Package::name This attached property holds the name of an item within a Package. */ -- cgit v0.12