summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-07 08:21:42 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-07 08:21:42 (GMT)
commit525f585465029075bace5f68997bea07e64f7725 (patch)
tree522873174e168d18120048783bcc050a3eaecce0 /src/gui/graphicsview
parenta0c12d54b8eef537ab8051e48b6d04617a91d170 (diff)
downloadQt-525f585465029075bace5f68997bea07e64f7725.zip
Qt-525f585465029075bace5f68997bea07e64f7725.tar.gz
Qt-525f585465029075bace5f68997bea07e64f7725.tar.bz2
Add ChangeFlags to QGraphicsEffect and pass flags to sourceChanged.
This is way more flexible as it allows for extension in the future. Instead of having several virtual functions, which in most cases when re-implemented have to do exactly the same, we now have one virtual function which takes a ChangedFlags parameter do describe what kind of changes that occurred to the source.
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicseffect.cpp13
-rw-r--r--src/gui/graphicsview/qgraphicseffect.h12
-rw-r--r--src/gui/graphicsview/qgraphicseffect_p.h6
3 files changed, 18 insertions, 13 deletions
diff --git a/src/gui/graphicsview/qgraphicseffect.cpp b/src/gui/graphicsview/qgraphicseffect.cpp
index 6f60ab9..b04af7a 100644
--- a/src/gui/graphicsview/qgraphicseffect.cpp
+++ b/src/gui/graphicsview/qgraphicseffect.cpp
@@ -316,19 +316,12 @@ void QGraphicsEffect::updateBoundingRect()
This virtual function is called by QGraphicsEffect to notify the effect
that the source has changed. If the effect applies any cache, then this
cache must be purged in order to reflect the new appearance of the source.
-*/
-void QGraphicsEffect::sourceChanged()
-{
-}
-/*!
- This virtual function is called by QGraphicsEffect to notify the effect
- that the source's bounding rectangle has changed. If the effect applies any
- cache, then this cache must be purged in order to reflect the new
- appearance of the source.
+ The \a flags describes what has changed.
*/
-void QGraphicsEffect::sourceBoundingRectChanged()
+void QGraphicsEffect::sourceChanged(ChangeFlags flags)
{
+ Q_UNUSED(flags);
}
QGraphicsGrayscaleEffect::QGraphicsGrayscaleEffect()
diff --git a/src/gui/graphicsview/qgraphicseffect.h b/src/gui/graphicsview/qgraphicseffect.h
index bb79563..d171b1b 100644
--- a/src/gui/graphicsview/qgraphicseffect.h
+++ b/src/gui/graphicsview/qgraphicseffect.h
@@ -94,8 +94,17 @@ class QGraphicsEffectPrivate;
class Q_GUI_EXPORT QGraphicsEffect : public QObject
{
Q_OBJECT
+ Q_FLAGS(ChangeFlags)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
public:
+ enum ChangeFlag {
+ SourceAttached = 0x1,
+ SourceDetached = 0x2,
+ SourceBoundingRectChanged = 0x4,
+ SourceInvalidated = 0x8
+ };
+ Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag);
+
QGraphicsEffect();
virtual ~QGraphicsEffect();
@@ -114,8 +123,7 @@ public Q_SLOTS:
protected:
QGraphicsEffect(QGraphicsEffectPrivate &d);
virtual void draw(QPainter *painter, QGraphicsEffectSource *source) = 0;
- virtual void sourceChanged();
- virtual void sourceBoundingRectChanged();
+ virtual void sourceChanged(ChangeFlags flags);
void updateBoundingRect();
private:
diff --git a/src/gui/graphicsview/qgraphicseffect_p.h b/src/gui/graphicsview/qgraphicseffect_p.h
index 6664a03..6d546cc 100644
--- a/src/gui/graphicsview/qgraphicseffect_p.h
+++ b/src/gui/graphicsview/qgraphicseffect_p.h
@@ -94,12 +94,16 @@ public:
inline void setGraphicsEffectSource(QGraphicsEffectSource *newSource)
{
+ QGraphicsEffect::ChangeFlags flags;
if (source) {
+ flags |= QGraphicsEffect::SourceDetached;
source->d_func()->detach();
delete source;
}
source = newSource;
- q_func()->sourceChanged();
+ if (newSource)
+ flags |= QGraphicsEffect::SourceAttached;
+ q_func()->sourceChanged(flags);
}
QGraphicsEffectSource *source;