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__;
82 foreach (ListItem *item, m_listItems)
83 setItemHidden(item, false);
86 bool ListView::contains(const QString &userID)
88 qDebug() << __PRETTY_FUNCTION__;
90 return m_listItems.contains(userID);
93 void ListView::filter(const QList<QString> &userIDs)
95 qDebug() << __PRETTY_FUNCTION__;
97 foreach (ListItem *item, m_listItems) {
98 if (userIDs.contains(item->id()))
99 setItemHidden(item, false);
101 setItemHidden(item, true);
105 ListItem *ListView::takeListItemFromView(const QString &userID)
107 qDebug() << __PRETTY_FUNCTION__;
109 ListItem *item = listItem(userID);
114 void ListView::listItemClicked(QListWidgetItem *item)
116 qDebug() << __PRETTY_FUNCTION__;
118 ListItem *currentItem = static_cast<ListItem*>(item);
122 if (previousItem == currentItem) {
123 bool expanded = currentItem->toggleSelection();
126 emit listItemClicked(currentItem->coordinates());
130 previousItem->setSelected(false);
132 currentItem->setSelected(true);
133 emit listItemClicked(currentItem->coordinates());
136 previousItem = currentItem;
141 ListItem *ListView::listItem(const QString &userID)
143 qDebug() << __PRETTY_FUNCTION__;
145 return static_cast<ListItem*>(m_listItems.value(userID));