blob: 7ecbe5759f6610bdd960e0ad07868b2f1769cbfd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include "list_item.h"
#include "types.h"
QIcon* choose_icon(StatusType status_type) {
// via the use of `static' in the following switch block, the idea is to only initialize each QIcon type once in the program's lifetime.
switch (status_type) {
// TODO: only null icon for the moment
default:
static QIcon* icon = new QIcon();
return icon;
}
}
ListItem::ListItem(const QString &text, StatusType status_type, bool has_attachement, QListWidget *parent, int index) :
status_index(index), has_attachement(has_attachement)
{
setText(text);
setIcon(*choose_icon(status_type));
parent->addItem(this);
#ifndef NDEBUG
QString tool_tip;
switch (status_type) {
case PUBLIC: tool_tip = "Public"; break;
case UNLISTED: tool_tip = "Unlisted"; break;
case PRIVATE: tool_tip = "Private"; break;
case DIRECT: tool_tip = "Direct"; break;
case UNKNOWN: tool_tip = "Unknown"; break;
case REBLOG: tool_tip = "Reblog"; break;
}
setToolTip(tool_tip);
#endif
}
int ListItem::get_status_index() {
return status_index;
}
|