qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
chatmessage.h
Go to the documentation of this file.
1 /*
2  Copyright © 2014-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 "chatline.h"
23 #include "src/core/toxfile.h"
25 
26 #include <QDateTime>
27 
28 class CoreFile;
29 class QGraphicsScene;
30 
31 class ChatMessage : public ChatLine
32 {
33 public:
34  using Ptr = std::shared_ptr<ChatMessage>;
35 
37  {
41  };
42 
44  {
48  };
49 
50  ChatMessage();
51  ~ChatMessage();
52  ChatMessage(const ChatMessage&) = default;
53  ChatMessage& operator=(const ChatMessage&) = default;
54  ChatMessage(ChatMessage&&) = default;
55 
56  static ChatMessage::Ptr createChatMessage(const QString& sender, const QString& rawMessage,
57  MessageType type, bool isMe, MessageState state,
58  const QDateTime& date, bool colorizeName = false);
59  static ChatMessage::Ptr createChatInfoMessage(const QString& rawMessage, SystemMessageType type,
60  const QDateTime& date);
61  static ChatMessage::Ptr createFileTransferMessage(const QString& sender, CoreFile& coreFile,
62  ToxFile file, bool isMe, const QDateTime& date);
65 
66  void markAsDelivered(const QDateTime& time);
67  void markAsBroken();
68  QString toString() const;
69  bool isAction() const;
70  void setAsAction();
71  void hideSender();
72  void hideDate();
73 
74 protected:
75  static QString detectQuotes(const QString& str, MessageType type);
76  static QString wrapDiv(const QString& str, const QString& div);
77 
78 private:
79  bool action = false;
80 };
history.h
toxfile.h
ChatMessage::~ChatMessage
~ChatMessage()
ChatMessage::hideSender
void hideSender()
Definition: chatmessage.cpp:261
SystemMessageType
SystemMessageType
Definition: systemmessage.h:28
ChatMessage::ERROR
@ ERROR
Definition: chatmessage.h:39
HistMessageContentType::file
@ file
ChatMessage::TYPING
@ TYPING
Definition: chatmessage.h:40
ChatMessage::toString
QString toString() const
Definition: chatmessage.cpp:242
ChatMessage::Ptr
std::shared_ptr< ChatMessage > Ptr
Definition: chatmessage.h:34
ChatMessage::action
bool action
Definition: chatmessage.h:79
ChatMessage::ChatMessage
ChatMessage()
Definition: chatmessage.cpp:44
ChatLine
Definition: chatline.h:65
ChatMessage::MessageType
MessageType
Definition: chatmessage.h:43
ChatMessage::ALERT
@ ALERT
Definition: chatmessage.h:47
chatline.h
ChatMessage::markAsBroken
void markAsBroken()
Definition: chatmessage.cpp:237
ChatMessage::NORMAL
@ NORMAL
Definition: chatmessage.h:45
ChatMessage::createFileTransferMessage
static ChatMessage::Ptr createFileTransferMessage(const QString &sender, CoreFile &coreFile, ToxFile file, bool isMe, const QDateTime &date)
Definition: chatmessage.cpp:166
ChatMessage::ACTION
@ ACTION
Definition: chatmessage.h:46
ChatMessage::setAsAction
void setAsAction()
Definition: chatmessage.cpp:256
ChatMessage::isAction
bool isAction() const
Definition: chatmessage.cpp:251
ChatMessage::markAsDelivered
void markAsDelivered(const QDateTime &time)
Definition: chatmessage.cpp:229
ChatMessage::INFO
@ INFO
Definition: chatmessage.h:38
ChatMessage::detectQuotes
static QString detectQuotes(const QString &str, MessageType type)
Definition: chatmessage.cpp:275
MessageState
MessageState
Definition: history.h:128
ChatMessage::createBusyNotification
static ChatMessage::Ptr createBusyNotification()
Create message placeholder while chatform restructures text.
Definition: chatmessage.cpp:216
ChatMessage::SystemMessageType
SystemMessageType
Definition: chatmessage.h:36
ChatMessage::createTypingNotification
static ChatMessage::Ptr createTypingNotification()
Definition: chatmessage.cpp:187
ChatMessage
Definition: chatmessage.h:31
ChatMessage::wrapDiv
static QString wrapDiv(const QString &str, const QString &div)
Definition: chatmessage.cpp:301
ChatMessage::hideDate
void hideDate()
Definition: chatmessage.cpp:268
ToxFile
Definition: toxfile.h:32
ChatMessage::operator=
ChatMessage & operator=(const ChatMessage &)=default
CoreFile
Manages the file transfer service of toxcore.
Definition: corefile.h:46
ChatLine::Ptr
std::shared_ptr< ChatLine > Ptr
Definition: chatline.h:68
ChatMessage::createChatMessage
static ChatMessage::Ptr createChatMessage(const QString &sender, const QString &rawMessage, MessageType type, bool isMe, MessageState state, const QDateTime &date, bool colorizeName=false)
Definition: chatmessage.cpp:50
ChatMessage::createChatInfoMessage
static ChatMessage::Ptr createChatInfoMessage(const QString &rawMessage, SystemMessageType type, const QDateTime &date)
Definition: chatmessage.cpp:135