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 <QListWidgetItem>
28 * @brief Base class for list items.
30 * Stores item's name and image and includes method to shorten texts.
32 * @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
34 class ListItem : public QListWidgetItem
41 ListItem(QListWidget *parent = 0, int type = Type);
44 * @brief Defines text size.
46 enum TextSize{TEXT_SIZE_NORMAL, TEXT_SIZE_SMALL};
48 /******************************************************************************
49 * MEMBER FUNCTIONS AND SLOTS
50 ******************************************************************************/
53 * @brief Sets item's image.
55 * @param image QPixmap
57 void setImage(const QPixmap &image);
60 * @brief Sets item's title.
62 * @param name item's title
64 void setTitle(const QString &name);
67 * @brief Sets item selected.
69 * @param selected true if selected, false otherwise
71 virtual void setSelected(bool selected) = 0;
74 * @brief Sets item size.
76 * @param size item size
78 void setSize(const QSize &size);
81 * @brief Shortens text defined by text width.
83 * @param text text to be shortened
84 * @param textWidth the width the text can use
85 * @param textSize which text size to use
86 * @return shortened text
88 QString shortenText(const QString &text, int textWidth, TextSize textSize);
91 * @brief Returns item's title.
93 * @return item's title
95 QString title() const;
98 * @brief Toggles selection.
100 * @return true if selection was toggled, false otherwise
102 virtual bool toggleSelection() = 0;
104 /*******************************************************************************
106 ******************************************************************************/
108 QPixmap m_image; ///< Item's image
109 QString m_name; ///< Item's name