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,
25 #include "../common.h"
26 #include "listcommon.h"
32 qDebug() << __PRETTY_FUNCTION__;
34 setSize(QSize(ITEM_WIDTH, ITEM_MIN_HEIGHT));
37 QString ListItem::name() const
39 qDebug() << __PRETTY_FUNCTION__;
41 return data(NAME_DISPLAY_INDEX).toString();
44 void ListItem::setImage(const QPixmap &image)
46 qDebug() << __PRETTY_FUNCTION__;
48 setData(ITEM_HAS_IMAGE_INDEX, true);
49 setData(AVATAR_IMAGE_INDEX, image);
53 void ListItem::setName(const QString &name)
55 qDebug() << __PRETTY_FUNCTION__;
57 setData(NAME_DISPLAY_INDEX, name);
60 void ListItem::setSize(const QSize &size)
62 qDebug() << __PRETTY_FUNCTION__;
64 setData(ITEM_SIZE_HINT_INDEX, size);
67 QString ListItem::shortenText(const QString &text, int textWidth, TextSize textSize)
69 qDebug() << __PRETTY_FUNCTION__;
71 QPixmap p = QPixmap(ICON_WIDTH, ICON_HEIGHT);
74 if (textSize == ListItem::TEXT_SIZE_NORMAL)
75 painter.setFont(NOKIA_FONT_NORMAL);
77 painter.setFont(NOKIA_FONT_SMALL);
79 QFontMetrics textMetrics = painter.fontMetrics();
81 QString shortenedText = text;
83 int index = shortenedText.indexOf('\n');
86 shortenedText.truncate(index);
87 shortenedText.append("...");
90 return textMetrics.elidedText(shortenedText, Qt::ElideRight, textWidth);