qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
chatlogitem.h
Go to the documentation of this file.
1 /*
2  Copyright © 2019 by The qTox Project Contributors
3 
4  This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6  qTox is libre software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  qTox is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with qTox. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include "src/core/toxfile.h"
23 #include "src/core/toxpk.h"
24 #include "src/model/message.h"
27 
28 #include <memory>
29 
31 {
34 };
35 
37 {
38  QDateTime timestamp;
40 };
41 
43 {
44 private:
45  using ContentPtr = std::unique_ptr<void, void (*)(void*)>;
46 
47 public:
48  enum class ContentType
49  {
50  message,
53  };
54 
56  ChatLogItem(ToxPk sender, const QString& displayName, ChatLogMessage message);
57  ChatLogItem(SystemMessage message);
58  const ToxPk& getSender() const;
61  const ChatLogFile& getContentAsFile() const;
63  const ChatLogMessage& getContentAsMessage() const;
66  QDateTime getTimestamp() const;
67  void setDisplayName(QString name);
68  const QString& getDisplayName() const;
69 
70 private:
71  ChatLogItem(ToxPk sender, const QString &displayName_, ContentType contentType, ContentPtr content);
72 
74  QString displayName;
76 
78 };
ChatLogItem::getContentAsFile
ChatLogFile & getContentAsFile()
Definition: chatlogitem.cpp:75
systemmessage.h
ChatLogItem::getTimestamp
QDateTime getTimestamp() const
Definition: chatlogitem.cpp:112
ChatLogItem
Definition: chatlogitem.h:42
history.h
toxfile.h
ChatLogItem::setDisplayName
void setDisplayName(QString name)
Definition: chatlogitem.cpp:133
ChatLogItem::getSender
const ToxPk & getSender() const
Definition: chatlogitem.cpp:65
ChatLogItem::ContentType
ContentType
Definition: chatlogitem.h:48
ChatLogItem::ContentType::message
@ message
HistMessageContentType::file
@ file
SystemMessage
Definition: systemmessage.h:47
ChatLogFile::timestamp
QDateTime timestamp
Definition: chatlogitem.h:38
toxpk.h
ChatLogItem::sender
ToxPk sender
Definition: chatlogitem.h:73
ChatLogItem::getContentType
ContentType getContentType() const
Definition: chatlogitem.cpp:70
ChatLogItem::contentType
ContentType contentType
Definition: chatlogitem.h:75
ChatLogItem::ChatLogItem
ChatLogItem(ToxPk sender, const QString &displayName, ChatLogFile file)
Definition: chatlogitem.cpp:41
message.h
ToxPk
This class represents a Tox Public Key, which is a part of Tox ID.
Definition: toxpk.h:26
ChatLogMessage
Definition: chatlogitem.h:30
ChatLogItem::displayName
QString displayName
Definition: chatlogitem.h:74
ChatLogItem::content
ContentPtr content
Definition: chatlogitem.h:77
ChatLogItem::getDisplayName
const QString & getDisplayName() const
Definition: chatlogitem.cpp:138
ChatLogItem::getContentAsMessage
ChatLogMessage & getContentAsMessage()
Definition: chatlogitem.cpp:87
MessageState
MessageState
Definition: history.h:128
ChatLogFile::file
ToxFile file
Definition: chatlogitem.h:39
ChatLogMessage::message
Message message
Definition: chatlogitem.h:33
ChatLogItem::ContentType::systemMessage
@ systemMessage
ChatLogItem::getContentAsSystemMessage
SystemMessage & getContentAsSystemMessage()
Definition: chatlogitem.cpp:99
ChatLogItem::ContentPtr
std::unique_ptr< void, void(*)(void *)> ContentPtr
Definition: chatlogitem.h:45
ToxFile
Definition: toxfile.h:32
ChatLogMessage::state
MessageState state
Definition: chatlogitem.h:32
ChatLogItem::ContentType::fileTransfer
@ fileTransfer
Message
Definition: message.h:52
ChatLogFile
Definition: chatlogitem.h:36