aboutsummaryrefslogtreecommitdiff
path: root/src/chatlogpiece.cpp
diff options
context:
space:
mode:
authorTrickyLeifa <date.epoch@gmail.com>2024-05-16 03:09:21 +0200
committerTrickyLeifa <date.epoch@gmail.com>2024-05-16 03:09:21 +0200
commit39e4354b1dae5d8487ea5b84be9f304b1950a61a (patch)
tree734c99d3ef1a8e69007dd870a8b6763deca5ffce /src/chatlogpiece.cpp
parenta0cee58c048772b2dcfe3992f60728d5a6f7d786 (diff)
Reimplemented favorite server widget, ...
* Reworked favorite server widget * Renamed `server_type` to `ServerInfo` * Renamed `connection_type` to `ServerConnectionType` * Refactored `AOCharButton` * Reimplemented `AOButton` * Partially reimplemented `AOEmoteButton` * Refactored `AOEvidenceButton`
Diffstat (limited to 'src/chatlogpiece.cpp')
-rw-r--r--src/chatlogpiece.cpp67
1 files changed, 20 insertions, 47 deletions
diff --git a/src/chatlogpiece.cpp b/src/chatlogpiece.cpp
index 662dc0d2..d8ef2949 100644
--- a/src/chatlogpiece.cpp
+++ b/src/chatlogpiece.cpp
@@ -1,60 +1,33 @@
#include "chatlogpiece.h"
-ChatLogPiece::ChatLogPiece()
-{
- name = tr("UNKNOWN");
- showname = tr("UNKNOWN");
- message = tr("UNKNOWN");
- color = 0;
- datetime = QDateTime::currentDateTimeUtc();
-}
-
-ChatLogPiece::ChatLogPiece(QString p_name, QString p_showname, QString p_message, QString p_action, int p_color, bool p_selfname)
-{
- name = p_name;
- showname = p_showname;
- message = p_message;
- action = p_action;
- color = p_color;
- selfname = p_selfname;
- datetime = QDateTime::currentDateTimeUtc();
-}
-
-ChatLogPiece::ChatLogPiece(QString p_name, QString p_showname, QString p_message, QString p_action, int p_color, bool p_selfname, QDateTime p_datetime)
-{
- name = p_name;
- showname = p_showname;
- message = p_message;
- action = p_action;
- color = p_color;
- selfname = p_selfname;
- datetime = p_datetime.toUTC();
-}
+#include <QStringBuilder>
-QString ChatLogPiece::get_datetime_as_string()
+QString ChatLogPiece::toString()
{
- return datetime.toString();
-}
+ auto maybe_unknown = [](QString str) -> QString {
+ if (str.isEmpty())
+ {
+ return tr("UNKNOWN");
+ }
+ else
+ {
+ return str;
+ }
+ };
-QString ChatLogPiece::get_full()
-{
- QString full = "[";
+ QString details = QString("[%1] %2").arg(timestamp.toString(), maybe_unknown(character_name));
- full.append(get_datetime_as_string());
- full.append("] ");
- full.append(showname);
- if (showname != name)
+ if (character_name != character)
{
- full.append(" (");
- full.append(name);
- full.append(")");
+ details += " (" % maybe_unknown(character) % ")";
}
+
if (!action.isEmpty())
{
- full.append(" " + action);
+ details += " " % action;
}
- full.append(": ");
- full.append(message);
- return full;
+ details += ": " % maybe_unknown(message);
+
+ return details;
}