aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/list_item.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/list_item.cpp b/src/list_item.cpp
index 020ccde..b235d2b 100644
--- a/src/list_item.cpp
+++ b/src/list_item.cpp
@@ -1,21 +1,31 @@
#include "list_item.h"
+#include "src/types.h"
-QIcon* choose_icon(StatusType status_type) {
+#define ICON_PATH_PREFIX "res/icons"
+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;
+ case StatusType::PUBLIC:
+ static QIcon public_icon(ICON_PATH_PREFIX"/globe.png"); return public_icon;
+ case StatusType::UNLISTED:
+ static QIcon unlisted_icon(ICON_PATH_PREFIX"/unlisted.png"); return unlisted_icon;
+ case StatusType::PRIVATE:
+ static QIcon private_icon(ICON_PATH_PREFIX"/padlock-locked.png"); return private_icon;
+ case StatusType::DIRECT:
+ static QIcon direct_icon(ICON_PATH_PREFIX"/letter.png"); return direct_icon;
+ case StatusType::REBLOG:
+ static QIcon reblog_icon(ICON_PATH_PREFIX"/repeat.png"); return reblog_icon;
+ case StatusType::UNKNOWN:
+ static QIcon unknown_icon(ICON_PATH_PREFIX"/question.png"); return unknown_icon;
}
}
+#undef ICON_PATH_PREFIX
StatusListItem::StatusListItem(const QString &text, StatusType status_type, bool has_attachement, Archive* data_archive, QListWidget *parent, int index) :
status_index(index), has_attachement(has_attachement), status_type(status_type), data_archive(data_archive)
{
setText(text);
- setIcon(*choose_icon(status_type));
+ setIcon(choose_icon(status_type));
parent->addItem(this);
#ifndef NDEBUG
QString tool_tip;