diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-05-07 06:20:45 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-05-07 06:20:45 (GMT) |
commit | 67bf465253db71c0eddbc6ffcb811dd65c00b207 (patch) | |
tree | 6683844454f67032e5f85be77e076d6282ccf603 /src | |
parent | 4976130171033abdd8323a19229dcbfc5b008cfe (diff) | |
parent | bdfa2d47fa1a6abee6e966f82fadf7a3d97bab0b (diff) | |
download | Qt-67bf465253db71c0eddbc6ffcb811dd65c00b207.zip Qt-67bf465253db71c0eddbc6ffcb811dd65c00b207.tar.gz Qt-67bf465253db71c0eddbc6ffcb811dd65c00b207.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativelistview.cpp | 10 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativemousearea.cpp | 19 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativemousearea_p.h | 1 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativelistmodel.cpp | 2 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeview.cpp | 16 | ||||
-rw-r--r-- | src/gui/styles/qs60style.cpp | 71 | ||||
-rw-r--r-- | src/gui/widgets/qcombobox_p.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/qtabbar.cpp | 39 | ||||
-rw-r--r-- | src/imports/imports.pro | 2 | ||||
-rw-r--r-- | src/imports/webkit/qdeclarativewebview.cpp | 33 | ||||
-rw-r--r-- | src/network/socket/qlocalserver_win.cpp | 2 | ||||
-rw-r--r-- | src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp | 2 | ||||
-rw-r--r-- | src/qt3support/widgets/q3spinwidget.cpp | 8 | ||||
-rw-r--r-- | src/testlib/qplaintestlogger.cpp | 1 |
14 files changed, 161 insertions, 47 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 328f319..416e0a8 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -650,7 +650,7 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer) FxListItem *item = 0; int pos = itemEnd + 1; while (modelIndex < model->count() && pos <= fillTo) { - //qDebug() << "refill: append item" << modelIndex << "pos" << pos; +// qDebug() << "refill: append item" << modelIndex << "pos" << pos; if (!(item = createItem(modelIndex))) break; item->setPosition(pos); @@ -661,8 +661,8 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer) if (doBuffer) // never buffer more than one item per frame break; } - while (visibleIndex > 0 && visibleIndex <= model->count() && visiblePos > fillFrom) { - //qDebug() << "refill: prepend item" << visibleIndex-1 << "current top pos" << visiblePos; + while (visibleIndex > 0 && visibleIndex <= model->count() && visiblePos-1 >= fillFrom) { +// qDebug() << "refill: prepend item" << visibleIndex-1 << "current top pos" << visiblePos; if (!(item = createItem(visibleIndex-1))) break; --visibleIndex; @@ -678,7 +678,7 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer) while (visibleItems.count() > 1 && (item = visibleItems.first()) && item->endPosition() < bufferFrom) { if (item->attached->delayRemove()) break; - //qDebug() << "refill: remove first" << visibleIndex << "top end pos" << item->endPosition(); +// qDebug() << "refill: remove first" << visibleIndex << "top end pos" << item->endPosition(); if (item->index != -1) visibleIndex++; visibleItems.removeFirst(); @@ -688,7 +688,7 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer) while (visibleItems.count() > 1 && (item = visibleItems.last()) && item->position() > bufferTo) { if (item->attached->delayRemove()) break; - //qDebug() << "refill: remove last" << visibleIndex+visibleItems.count()-1; +// qDebug() << "refill: remove last" << visibleIndex+visibleItems.count()-1 << item->position(); visibleItems.removeLast(); releaseItem(item); changed = true; diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index c5a995e..74f2338 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -288,6 +288,17 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate() */ /*! + \qmlsignal MouseArea::onCanceled() + + This handler is called when the mouse events are canceled, either because the event was not accepted or + another element stole the mouse event handling. This signal is for advanced users, it's useful in case there + is more than one mouse areas handling input, or when there is a mouse area inside a flickable. In the latter + case, if you do some logic on pressed and then start dragging, the flickable will steal the mouse handling + from the mouse area. In these cases, to reset the logic when there is no mouse handling anymore, you should + use onCanceled, in addition to onReleased. +*/ + +/*! \internal \class QDeclarativeMouseArea \brief The QDeclarativeMouseArea class provides a simple mouse handling abstraction for use within Qml. @@ -562,10 +573,12 @@ bool QDeclarativeMouseArea::sceneEvent(QEvent *event) // state d->pressed = false; setKeepMouseGrab(false); - QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, false); - emit released(&me); + emit canceled(); emit pressedChanged(); - setHovered(false); + if (d->hovered) { + d->hovered = false; + emit hoveredChanged(); + } } } return rv; diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p.h index e3f523b..df77ac6 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea_p.h +++ b/src/declarative/graphicsitems/qdeclarativemousearea_p.h @@ -163,6 +163,7 @@ Q_SIGNALS: void doubleClicked(QDeclarativeMouseEvent *mouse); void entered(); void exited(); + void canceled(); protected: void setHovered(bool); diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 3810256..0985a6b 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -591,7 +591,7 @@ void QDeclarativeListModel::set(int index, const QScriptValue& valuemap) Changes the \a property of the item at \a index in the list model to \a value. \code - fruitModel.set(3, "cost", 5.95) + fruitModel.setProperty(3, "cost", 5.95) \endcode The \a index must be an element in the list. diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index 62d913c..833e284 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -484,10 +484,7 @@ QSize QDeclarativeViewPrivate::rootObjectSize() QSize rootObjectSize(0,0); int widthCandidate = -1; int heightCandidate = -1; - if (declarativeItemRoot) { - widthCandidate = declarativeItemRoot->width(); - heightCandidate = declarativeItemRoot->height(); - } else if (root) { + if (root) { QSizeF size = root->boundingRect().size(); widthCandidate = size.width(); heightCandidate = size.height(); @@ -614,16 +611,15 @@ bool QDeclarativeView::eventFilter(QObject *watched, QEvent *e) /*! \internal - Preferred size follows the root object in - resize mode SizeViewToRootObject and - the view in resize mode SizeRootObjectToView. + Preferred size follows the root object geometry. */ QSize QDeclarativeView::sizeHint() const { - if (d->resizeMode == SizeRootObjectToView) { + QSize rootObjectSize = d->rootObjectSize(); + if (rootObjectSize.isEmpty()) { return size(); - } else { // d->resizeMode == SizeViewToRootObject - return d->rootObjectSize(); + } else { + return rootObjectSize; } } diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 90b8be3..20297ae 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1546,18 +1546,35 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); const int tabOverlap = QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap) - borderThickness; - - if (skinElement==QS60StylePrivate::SE_TabBarTabEastInactive|| - skinElement==QS60StylePrivate::SE_TabBarTabEastActive|| - skinElement==QS60StylePrivate::SE_TabBarTabWestInactive|| - skinElement==QS60StylePrivate::SE_TabBarTabWestActive){ - optionTabAdj.rect.adjust(0, 0, 0, tabOverlap); - } else { - if (directionMirrored) - optionTabAdj.rect.adjust(-tabOverlap, 0, 0, 0); + const bool usesScrollButtons = + (widget) ? (qobject_cast<const QTabBar*>(widget))->usesScrollButtons() : false; + const int roomForScrollButton = + usesScrollButtons ? QS60StylePrivate::pixelMetric(PM_TabBarScrollButtonWidth) : 0; + + // adjust for overlapping tabs and scrollbuttons, if necessary + if (skinElement == QS60StylePrivate::SE_TabBarTabEastInactive || + skinElement == QS60StylePrivate::SE_TabBarTabEastActive || + skinElement == QS60StylePrivate::SE_TabBarTabWestInactive || + skinElement == QS60StylePrivate::SE_TabBarTabWestActive){ + if (optionTabAdj.position == QStyleOptionTabV3::Beginning) + optionTabAdj.rect.adjust(0, roomForScrollButton, 0, tabOverlap); + else if (optionTabAdj.position == QStyleOptionTabV3::End) + optionTabAdj.rect.adjust(0, 0, 0, tabOverlap); else - optionTabAdj.rect.adjust(0, 0, tabOverlap, 0); + optionTabAdj.rect.adjust(0, 0, 0, tabOverlap); + } else { + if (directionMirrored) { + if (optionTabAdj.position == QStyleOptionTabV3::Beginning) + optionTabAdj.rect.adjust(-tabOverlap, 0, -roomForScrollButton, 0); + else + optionTabAdj.rect.adjust(-tabOverlap, 0, 0, 0); + } else { + if (optionTabAdj.position == QStyleOptionTabV3::Beginning) + optionTabAdj.rect.adjust(roomForScrollButton, 0, tabOverlap, 0); + else + optionTabAdj.rect.adjust(0, 0, tabOverlap, 0); } + } } QS60StylePrivate::drawSkinElement(skinElement, painter, optionTabAdj.rect, flags); } @@ -1570,7 +1587,10 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, const int borderThickness = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); const int tabOverlap = QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap) - borderThickness; - const QRect windowRect = painter->window(); + const bool usesScrollButtons = + (widget) ? (qobject_cast<const QTabBar*>(widget))->usesScrollButtons() : false; + const int roomForScrollButton = + usesScrollButtons ? QS60StylePrivate::pixelMetric(PM_TabBarScrollButtonWidth) : 0; switch (tab->shape) { case QTabBar::TriangularWest: @@ -1605,6 +1625,17 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, || optionTab.shape == QTabBar::TriangularEast || optionTab.shape == QTabBar::TriangularWest; + //make room for scrollbuttons + if (!verticalTabs) { + if ((tab->position == QStyleOptionTabV3::Beginning && !directionMirrored)) + tr.adjust(roomForScrollButton, 0, 0, 0); + else if ((tab->position == QStyleOptionTabV3::Beginning && directionMirrored)) + tr.adjust(0, 0, -roomForScrollButton, 0); + } else { + if (tab->position == QStyleOptionTabV3::Beginning) + tr.adjust(0, roomForScrollButton, 0, 0); + } + if (verticalTabs) { painter->save(); int newX, newY, newRotation; @@ -1636,9 +1667,10 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, alignment |= Qt::TextHideMnemonic; if (!optionTab.icon.isNull()) { QSize iconSize = optionTab.iconSize; - int iconExtent = pixelMetric(PM_TabBarIconSize); - if (iconSize.height() > iconExtent || iconSize.width() > iconExtent) + if (!iconSize.isValid()) { + const int iconExtent = pixelMetric(PM_TabBarIconSize); iconSize = QSize(iconExtent, iconExtent); + } QPixmap tabIcon = optionTab.icon.pixmap(iconSize, (optionTab.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); if (tab->text.isEmpty()) @@ -2490,6 +2522,19 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget); if (naviPaneSize.height() > sz.height()) sz.setHeight(naviPaneSize.height()); + // Adjust beginning tabbar item size, if scrollbuttons are used. This is to ensure that the + // tabbar item content fits, since scrollbuttons are making beginning tabbar item smaller. + int scrollButtonSize = 0; + if (const QTabBar *tabBar = qobject_cast<const QTabBar *>(widget)) + scrollButtonSize = tabBar->usesScrollButtons() ? pixelMetric(PM_TabBarScrollButtonWidth) : 0; + if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { + const bool verticalTabs = tab->shape == QTabBar::RoundedEast + || tab->shape == QTabBar::RoundedWest + || tab->shape == QTabBar::TriangularEast + || tab->shape == QTabBar::TriangularWest; + if (tab->position == QStyleOptionTab::Beginning) + sz += QSize(verticalTabs ? 0 : scrollButtonSize, !verticalTabs ? 0 : scrollButtonSize); + } } break; case CT_MenuItem: diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h index 92d85cc..29a628c 100644 --- a/src/gui/widgets/qcombobox_p.h +++ b/src/gui/widgets/qcombobox_p.h @@ -200,7 +200,9 @@ protected: menuOpt.menuItemType = QStyleOptionMenuItem::Scroller; if (sliderAction == QAbstractSlider::SliderSingleStepAdd) menuOpt.state |= QStyle::State_DownArrow; +#ifndef Q_WS_S60 p.eraseRect(rect()); +#endif style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, &p); } diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index 8aaaade..d692307 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -67,6 +67,10 @@ #include <private/qt_cocoa_helpers_mac_p.h> #endif +#ifndef QT_NO_STYLE_S60 +#include "qs60style.h" +#endif + QT_BEGIN_NAMESPACE @@ -490,6 +494,9 @@ void QTabBarPrivate::layoutTabs() if (useScrollButtons && tabList.count() && last > available) { int extra = extraWidth(); +#ifndef QT_NO_STYLE_S60 + QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style()); +#endif if (!vertTabs) { Qt::LayoutDirection ld = q->layoutDirection(); QRect arrows = QStyle::visualRect(ld, q->rect(), @@ -497,25 +504,57 @@ void QTabBarPrivate::layoutTabs() int buttonOverlap = q->style()->pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap, 0, q); if (ld == Qt::LeftToRight) { +// In S60style, tab scroll buttons are layoutted separately, on the sides of the tabbar. +#ifndef QT_NO_STYLE_S60 + if (s60Style) { + rightB->setGeometry(arrows.left() + extra / 2, arrows.top(), extra / 2, arrows.height()); + leftB->setGeometry(0, arrows.top(), extra / 2, arrows.height()); + } else { +#endif leftB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height()); rightB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(), extra/2, arrows.height()); +#ifndef QT_NO_STYLE_S60 + } +#endif leftB->setArrowType(Qt::LeftArrow); rightB->setArrowType(Qt::RightArrow); } else { +#ifndef QT_NO_STYLE_S60 + if (s60Style) { + rightB->setGeometry(arrows.left() + extra / 2, arrows.top(), extra / 2, arrows.height()); + leftB->setGeometry(0, arrows.top(), extra / 2, arrows.height()); + } else { +#endif rightB->setGeometry(arrows.left(), arrows.top(), extra/2, arrows.height()); leftB->setGeometry(arrows.right() - extra/2 + buttonOverlap, arrows.top(), extra/2, arrows.height()); +#ifndef QT_NO_STYLE_S60 + } +#endif rightB->setArrowType(Qt::LeftArrow); leftB->setArrowType(Qt::RightArrow); } } else { +#ifndef QT_NO_STYLE_S60 + if (s60Style) { + QRect arrows = QRect(0, 0, size.width(), available ); + leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra / 2); + leftB->setArrowType(Qt::UpArrow); + rightB->setGeometry(arrows.left(), arrows.bottom() - extra / 2 + 1, + arrows.width(), extra / 2); + rightB->setArrowType(Qt::DownArrow); + } else { +#endif QRect arrows = QRect(0, available - extra, size.width(), extra ); leftB->setGeometry(arrows.left(), arrows.top(), arrows.width(), extra/2); leftB->setArrowType(Qt::UpArrow); rightB->setGeometry(arrows.left(), arrows.bottom() - extra/2 + 1, arrows.width(), extra/2); rightB->setArrowType(Qt::DownArrow); +#ifndef QT_NO_STYLE_S60 + } +#endif } leftB->setEnabled(scrollOffset > 0); rightB->setEnabled(last - scrollOffset >= available - extra); diff --git a/src/imports/imports.pro b/src/imports/imports.pro index 1754908..a9d600e 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs -SUBDIRS += particles +SUBDIRS += particles gestures contains(QT_CONFIG, webkit): SUBDIRS += webkit contains(QT_CONFIG, mediaservices): SUBDIRS += multimedia diff --git a/src/imports/webkit/qdeclarativewebview.cpp b/src/imports/webkit/qdeclarativewebview.cpp index 5db812c..9571470 100644 --- a/src/imports/webkit/qdeclarativewebview.cpp +++ b/src/imports/webkit/qdeclarativewebview.cpp @@ -437,24 +437,39 @@ void QDeclarativeWebView::paintPage(const QRect& r) /*! \qmlproperty list<object> WebView::javaScriptWindowObjects - This property is a list of object that are available from within - the webview's JavaScript context. + A list of QML objects to expose to the web page. - The \a object will be inserted as a child of the frame's window - object, under the name given by the attached property \c WebView.windowObjectName. + Each object will be added as a property of the web frame's window object. The + property name is controlled by the value of \c WebView.windowObjectName + attached property. + + Exposing QML objects to a web page allows JavaScript executing in the web + page itself to communicate with QML, by reading and writing properties and + by calling methods of the exposed QML objects. + + This example shows how to call into a QML method using a window object. \qml WebView { - javaScriptWindowObjects: Object { - WebView.windowObjectName: "coordinates" + javaScriptWindowObjects: QtObject { + WebView.windowObjectName: "qml" + + function qmlCall() { + console.log("This call is in QML!"); + } } + + html: "<script>console.log(\"This is in WebKit!\"); window.qml.qmlCall();</script>" } \endqml - Properties of the object will be exposed as JavaScript properties and slots as - JavaScript methods. + The output of the example will be: + \code + This is in WebKit! + This call is in QML! + \endcode - If Javascript is not enabled for this page, then this property does nothing. + If Javascript is not enabled for the page, then this property does nothing. */ QDeclarativeListProperty<QObject> QDeclarativeWebView::javaScriptWindowObjects() { diff --git a/src/network/socket/qlocalserver_win.cpp b/src/network/socket/qlocalserver_win.cpp index 5d2be72..07baf1e 100644 --- a/src/network/socket/qlocalserver_win.cpp +++ b/src/network/socket/qlocalserver_win.cpp @@ -167,8 +167,8 @@ void QLocalServerPrivate::_q_onNewConnection() q->incomingConnection((quintptr)handle); } else { if (GetLastError() != ERROR_IO_INCOMPLETE) { + q->close(); setError(QLatin1String("QLocalServerPrivate::_q_onNewConnection")); - closeServer(); return; } diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp index 964fa53..9de2a34 100644 --- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp +++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp @@ -259,7 +259,7 @@ int PvrEglScreen::transformation() const if (parent->classId() != QScreen::TransformedClass) return 0; return 90 * static_cast<const QTransformedScreen *>(parent) - ->transformation(); + ->transformOrientation(); } #else diff --git a/src/qt3support/widgets/q3spinwidget.cpp b/src/qt3support/widgets/q3spinwidget.cpp index 3dc36c5..3bfad06 100644 --- a/src/qt3support/widgets/q3spinwidget.cpp +++ b/src/qt3support/widgets/q3spinwidget.cpp @@ -340,11 +340,13 @@ void Q3SpinWidget::paintEvent(QPaintEvent *) QPainter p(this); QStyleOptionSpinBox opt = getStyleOption(this); - if (d->theButton & 1) + if (d->theButton & 1) { opt.activeSubControls = QStyle::SC_SpinBoxDown; - else if (d->theButton & 2) + opt.state |= QStyle::State_Sunken; + } else if (d->theButton & 2) { opt.activeSubControls = QStyle::SC_SpinBoxUp; - else + opt.state |= QStyle::State_Sunken; + } else opt.activeSubControls = QStyle::SC_None; opt.rect = style()->subControlRect(QStyle::CC_SpinBox, &opt, QStyle::SC_SpinBoxFrame, this); opt.subControls = QStyle::SC_All; diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index 46431a8..1a0e737 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -182,6 +182,7 @@ namespace QTest { hbuffer->Des().Copy(ptr.Mid(i, size)); RDebug::Print(format, hbuffer); } + delete hbuffer; } else { // fast, no allocations, but truncates silently |