You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.4 KiB
63 lines
2.4 KiB
#include <QObject>
|
|
#include <QDebug>
|
|
|
|
#include "models/ChatMessage.h"
|
|
|
|
ChatMessage::ChatMessage(
|
|
const int event_id, const QString &service, const QString &group_uid,
|
|
const QString &local_uid, const QString &remote_uid, const QString &remote_name,
|
|
const QString &remote_ebook_uid, const QString &text, const QString &icon_name,
|
|
const int timestamp, const int count, const QString &group_title,
|
|
const QString &event_type, bool outgoing, const int flags) :
|
|
m_event_id(event_id),
|
|
m_service(service),
|
|
m_group_uid(group_uid),
|
|
m_local_uid(local_uid),
|
|
m_remote_uid(remote_uid),
|
|
m_remote_name(remote_name),
|
|
m_remote_ebook_uid(remote_ebook_uid),
|
|
m_text(text),
|
|
m_icon_name(icon_name),
|
|
m_count(count),
|
|
m_group_title(group_title),
|
|
m_event_type(event_type),
|
|
m_outgoing(outgoing),
|
|
m_flags(flags) {
|
|
m_date = QDateTime::fromTime_t(timestamp);
|
|
m_text = m_text.trimmed();
|
|
m_cid = QString("%1%2").arg(QString::number(outgoing), remote_uid);
|
|
}
|
|
|
|
QString ChatMessage::service() const { return m_service; }
|
|
int ChatMessage::event_id() const { return m_event_id; }
|
|
QString ChatMessage::group_uid() const { return m_group_uid; }
|
|
QString ChatMessage::local_uid() const { return m_local_uid; }
|
|
QString ChatMessage::remote_uid() const { return m_remote_uid; }
|
|
QString ChatMessage::remote_name() const { return m_remote_name; }
|
|
QString ChatMessage::remote_ebook_uid() const { return m_remote_ebook_uid; }
|
|
QString ChatMessage::text() const { return m_text; }
|
|
QString ChatMessage::icon_name() const { return m_icon_name; }
|
|
int ChatMessage::count() const { return m_count; }
|
|
QString ChatMessage::group_title() const { return m_group_title; }
|
|
QString ChatMessage::event_type() const { return m_event_type; }
|
|
bool ChatMessage::outgoing() const { return m_outgoing; }
|
|
int ChatMessage::flags() const { return m_flags; }
|
|
QString ChatMessage::cid() const { return m_cid; }
|
|
QDateTime ChatMessage::date() const { return m_date; }
|
|
QString ChatMessage::hourstr() const { return m_date.toString("hh:mm"); }
|
|
QString ChatMessage::datestr() const { return m_date.toString("dd/MM/yyyy"); }
|
|
bool ChatMessage::isHead() const {
|
|
if(previous == nullptr) return true;
|
|
if(m_text == "got in") {
|
|
int wegewg = 1;
|
|
}
|
|
if(previous->cid() == m_cid) return false;
|
|
return true;
|
|
}
|
|
bool ChatMessage::isLast() const {
|
|
if(previous == nullptr || next == nullptr) return false;
|
|
if(previous->cid() == m_cid && next->cid() != m_cid) {
|
|
return true;
|
|
}
|
|
return false;
|
|
} |