diff options
| author | Salanto <62221668+Salanto@users.noreply.github.com> | 2024-05-18 03:33:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-18 03:33:43 +0200 |
| commit | 51338e30e046f1a62c84049b34577f0f3b5db6e3 (patch) | |
| tree | 283c95f8f776ed852d03a816388695afd65c0f73 /src/chatlogpiece.cpp | |
| parent | 469e293a1885e49f1d5994d41ac7cfc9f4666952 (diff) | |
| parent | f9c7205210fb9f768f583065971ece09e6b5eb03 (diff) | |
Merge pull request #957 from AttorneyOnline/kaleidoscope
The Kaleidoscope - Hell, it's about time.
Diffstat (limited to 'src/chatlogpiece.cpp')
| -rw-r--r-- | src/chatlogpiece.cpp | 68 |
1 files changed, 22 insertions, 46 deletions
diff --git a/src/chatlogpiece.cpp b/src/chatlogpiece.cpp index 64ffefe8..d8ef2949 100644 --- a/src/chatlogpiece.cpp +++ b/src/chatlogpiece.cpp @@ -1,57 +1,33 @@ #include "chatlogpiece.h" -chatlogpiece::chatlogpiece() -{ - name = tr("UNKNOWN"); - showname = tr("UNKNOWN"); - message = tr("UNKNOWN"); - color = 0; - action = ""; - datetime = QDateTime::currentDateTimeUtc(); -} +#include <QStringBuilder> -chatlogpiece::chatlogpiece(QString p_name, QString p_showname, - QString p_message, QString p_action, int p_color, bool p_selfname) +QString ChatLogPiece::toString() { - name = p_name; - showname = p_showname; - message = p_message; - action = p_action; - color = p_color; - selfname = p_selfname; - datetime = QDateTime::currentDateTimeUtc(); -} + auto maybe_unknown = [](QString str) -> QString { + if (str.isEmpty()) + { + return tr("UNKNOWN"); + } + else + { + return str; + } + }; -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(); -} + QString details = QString("[%1] %2").arg(timestamp.toString(), maybe_unknown(character_name)); -QString chatlogpiece::get_full() -{ - QString full = "["; + if (character_name != character) + { + details += " (" % maybe_unknown(character) % ")"; + } - full.append(get_datetime_as_string()); - full.append("] "); - full.append(get_showname()); - if (get_showname() != get_name()) + if (!action.isEmpty()) { - full.append(" ("); - full.append(get_name()); - full.append(")"); + details += " " % action; } - if (!get_action().isEmpty()) - full.append(" " + get_action()); - full.append(": "); - full.append(get_message()); - return full; + details += ": " % maybe_unknown(message); + + return details; } |
