aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/items/qquickitem.cpp')
-rw-r--r--src/quick/items/qquickitem.cpp246
1 files changed, 129 insertions, 117 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 5739d6874e..2a507a27b1 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -2707,6 +2707,8 @@ QQuickItemPrivate::QQuickItemPrivate()
, culled(false)
, hasCursor(false)
, activeFocusOnTab(false)
+ , implicitAntialiasing(false)
+ , antialiasingValid(false)
, dirtyAttributes(0)
, nextDirtyItem(0)
, prevDirtyItem(0)
@@ -4478,96 +4480,6 @@ void QQuickItemPrivate::deliverInputMethodEvent(QInputMethodEvent *e)
}
#endif // QT_NO_IM
-void QQuickItemPrivate::deliverFocusEvent(QFocusEvent *e)
-{
- Q_Q(QQuickItem);
-
- if (e->type() == QEvent::FocusIn) {
- q->focusInEvent(e);
- } else {
- q->focusOutEvent(e);
- }
-}
-
-void QQuickItemPrivate::deliverMouseEvent(QMouseEvent *e)
-{
- Q_Q(QQuickItem);
-
- Q_ASSERT(e->isAccepted());
-
- switch (e->type()) {
- default:
- Q_ASSERT(!"Unknown event type");
- case QEvent::MouseMove:
- q->mouseMoveEvent(e);
- break;
- case QEvent::MouseButtonPress:
- q->mousePressEvent(e);
- break;
- case QEvent::MouseButtonRelease:
- q->mouseReleaseEvent(e);
- break;
- case QEvent::MouseButtonDblClick:
- q->mouseDoubleClickEvent(e);
- break;
- }
-}
-
-#ifndef QT_NO_WHEELEVENT
-void QQuickItemPrivate::deliverWheelEvent(QWheelEvent *e)
-{
- Q_Q(QQuickItem);
- q->wheelEvent(e);
-}
-#endif
-
-void QQuickItemPrivate::deliverTouchEvent(QTouchEvent *e)
-{
- Q_Q(QQuickItem);
- q->touchEvent(e);
-}
-
-void QQuickItemPrivate::deliverHoverEvent(QHoverEvent *e)
-{
- Q_Q(QQuickItem);
- switch (e->type()) {
- default:
- Q_ASSERT(!"Unknown event type");
- case QEvent::HoverEnter:
- q->hoverEnterEvent(e);
- break;
- case QEvent::HoverLeave:
- q->hoverLeaveEvent(e);
- break;
- case QEvent::HoverMove:
- q->hoverMoveEvent(e);
- break;
- }
-}
-
-#ifndef QT_NO_DRAGANDDROP
-void QQuickItemPrivate::deliverDragEvent(QEvent *e)
-{
- Q_Q(QQuickItem);
- switch (e->type()) {
- default:
- Q_ASSERT(!"Unknown event type");
- case QEvent::DragEnter:
- q->dragEnterEvent(static_cast<QDragEnterEvent *>(e));
- break;
- case QEvent::DragLeave:
- q->dragLeaveEvent(static_cast<QDragLeaveEvent *>(e));
- break;
- case QEvent::DragMove:
- q->dragMoveEvent(static_cast<QDragMoveEvent *>(e));
- break;
- case QEvent::Drop:
- q->dropEvent(static_cast<QDropEvent *>(e));
- break;
- }
-}
-#endif // QT_NO_DRAGANDDROP
-
/*!
Called when \a change occurs for this item.
@@ -5573,6 +5485,9 @@ void QQuickItemPrivate::itemChange(QQuickItem::ItemChange change, const QQuickIt
}
}
break;
+ case QQuickItem::ItemAntialiasingHasChanged:
+ q->itemChange(change, data);
+ break;
}
}
@@ -5666,37 +5581,65 @@ void QQuickItem::setActiveFocusOnTab(bool activeFocusOnTab)
/*!
\qmlproperty bool QtQuick::Item::antialiasing
- Primarily used in Rectangle and image based elements to decide if the item should
- use antialiasing or not. Items with antialiasing enabled require more memory and
- are potentially slower to render.
+ Used by visual elements to decide if the item should use antialiasing or not.
+ In some cases items with antialiasing require more memory and are potentially
+ slower to render (see \l {Antialiasing} for more details).
- The default is false.
+ The default is false, but may be overridden by derived elements.
*/
/*!
\property QQuickItem::antialiasing
\brief Specifies whether the item is antialiased or not
- Primarily used in Rectangle and image based elements to decide if the item should
- use antialiasing or not. Items with antialiasing enabled require more memory and
- are potentially slower to render.
+ Used by visual elements to decide if the item should use antialiasing or not.
+ In some cases items with antialiasing require more memory and are potentially
+ slower to render (see \l {Antialiasing} for more details).
- The default is false.
+ The default is false, but may be overridden by derived elements.
*/
bool QQuickItem::antialiasing() const
{
Q_D(const QQuickItem);
- return d->antialiasing;
+ return d->antialiasingValid ? d->antialiasing : d->implicitAntialiasing;
}
-void QQuickItem::setAntialiasing(bool antialiasing)
+
+void QQuickItem::setAntialiasing(bool aa)
{
Q_D(QQuickItem);
- if (d->antialiasing == antialiasing)
+
+ bool changed = (aa != antialiasing());
+ d->antialiasingValid = true;
+
+ if (!changed)
return;
- d->antialiasing = antialiasing;
+ d->antialiasing = aa;
d->dirty(QQuickItemPrivate::Antialiasing);
- emit antialiasingChanged(antialiasing);
+ d->itemChange(ItemAntialiasingHasChanged, d->antialiasing);
+
+ emit antialiasingChanged(antialiasing());
+}
+
+void QQuickItem::resetAntialiasing()
+{
+ Q_D(QQuickItem);
+ if (!d->antialiasingValid)
+ return;
+
+ d->antialiasingValid = false;
+
+ if (d->implicitAntialiasing != d->antialiasing)
+ emit antialiasingChanged(antialiasing());
+}
+
+void QQuickItemPrivate::setImplicitAntialiasing(bool antialiasing)
+{
+ Q_Q(QQuickItem);
+ bool prev = q->antialiasing();
+ implicitAntialiasing = antialiasing;
+ if (componentComplete && (q->antialiasing() != prev))
+ emit q->antialiasingChanged(q->antialiasing());
}
/*!
@@ -6539,6 +6482,17 @@ void QQuickItemPrivate::incrementCursorCount(int delta)
#endif
}
+void QQuickItemPrivate::markObjects(QV4::ExecutionEngine *e)
+{
+ Q_Q(QQuickItem);
+ QQmlData *ddata = QQmlData::get(q);
+ if (ddata)
+ ddata->jsWrapper.markOnce(e);
+
+ foreach (QQuickItem *child, childItems)
+ QQuickItemPrivate::get(child)->markObjects(e);
+}
+
#ifndef QT_NO_CURSOR
/*!
@@ -6981,18 +6935,17 @@ QRectF QQuickItem::mapRectFromScene(const QRectF &rect) const
*/
bool QQuickItem::event(QEvent *ev)
{
+ Q_D(QQuickItem);
+
+ switch (ev->type()) {
#if 0
- if (ev->type() == QEvent::PolishRequest) {
- Q_D(QQuickItem);
+ case QEvent::PolishRequest:
d->polishScheduled = false;
updatePolish();
- return true;
- } else {
- return QObject::event(ev);
- }
+ break;
#endif
#ifndef QT_NO_IM
- if (ev->type() == QEvent::InputMethodQuery) {
+ case QEvent::InputMethodQuery: {
QInputMethodQueryEvent *query = static_cast<QInputMethodQueryEvent *>(ev);
Qt::InputMethodQueries queries = query->queries();
for (uint i = 0; i < 32; ++i) {
@@ -7003,20 +6956,79 @@ bool QQuickItem::event(QEvent *ev)
}
}
query->accept();
- return true;
- } else if (ev->type() == QEvent::InputMethod) {
+ break;
+ }
+ case QEvent::InputMethod:
inputMethodEvent(static_cast<QInputMethodEvent *>(ev));
- return true;
- } else
+ break;
#endif // QT_NO_IM
- if (ev->type() == QEvent::StyleAnimationUpdate) {
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ case QEvent::TouchCancel:
+ touchEvent(static_cast<QTouchEvent*>(ev));
+ break;
+ case QEvent::StyleAnimationUpdate:
if (isVisible()) {
ev->accept();
update();
}
- return true;
+ break;
+ case QEvent::HoverEnter:
+ hoverEnterEvent(static_cast<QHoverEvent*>(ev));
+ break;
+ case QEvent::HoverLeave:
+ hoverLeaveEvent(static_cast<QHoverEvent*>(ev));
+ break;
+ case QEvent::HoverMove:
+ hoverMoveEvent(static_cast<QHoverEvent*>(ev));
+ break;
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ d->deliverKeyEvent(static_cast<QKeyEvent*>(ev));
+ break;
+ case QEvent::FocusIn:
+ focusInEvent(static_cast<QFocusEvent*>(ev));
+ break;
+ case QEvent::FocusOut:
+ focusOutEvent(static_cast<QFocusEvent*>(ev));
+ break;
+ case QEvent::MouseMove:
+ mouseMoveEvent(static_cast<QMouseEvent*>(ev));
+ break;
+ case QEvent::MouseButtonPress:
+ mousePressEvent(static_cast<QMouseEvent*>(ev));
+ break;
+ case QEvent::MouseButtonRelease:
+ mouseReleaseEvent(static_cast<QMouseEvent*>(ev));
+ break;
+ case QEvent::MouseButtonDblClick:
+ mouseDoubleClickEvent(static_cast<QMouseEvent*>(ev));
+ break;
+#ifndef QT_NO_WHEELEVENT
+ case QEvent::Wheel:
+ wheelEvent(static_cast<QWheelEvent*>(ev));
+ break;
+#endif
+#ifndef QT_NO_DRAGANDDROP
+ case QEvent::DragEnter:
+ dragEnterEvent(static_cast<QDragEnterEvent*>(ev));
+ break;
+ case QEvent::DragLeave:
+ dragLeaveEvent(static_cast<QDragLeaveEvent*>(ev));
+ break;
+ case QEvent::DragMove:
+ dragMoveEvent(static_cast<QDragMoveEvent*>(ev));
+ break;
+ case QEvent::Drop:
+ dropEvent(static_cast<QDropEvent*>(ev));
+ break;
+#endif // QT_NO_DRAGANDDROP
+ default:
+ return QObject::event(ev);
}
- return QObject::event(ev);
+
+ return true;
}
#ifndef QT_NO_DEBUG_STREAM