summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-03-08 05:26:30 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-03-09 05:47:00 (GMT)
commit4367951cbb4a0ddb739724878dc9a1cabad5a773 (patch)
tree75ec265505c522eda16ee97ccc2db5440bd3b8e5 /src/declarative/graphicsitems
parent173994419413e89e6b1c7ab3cf58dff82f1e5789 (diff)
downloadQt-4367951cbb4a0ddb739724878dc9a1cabad5a773.zip
Qt-4367951cbb4a0ddb739724878dc9a1cabad5a773.tar.gz
Qt-4367951cbb4a0ddb739724878dc9a1cabad5a773.tar.bz2
Make QDeclarativeItem NOTIFY signals canonical
Task-number: QTBUG-7193 Reviewed-by: akennedy
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r--src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp8
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp40
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.h23
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem_p.h6
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativepainteditem.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp14
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp10
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p_p.h1
12 files changed, 50 insertions, 65 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp
index 1977817..eb5b6ce 100644
--- a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp
@@ -65,12 +65,12 @@ public:
if (graphicsObject && graphicsObject->isWidget()) {
if (!on) {
graphicsObject->removeEventFilter(q);
- QObject::disconnect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
- QObject::disconnect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
+ QObject::disconnect(q, SIGNAL(widthChanged(qreal)), q, SLOT(_q_updateSize()));
+ QObject::disconnect(q, SIGNAL(heightChanged(qreal)), q, SLOT(_q_updateSize()));
} else {
graphicsObject->installEventFilter(q);
- QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
- QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
+ QObject::connect(q, SIGNAL(widthChanged(qreal)), q, SLOT(_q_updateSize()));
+ QObject::connect(q, SIGNAL(heightChanged(qreal)), q, SLOT(_q_updateSize()));
}
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 1ac26b4..7c6c46b 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -273,7 +273,7 @@ void QDeclarativeContents::calcHeight()
m_height = qMax(bottom - top, qreal(0.0));
if (m_height != oldheight || m_y != oldy)
- emit rectChanged();
+ emit rectChanged(rectF());
}
//TODO: optimization: only check sender(), if there is one
@@ -301,7 +301,7 @@ void QDeclarativeContents::calcWidth()
m_width = qMax(right - left, qreal(0.0));
if (m_width != oldwidth || m_x != oldx)
- emit rectChanged();
+ emit rectChanged(rectF());
}
void QDeclarativeContents::setItem(QDeclarativeItem *item)
@@ -313,11 +313,11 @@ void QDeclarativeContents::setItem(QDeclarativeItem *item)
QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(i));
if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects?
continue;
- connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight()));
+ connect(child, SIGNAL(heightChanged(qreal)), this, SLOT(calcHeight()));
connect(child, SIGNAL(yChanged()), this, SLOT(calcHeight()));
- connect(child, SIGNAL(widthChanged()), this, SLOT(calcWidth()));
+ connect(child, SIGNAL(widthChanged(qreal)), this, SLOT(calcWidth()));
connect(child, SIGNAL(xChanged()), this, SLOT(calcWidth()));
- connect(this, SIGNAL(rectChanged()), m_item, SIGNAL(childrenRectChanged()));
+ connect(this, SIGNAL(rectChanged(QRectF)), m_item, SIGNAL(childrenRectChanged(QRectF)));
}
calcHeight();
@@ -1652,7 +1652,7 @@ void QDeclarativeItem::setClip(bool c)
if (clip() == c)
return;
setFlag(ItemClipsChildrenToShape, c);
- emit clipChanged();
+ emit clipChanged(c);
}
/*!
@@ -1792,11 +1792,11 @@ void QDeclarativeItem::geometryChanged(const QRectF &newGeometry,
if (newGeometry.x() != oldGeometry.x())
emit xChanged();
if (newGeometry.width() != oldGeometry.width())
- emit widthChanged();
+ emit widthChanged(newGeometry.width());
if (newGeometry.y() != oldGeometry.y())
emit yChanged();
if (newGeometry.height() != oldGeometry.height())
- emit heightChanged();
+ emit heightChanged(newGeometry.height());
for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
@@ -2058,7 +2058,6 @@ void QDeclarativeItem::setBaselineOffset(qreal offset)
return;
d->_baselineOffset = offset;
- emit baselineOffsetChanged();
for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
@@ -2068,6 +2067,7 @@ void QDeclarativeItem::setBaselineOffset(qreal offset)
anchor->updateVerticalAnchors();
}
}
+ emit baselineOffsetChanged(offset);
}
/*!
@@ -2265,18 +2265,10 @@ QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, qreal x, qrea
return sv;
}
-/*!
- \internal
-
- This function emits the \e focusChanged signal.
-
- Subclasses overriding this function should call up
- to their base class.
-*/
-void QDeclarativeItem::focusChanged(bool flag)
+void QDeclarativeItemPrivate::focusChanged(bool flag)
{
- Q_UNUSED(flag);
- emit focusChanged();
+ Q_Q(QDeclarativeItem);
+ emit q->focusChanged(flag);
}
/*! \internal */
@@ -2569,9 +2561,9 @@ QPointF QDeclarativeItemPrivate::computeTransformOrigin() const
/*! \internal */
bool QDeclarativeItem::sceneEvent(QEvent *event)
{
+ Q_D(QDeclarativeItem);
if (event->type() == QEvent::KeyPress) {
QKeyEvent *k = static_cast<QKeyEvent *>(event);
-
if ((k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) &&
!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) {
keyPressEvent(static_cast<QKeyEvent *>(event));
@@ -2587,7 +2579,7 @@ bool QDeclarativeItem::sceneEvent(QEvent *event)
if (event->type() == QEvent::FocusIn ||
event->type() == QEvent::FocusOut) {
- focusChanged(hasFocus());
+ d->focusChanged(hasFocus());
}
return rv;
}
@@ -2600,7 +2592,7 @@ QVariant QDeclarativeItem::itemChange(GraphicsItemChange change,
Q_D(const QDeclarativeItem);
switch (change) {
case ItemParentHasChanged:
- emit parentChanged();
+ emit parentChanged(parentItem());
break;
case ItemChildAddedChange:
case ItemChildRemovedChange:
@@ -2713,7 +2705,7 @@ void QDeclarativeItem::setSmooth(bool smooth)
if (d->smooth == smooth)
return;
d->smooth = smooth;
- emit smoothChanged();
+ emit smoothChanged(smooth);
update();
}
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h
index f9e0c7e..9b85ba3 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem.h
@@ -42,8 +42,8 @@
#ifndef QDECLARATIVEITEM_H
#define QDECLARATIVEITEM_H
-#include <qdeclarative.h>
-#include <qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarative.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
#include <QtCore/QObject>
#include <QtCore/QList>
@@ -173,18 +173,18 @@ public:
QDeclarativeAnchorLine baseline() const;
Q_SIGNALS:
- void widthChanged();
- void heightChanged();
+ void widthChanged(qreal);
+ void heightChanged(qreal);
void childrenChanged();
- void childrenRectChanged();
- void baselineOffsetChanged();
+ void childrenRectChanged(const QRectF &);
+ void baselineOffsetChanged(qreal);
void stateChanged(const QString &);
- void focusChanged();
- void wantsFocusChanged();
- void parentChanged();
+ void focusChanged(bool);
+ void wantsFocusChanged(bool);
+ void parentChanged(QDeclarativeItem *);
void transformOriginChanged(TransformOrigin);
- void smoothChanged();
- void clipChanged();
+ void smoothChanged(bool);
+ void clipChanged(bool);
protected:
bool isComponentComplete() const;
@@ -199,7 +199,6 @@ protected:
virtual void classBegin();
virtual void componentComplete();
- virtual void focusChanged(bool);
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event);
virtual void inputMethodEvent(QInputMethodEvent *);
diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h
index e424970..76ebcb4 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h
@@ -91,7 +91,7 @@ public Q_SLOTS:
void calcWidth();
Q_SIGNALS:
- void rectChanged();
+ void rectChanged(QRectF);
private:
QDeclarativeItem *m_item;
@@ -240,7 +240,7 @@ public:
// Reimplemented from QGraphicsItemPrivate
virtual void subFocusItemChange()
{
- emit q_func()->wantsFocusChanged();
+ emit q_func()->wantsFocusChanged(subFocusItem != 0);
}
// Reimplemented from QGraphicsItemPrivate
@@ -255,6 +255,8 @@ public:
}
}
+ virtual void focusChanged(bool);
+
static int consistentTime;
static QTime currentTime();
static void Q_DECLARATIVE_EXPORT setConsistentTime(int t);
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 73fe1e4..6385ddd 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -557,7 +557,7 @@ void QDeclarativeListViewPrivate::releaseItem(FxListItem *item)
return;
if (trackedItem == item) {
const char *notifier1 = orient == QDeclarativeListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
- const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
+ const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged(qreal)) : SIGNAL(widthChanged(qreal));
QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged()));
QObject::disconnect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged()));
trackedItem = 0;
@@ -748,7 +748,7 @@ void QDeclarativeListViewPrivate::updateTrackedItem()
FxListItem *oldTracked = trackedItem;
const char *notifier1 = orient == QDeclarativeListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
- const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
+ const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged(qreal)) : SIGNAL(widthChanged(qreal));
if (trackedItem && item != trackedItem) {
QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged()));
diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
index ab6007a..28a93d2 100644
--- a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
@@ -211,8 +211,8 @@ QDeclarativePaintedItem::~QDeclarativePaintedItem()
*/
void QDeclarativePaintedItem::init()
{
- connect(this,SIGNAL(widthChanged()),this,SLOT(clearCache()));
- connect(this,SIGNAL(heightChanged()),this,SLOT(clearCache()));
+ connect(this,SIGNAL(widthChanged(qreal)),this,SLOT(clearCache()));
+ connect(this,SIGNAL(heightChanged(qreal)),this,SLOT(clearCache()));
connect(this,SIGNAL(visibleChanged()),this,SLOT(clearCache()));
}
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index be73b39..dbae47d 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -760,17 +760,11 @@ void QDeclarativeTextEdit::keyReleaseEvent(QKeyEvent *event)
QDeclarativePaintedItem::keyReleaseEvent(event);
}
-/*!
- \overload
- Handles changing of the focus property. Focus is applied to the control
- even if the edit does not have active focus. This is because things
- like KeyProxy can give the behavior of focus even when hasFocus() isn't
- true.
-*/
-void QDeclarativeTextEdit::focusChanged(bool hasFocus)
+void QDeclarativeTextEditPrivate::focusChanged(bool hasFocus)
{
- setCursorVisible(hasFocus);
- QDeclarativeItem::focusChanged(hasFocus);
+ Q_Q(QDeclarativeTextEdit);
+ q->setCursorVisible(hasFocus);
+ QDeclarativeItemPrivate::focusChanged(hasFocus);
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
index 6183b1d..b1682c4 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
@@ -215,8 +215,6 @@ protected:
void keyPressEvent(QKeyEvent *);
void keyReleaseEvent(QKeyEvent *);
- void focusChanged(bool);
-
// mouse filter?
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
index 002fac4..dd2a29d 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
@@ -80,6 +80,7 @@ public:
void updateDefaultTextOption();
void relayoutDocument();
void updateSelection();
+ void focusChanged(bool);
QString text;
QFont font;
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 3382628..6df3533 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -636,12 +636,12 @@ int QDeclarativeTextInput::xToPos(int x)
return d->control->xToPos(x - d->hscroll);
}
-void QDeclarativeTextInput::focusChanged(bool hasFocus)
+void QDeclarativeTextInputPrivate::focusChanged(bool hasFocus)
{
- Q_D(QDeclarativeTextInput);
- d->focused = hasFocus;
- setCursorVisible(hasFocus);
- QDeclarativeItem::focusChanged(hasFocus);
+ Q_Q(QDeclarativeTextInput);
+ focused = hasFocus;
+ q->setCursorVisible(hasFocus);
+ QDeclarativeItemPrivate::focusChanged(hasFocus);
}
void QDeclarativeTextInput::keyPressEvent(QKeyEvent* ev)
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
index f690ae2..6a61c2d 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
@@ -199,8 +199,6 @@ protected:
void keyPressEvent(QKeyEvent* ev);
bool event(QEvent *e);
- void focusChanged(bool hasFocus);
-
public Q_SLOTS:
void selectAll();
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
index 3d28f40..5d17a55 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
@@ -83,6 +83,7 @@ public:
void init();
void startCreatingCursor();
+ void focusChanged(bool hasFocus);
QLineControl* control;