swift
textmessagetextedit.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_GUI_TEXTMESSAGETEXTEDIT_H
7 #define SWIFT_GUI_TEXTMESSAGETEXTEDIT_H
8 
9 #include <QObject>
10 #include <QString>
11 #include <QTextDocument>
12 #include <QTextEdit>
13 
14 #include "gui/swiftguiexport.h"
16 
17 class QAction;
18 class QPoint;
19 
20 namespace swift::misc::network
21 {
22  class CTextMessage;
23 }
24 namespace swift::gui
25 {
27  class SWIFT_GUI_EXPORT CTextMessageTextEdit : public QTextEdit
28  {
29  Q_OBJECT
30 
31  public:
33  CTextMessageTextEdit(QWidget *parent = nullptr);
34 
36  virtual ~CTextMessageTextEdit() override;
37 
39  void insertTextMessage(const swift::misc::network::CTextMessage &textMessage, int maxMessages = -1);
40 
43 
45  int count() const;
46 
48  void setStyleSheetForContent(const QString &styleSheet);
49 
51  void clear();
52 
54  void redrawHtml();
55 
57  void setLatestFirst(bool latestFirst) { m_latestFirst = latestFirst; }
58 
60  bool isLatestFirst() const { return m_latestFirst; }
61 
62  private:
64  void showContextMenuForTextEdit(const QPoint &pt);
65 
67  void keepLastNMessages();
68 
70  void setVisibleFields();
71 
73  static QString toHtml(const swift::misc::network::CTextMessageList &messages, bool withFrom, bool withTo);
74 
76  static QString toHtml(const swift::misc::network::CTextMessage &message, bool withFrom, bool withTo);
77 
79  void setWordWrap(bool wordWrap);
80 
82  QTextDocument m_textDocument;
83  int m_keepMaxMessages = -1;
84  bool m_latestFirst = false;
85  bool m_withSender = true;
86  bool m_withRecipient = false;
87  bool m_wordWrap = true;
88 
89  QAction *m_actionClearTextEdit = nullptr;
90  QAction *m_actionLast10 = nullptr;
91  QAction *m_actionLast25 = nullptr;
92  QAction *m_actionAll = nullptr;
93  QAction *m_actionWithSender = nullptr;
94  QAction *m_actionWithRecipient = nullptr;
95  QAction *m_actionWordWrap = nullptr;
96  };
97 } // namespace swift::gui
98 
99 #endif // SWIFT_GUI_TEXTMESSAGETEXTEDIT_H
Specialized text edit for displaying text messages.
void setLatestFirst(bool latestFirst)
Order latest first/latest last.
bool isLatestFirst() const
Lastest first.
const swift::misc::network::CTextMessageList & getDisplayedTextMessages() const
The displayed text messaged.
Value object encapsulating information of a text message.
Definition: textmessage.h:31
Value object encapsulating a list of text messages.
GUI related classes.
#define SWIFT_GUI_EXPORT
Export a class or function from the library.