1 // -*- Mode: C++ -*-
2 #ifndef DISPLAYTEXT_H
3 #define DISPLAYTEXT_H
4 
5 #include <QTextEdit>
6 #include <QFont>
7 #include <QHash>
8 #include <QPair>
9 #include <QString>
10 
11 class QAction;
12 class Configuration;
13 class LogBook;
14 class DecodedText;
15 
16 class DisplayText
17   : public QTextEdit
18 {
19   Q_OBJECT
20 public:
21   explicit DisplayText(QWidget *parent = nullptr);
22   void set_configuration (Configuration const * configuration, bool high_volume = false)
23   {
24     disconnect (vertical_scroll_connection_);
25     m_config = configuration;
26     high_volume_ = high_volume;
27   }
28   void setContentFont (QFont const&);
29   void insertLineSpacer(QString const&);
30   void displayDecodedText(DecodedText const& decodedText, QString const& myCall, QString const& mode,
31                           bool displayDXCCEntity, LogBook const& logBook,
32                           QString const& currentBand=QString {}, bool ppfx=false, bool bCQonly=false,
33                           bool haveFSpread = false, float fSpread = 0., bool incl73=false, bool colourAll=false, QString distance = "", QString state = "");
34   void displayTransmittedText(QString text, QString modeTx, qint32 txFreq, bool bFastMode, double TRperiod);
35   void displayQSY(QString text);
36   void displayFoxToBeCalled(QString t, QColor bg = QColor {}, QColor fg = QColor {});
37   void new_period ();
CQPriority()38   QString CQPriority(){return m_CQPriority;};
39 
40   Q_SIGNAL void selectCallsign (Qt::KeyboardModifiers);
41   // Z
42   Q_SIGNAL void leftClick (Qt::KeyboardModifiers);
43 void log(QString s);
44   Q_SIGNAL void erased ();
45 
46   Q_SLOT void appendText (QString const& text, QColor bg = QColor {}, QColor fg = QColor {}
47                           , QString const& call1 = QString {}, QString const& call2 = QString {});
48   Q_SLOT void erase ();
49   Q_SLOT void highlight_callsign (QString const& callsign, QColor const& bg, QColor const& fg, bool last_period_only);
50 
51 private:
52   QString leftJustifyAppendage (QString message, QString const& appendage) const;
53   void mouseDoubleClickEvent (QMouseEvent *) override;
54   // Z
55   void mousePressEvent(QMouseEvent *) override;
56 
57   void extend_vertical_scrollbar (int min, int max);
58 
59   Configuration const * m_config;
60   bool m_bPrincipalPrefix;
61   QString m_CQPriority;
62   QString appendWorkedB4(QString message, QString callsign
63                          , QString const& grid, QColor * bg, QColor * fg
64                          , LogBook const& logBook, QString const& currentBand
65                          , QString const& currentMode, QString extra);
66   QFont char_font_;
67   QAction * erase_action_;
68   QHash<QString, QPair<QColor, QColor>> highlighted_calls_;
69   bool high_volume_;
70   QMetaObject::Connection vertical_scroll_connection_;
71   int modified_vertical_scrollbar_max_;
72 };
73 
74 #endif // DISPLAYTEXT_H
75