Handler for friend and friend group items. More...
#include <frienditemshandler.h>
Signals | |
void | locationItemClicked (const QList< QString > &userIDs) |
Signal is emitted when location item is clicked. | |
Public Member Functions | |
FriendItemsHandler (MapScene *mapScene, QObject *parent=0) | |
Constructor. | |
Private Slots | |
void | friendListUpdated (QList< User * > &friendsList) |
Slot for upgrading friend items and groups. | |
void | refactorFriendItems (int zoomLevel) |
Re-factors all FriendLocationItem and FriendGroupItem items. | |
Private Member Functions | |
void | addFriendItem (User *friendData) |
Add new FriendLocationItem. | |
void | checkAllFriendsForCollidingFriends () |
Group colliding friends. | |
void | checkAllGroupsForCollidingFriends () |
Join friends to colliding group. | |
void | checkFriendForCollidingFriends (FriendLocationItem *item) |
Check single FriendLocationItem for colliding FriendLocationItem items. | |
void | checkGroupForCollidingFriends (FriendGroupItem *group) |
Check single FriendGroupItem for colliding FriendLocationItem. | |
void | checkGroupForCollidingGroups (FriendGroupItem *group) |
Check single FriendGroupItem for colliding FriendGroupItem items. | |
void | cleanOldFriendData (const QList< User * > &friendsList) |
clean old friend data from m_mapScene and m_friendItems | |
void | deleteFriendItem (FriendLocationItem *item) |
Delete FriendLocationItem. | |
void | dropFriendFromAllGroups (FriendLocationItem *item) |
Drop FriendLocationItem from all FriendGroupItem groups. | |
void | dropOutOfGroupFriends () |
Drop all FriendLocationItem items, which are out of FriendGroupItem boundaries, from all FriendGroupItem items. | |
void | mergeCollidingGroups () |
Merge all colliding groups. | |
void | updateFriendItem (FriendLocationItem *friendItem, User *friendData) |
Update FriendLocationItem data. | |
void | updateFriendItemList (const QList< User * > &friendsList) |
updates data member m_friendItems from given parameter | |
void | updateFriendLocationsAndImages (const QList< User * > &friendsList) |
updates data member m_friendItems values that differs from given parameter | |
Private Attributes | |
QLinkedList< FriendGroupItem * > | m_friendGroupItems |
All FriendGroupItem items. | |
QLinkedList< FriendLocationItem * > | m_friendItems |
List of friendLocationItems. | |
MapScene * | m_mapScene |
Pointer to MapScene. | |
int | m_zoomLevel |
Current view zoom level used for calculation of items bounding rect. |
Handler for friend and friend group items.
Handles all friend map items. Colliding items and groups are grouped. All items are owned by MapScene.
FriendItemsHandler::FriendItemsHandler | ( | MapScene * | mapScene, | |
QObject * | parent = 0 | |||
) |
Constructor.
mapScene | MapScene object | |
parent | Parent QObject |
void FriendItemsHandler::addFriendItem | ( | User * | friendData | ) | [private] |
Add new FriendLocationItem.
New FriendLocationItem is created, values are set and item is added to map. Item is also added to m_friendItems list.
friendData | Data for new friend |
void FriendItemsHandler::checkAllFriendsForCollidingFriends | ( | ) | [private] |
Group colliding friends.
Call checkFriendForCollidingFriends() for all visible FriendLocationItem items.
void FriendItemsHandler::checkAllGroupsForCollidingFriends | ( | ) | [private] |
Join friends to colliding group.
Call checkGroupForCollidingFriends() for all FriendGroupItem items.
void FriendItemsHandler::checkFriendForCollidingFriends | ( | FriendLocationItem * | item | ) | [private] |
Check single FriendLocationItem for colliding FriendLocationItem items.
Check FriendLocationItem against another visible FriendLocationItem items. If collision is found, then new FriendGroupItem is made and colliding FriendLocationItem items are joined to this new FriendGroupItem.
item | FriendLocationItem to be checked |
void FriendItemsHandler::checkGroupForCollidingFriends | ( | FriendGroupItem * | group | ) | [private] |
Check single FriendGroupItem for colliding FriendLocationItem.
Check FriendGroupItem against all visible FriendLocationItem items. Colliding FriendLocationItem items are joiden to given FriendGroupItem.
group | FriendGroupItem to be checked |
void FriendItemsHandler::checkGroupForCollidingGroups | ( | FriendGroupItem * | group | ) | [private] |
Check single FriendGroupItem for colliding FriendGroupItem items.
Colliding FriendGroupItem items are merged. Item given as parameter remains and colliding items are deleted after their friend items are merged to remaining group.
group | FriendGroupItem to be checked |
void FriendItemsHandler::cleanOldFriendData | ( | const QList< User * > & | friendsList | ) | [private] |
clean old friend data from m_mapScene and m_friendItems
friendsList | QList item of friend information |
void FriendItemsHandler::deleteFriendItem | ( | FriendLocationItem * | item | ) | [private] |
Delete FriendLocationItem.
Drops item from all groups, removes it from scene and deletes the item.
item | Item to be deleted |
void FriendItemsHandler::dropFriendFromAllGroups | ( | FriendLocationItem * | item | ) | [private] |
Drop FriendLocationItem from all FriendGroupItem groups.
item | Item to be dropped. |
void FriendItemsHandler::friendListUpdated | ( | QList< User * > & | friendsList | ) | [private, slot] |
Slot for upgrading friend items and groups.
Does add and/or remove FriendLocationItem items if there are new friends or old ones deleted in the given list. Remaining FriensLocationItems are updated.
friendsList | QList item of friend information |
void FriendItemsHandler::locationItemClicked | ( | const QList< QString > & | userIDs | ) | [signal] |
Signal is emitted when location item is clicked.
userIDs | list of friends user IDs in the group |
void FriendItemsHandler::mergeCollidingGroups | ( | ) | [private] |
Merge all colliding groups.
Calls checkGroupForCollidingGroups() for all FriendGroupItem items.
void FriendItemsHandler::refactorFriendItems | ( | int | zoomLevel | ) | [private, slot] |
Re-factors all FriendLocationItem and FriendGroupItem items.
Calls mergeCollidingGroups(), dropOutOfGroupFriends(), checkAllGroupsForCollidingFriends() and checkAllFriendsForCollidingFriends().
zoomLevel | Current view zoom level |
void FriendItemsHandler::updateFriendItem | ( | FriendLocationItem * | friendItem, | |
User * | friendData | |||
) | [private] |
Update FriendLocationItem data.
Position and image are updated.
friendItem | Item to be updated | |
friendData | New data for the item |
void FriendItemsHandler::updateFriendItemList | ( | const QList< User * > & | friendsList | ) | [private] |
updates data member m_friendItems from given parameter
friendsList | QList item of friend information |
void FriendItemsHandler::updateFriendLocationsAndImages | ( | const QList< User * > & | friendsList | ) | [private] |
updates data member m_friendItems values that differs from given parameter
friendsList | QList item of friend information |