2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Jussi Laitinen - jussi.laitinen@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
26 #include "friendlistitem.h"
28 ListView::ListView(QWidget *parent)
29 : QListWidget(parent),
32 qDebug() << __PRETTY_FUNCTION__;
34 connect(this, SIGNAL(itemClicked(QListWidgetItem*)),
35 this, SLOT(listItemClicked(QListWidgetItem*)));
38 void ListView::addListItem(const QString &key, ListItem *item)
40 qDebug() << __PRETTY_FUNCTION__;
42 if (!m_listItems.contains(key)) {
44 m_listItems.insert(key, item);
48 void ListView::addListItemToView(ListItem *item)
50 qDebug() << __PRETTY_FUNCTION__;
55 void ListView::clearList()
57 qDebug() << __PRETTY_FUNCTION__;
63 void ListView::clearUnused(const QStringList &userIDs)
65 qDebug() << __PRETTY_FUNCTION__;
67 foreach (QString key, m_listItems.keys()) {
68 if (!userIDs.contains(key)) {
69 ListItem *item = m_listItems.take(key);
78 void ListView::clearFilter()
80 qDebug() << __PRETTY_FUNCTION__;
83 previousItem->setSelected(false);
85 foreach (ListItem *item, m_listItems)
86 setItemHidden(item, false);
89 bool ListView::contains(const QString &userID)
91 qDebug() << __PRETTY_FUNCTION__;
93 return m_listItems.contains(userID);
96 void ListView::filter(const QList<QString> &userIDs)
98 qDebug() << __PRETTY_FUNCTION__;
100 foreach (ListItem *item, m_listItems) {
101 if (userIDs.contains(item->id()))
102 setItemHidden(item, false);
104 setItemHidden(item, true);
108 ListItem *ListView::takeListItemFromView(const QString &userID)
110 qDebug() << __PRETTY_FUNCTION__;
112 ListItem *item = listItem(userID);
117 void ListView::listItemClicked(QListWidgetItem *item)
119 qDebug() << __PRETTY_FUNCTION__;
121 ListItem *currentItem = static_cast<ListItem*>(item);
125 if (previousItem == currentItem) {
126 bool selected = currentItem->toggleSelection();
129 emit listItemClicked(currentItem->coordinates());
133 previousItem->setSelected(false);
135 currentItem->setSelected(true);
136 emit listItemClicked(currentItem->coordinates());
139 previousItem = currentItem;
143 ListItem *ListView::listItem(const QString &userID)
145 qDebug() << __PRETTY_FUNCTION__;
147 return static_cast<ListItem*>(m_listItems.value(userID));