| 1 |
/* This file is part of the KDE project. |
| 2 |
|
| 3 |
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
| 4 |
|
| 5 |
This library is free software: you can redistribute it and/or modify |
| 6 |
it under the terms of the GNU Lesser General Public License as published by |
| 7 |
the Free Software Foundation, either version 2.1 or 3 of the License. |
| 8 |
|
| 9 |
This library is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU Lesser General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU Lesser General Public License |
| 15 |
along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
|
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef PHONON_MMF_ANCESTORMOVEMONITOR_H |
| 20 |
#define PHONON_MMF_ANCESTORMOVEMONITOR_H |
| 21 |
|
| 22 |
#include <QObject> |
| 23 |
#include <QHash> |
| 24 |
#include <QList> |
| 25 |
|
| 26 |
QT_BEGIN_NAMESPACE |
| 27 |
|
| 28 |
namespace Phonon |
| 29 |
{ |
| 30 |
namespace MMF |
| 31 |
{ |
| 32 |
class DsaVideoOutput; |
| 33 |
|
| 34 |
class AncestorMoveMonitor : public QObject |
| 35 |
{ |
| 36 |
Q_OBJECT |
| 37 |
|
| 38 |
public: |
| 39 |
explicit AncestorMoveMonitor(QObject *parent); |
| 40 |
~AncestorMoveMonitor(); |
| 41 |
|
| 42 |
/** |
| 43 |
* Register target widget for notification. |
| 44 |
* |
| 45 |
* The widget receives an ancestorMoveEvent callback when a move event |
| 46 |
* is delivered to any of its ancestors: |
| 47 |
* |
| 48 |
* If the target is already registered, this function causes its |
| 49 |
* ancestor list to be updated - therefore it should be called when |
| 50 |
* the target receives a ParentChange event. |
| 51 |
*/ |
| 52 |
void registerTarget(DsaVideoOutput *target); |
| 53 |
|
| 54 |
/** |
| 55 |
* Remove target from the monitor. |
| 56 |
* |
| 57 |
* The target will no longer receive notification when move events are |
| 58 |
* delivered to its ancestors. |
| 59 |
*/ |
| 60 |
void unRegisterTarget(DsaVideoOutput *target); |
| 61 |
|
| 62 |
protected: |
| 63 |
/** |
| 64 |
* Function which receives events from the global event filter. |
| 65 |
*/ |
| 66 |
bool eventFilter(QObject *watched, QEvent *event); |
| 67 |
|
| 68 |
void dump(); |
| 69 |
|
| 70 |
private: |
| 71 |
/** |
| 72 |
* List of registered target widgets which descend from a given |
| 73 |
* ancestor. |
| 74 |
* |
| 75 |
* Note that the members of the list should be non-redundant; this |
| 76 |
* invariant is checked in debug builds. Semantically, the value is |
| 77 |
* therefore a set, however we use QList rather than QSet for |
| 78 |
* efficiency of iteration. |
| 79 |
*/ |
| 80 |
typedef QList<DsaVideoOutput *> TargetList; |
| 81 |
|
| 82 |
/** |
| 83 |
* Map from widget on which the move event occurs, to widgets which |
| 84 |
* descend from it and therefore need to be notified. |
| 85 |
*/ |
| 86 |
typedef QHash<QObject *, TargetList> Hash; |
| 87 |
Hash m_hash; |
| 88 |
|
| 89 |
}; |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
QT_END_NAMESPACE |
| 94 |
|
| 95 |
#endif // !PHONON_MMF_ANCESTORMOVEMONITOR_H |