Modified TagsDialog.
[situare] / tests / stubs / listitem.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Jussi Laitinen - jussi.laitinen@ixonos.com
6
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.
10
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.
15
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,
19    USA.
20 */
21
22 #ifndef LISTITEMSTUB_H
23 #define LISTITEMSTUB_H
24
25 #include "../../src/ui/personlistitem.h"
26 #include "../../src/coordinates/geocoordinate.h"
27 #include "stubbase.h"
28
29 class ListItemStub : public StubBase
30 {
31 public:
32     virtual void ListItemConstructor(QListWidget *parent = 0,
33                                      int type = QListWidgetItem::Type);
34     enum TextSize{TEXT_SIZE_NORMAL, TEXT_SIZE_SMALL};
35     virtual void setImage(const QPixmap &image);
36     virtual void setTitle(const QString &name);
37     virtual void setSize(const QSize &size);
38     virtual QString shortenText(const QString &text, int textWidth, ListItem::TextSize textSize);
39     virtual QString title();
40 };
41
42 void ListItemStub::ListItemConstructor(QListWidget *parent, int type)
43 {
44     Q_UNUSED(parent)
45     Q_UNUSED(type)
46 }
47
48 void ListItemStub::setImage(const QPixmap &image)
49 {
50     QList<ParameterBase *> params;
51     params.append(new Parameter<const QPixmap &>(image));
52     stubMethodEntered("setImage", params);
53 }
54
55 void ListItemStub::setTitle(const QString &name)
56 {
57     QList<ParameterBase *> params;
58     params.append(new Parameter<const QString &>(name));
59     stubMethodEntered("setTitle", params);
60 }
61
62 void ListItemStub::setSize(const QSize &size)
63 {
64     QList<ParameterBase *> params;
65     params.append(new Parameter<const QSize &>(size));
66     stubMethodEntered("setSize", params);
67 }
68
69 QString ListItemStub::shortenText(const QString &text, int textWidth, ListItem::TextSize textSize)
70 {
71     QList<ParameterBase *> params;
72     params.append(new Parameter<const QString &>(text));
73     params.append(new Parameter<int>(textWidth));
74     params.append(new Parameter<ListItem::TextSize>(textSize));
75     stubMethodEntered("shortenText", params);
76
77     return stubReturnValue<QString>("shortenText");
78 }
79
80 QString ListItemStub::title()
81 {
82     return stubReturnValue<QString>("title");
83 }
84
85 //Create a stub instance
86 ListItemStub defaultListItemStub;
87 ListItemStub *listItemStub = &defaultListItemStub;
88
89 ListItem::ListItem(QListWidget *parent, int type)
90     : QListWidgetItem(parent, type)
91 {
92     listItemStub->ListItemConstructor(parent, type);
93 }
94
95 void ListItem::setImage(const QPixmap &image)
96 {
97     listItemStub->setImage(image);
98 }
99
100 void ListItem::setTitle(const QString &name)
101 {
102     listItemStub->setTitle(name);
103 }
104
105 void ListItem::setSize(const QSize &size)
106 {
107     listItemStub->setSize(size);
108 }
109
110 QString ListItem::shortenText(const QString &text, int textWidth, ListItem::TextSize textSize)
111 {
112     return listItemStub->shortenText(text, textWidth, textSize);
113 }
114
115 QString ListItem::title()
116 {
117     return listItemStub->title();
118 }
119
120 #endif // LISTITEMSTUB_H
121