This class manages a map of <T>-QObject pairs. <T> is a template class. More...
#include <GCF3/MapToObject>
Public Member Functions | |
MapToObject () | |
MapToObject (const MapToObject &other) | |
MapToObject (const QMap< T, QObject * > &map) | |
~MapToObject () | |
void | setEventListener (MapToObjectEventListener *listener) |
MapToObjectEventListener * | eventListener () const |
MapToObject & | operator= (const MapToObject &other) |
void | insert (const T &value, QObject *object) |
void | remove (const T &value) |
QObject * | operator[] (const T &value) const |
int | count () const |
bool | isEmpty () const |
bool | contains (const T &value) const |
QObject * | value (const T &key) const |
QList< T > | keys () const |
QObjectList | values () const |
QMap< T, QObject * > | toMap () const |
const QMap< T, QObject * > & | map () const |
void | removeAll () |
void | deleteAll () |
Public Member Functions inherited from GCF::ObjectListEventListener | |
ObjectListEventListener () | |
virtual | ~ObjectListEventListener () |
Detailed Description
template<class T>
class GCF::MapToObject< T >
This class can be used as a replacement for QMap<T, QObject*>
, when you want Value versus valid pointers to QObject
to be stored in the map. This class automatically notifies and removes Value - invalid QObject
pairs, as and when the object pointers inside MapToObject
are deleted elsewhere in the application.
Three types of events can happen on GCF::MapToObject
- A
Value
-QObject
pointer pair got added to the map. - A
Value
-QObject
pointer - got removed from the map. - A
QObject
pointer in Value -QObject
pair's ,got deleted.
You can listen to this class by setting GCF::MapToObjectEventListener using setEventListener(MapToObjectEventListener *listener) method. When a new Value - QObject
pointer pair is inserted or removed from the MapToObject
, MapToObjectEventListener
will notify it.
If you want to have several listeners receive event notifications on an object map, then you can install a GCF::MapToObjectEventBroadcaster on the object map and register all event listeners with the broadcaster.
Constructor & Destructor Documentation
GCF::MapToObject< T >::MapToObject | ( | ) |
Default constructor.
GCF::MapToObject< T >::MapToObject | ( | const MapToObject< T > & | other | ) |
Copy constructor. MapToObject
does not copy the GCF::MapToObjectEventListener that is currently set on the other GCF::MapToObject.
- Parameters
-
other MapToObject from which value-objects pairs will be copied.
GCF::MapToObject< T >::MapToObject | ( | const QMap< T, QObject * > & | map | ) |
Copies the value-object pairs from QMap<T,QObject*>& map to this.
GCF::MapToObject< T >::~MapToObject | ( | ) |
Destructor.
Member Function Documentation
GCF::MapToObject< T >::setEventListener | ( | MapToObjectEventListener * | listener | ) |
Sets an event listener on the this. If there was a already an event listener set then it will be replaced with the new one.
- Parameters
-
listener the GCF::MapToObjectEventListener which needs to be set as event listener.
GCF::MapToObject< T >::eventListener | ( | ) | const |
- Returns
- currently set event listener on this.
GCF::MapToObject< T >::operator= | ( | const MapToObject< T > & | other | ) |
Overloaded equal to operator. It copies everything from GCF::MapToObject except the GCF::MapToObjectEventListener that is currently set on 'other' GCF::MapToObject.
- Parameters
-
other MapToObject from which value-objects pairs will be copied.
GCF::MapToObject< T >::insert | ( | const T & | value, |
QObject * | object | ||
) |
Inserts the Value - QObject
pointer pair into the map.
- Parameters
-
value template class value which needs to be inserted into the map object QObject
pointer which needs to be inserted into the map against value.
GCF::MapToObject< T >::remove | ( | const T & | value | ) |
Removes the Value - QObject
pointer pair from the map.
- Parameters
-
value template class value which needs to be removed from the map.
GCF::MapToObject< T >::operator[] | ( | const T & | value | ) | const |
Returns QObject
pointer for value existing in the map. You have to make sure that the value exists in the map before calling this function.
- Parameters
-
value template class value for which QObject
pointer needs to be returned from the map.
- Returns
QObject
pointer stored against value.
GCF::MapToObject< T >::count | ( | ) | const |
- Returns
- the map object count.
GCF::MapToObject< T >::isEmpty | ( | ) | const |
- Returns
- true if the map is empty otherwise false.
GCF::MapToObject< T >::contains | ( | const T & | value | ) | const |
- Returns
- true if the map contains the value otherwise false.
GCF::MapToObject< T >::value | ( | const T & | key | ) | const |
- Returns
QObject
pointer stored against template class value 'key' in the map.
GCF::MapToObject< T >::keys | ( | ) | const |
Returns keys of map. Since GCF::MapToObject stores Template class value versus QObject
pointer, keys() will return QList<T>
.
- Returns
QList<T>
of all template class values stored as keys.
GCF::MapToObject< T >::values | ( | ) | const |
Returns list of QObject
pointers stored in the map. Since GCF::MapToObject stores QObject
pointer versus Template class value, value() will return QList<T>
.
- Returns
QObjectList
ofQObject
pointers stored as values of map.
GCF::MapToObject< T >::toMap | ( | ) | const |
- Returns
- stored template class value -
QObject
pointer pairs asQMap<T,QObject*>
.
GCF::MapToObject< T >::map | ( | ) | const |
- Returns
- constant reference to template class value -
QObject
pointer map.
GCF::MapToObject< T >::removeAll | ( | ) |
Removes all template class value - QObject
pointer stored in this map.
GCF::MapToObject< T >::deleteAll | ( | ) |
Deletes all QObject
pointer stored in this map and removes the value stored in this map.