summaryrefslogtreecommitdiffstats
path: root/ui/qt/widgets/follow_stream_text.h
blob: 0276c872213dd835bd14d0db67f95ee74fda7291 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/** @file
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef FOLLOW_STREAM_TEXT_H
#define FOLLOW_STREAM_TEXT_H

#include <QPlainTextEdit>

class FollowStreamText : public QPlainTextEdit
{
    Q_OBJECT
public:
    explicit FollowStreamText(QWidget *parent = 0);
    bool isTruncated() const { return truncated_; }
    void addText(QString text, bool is_from_server, uint32_t packet_num, bool colorize);
    void addDeltaTime(double delta);
    int currentPacket() const;

protected:
    void mouseMoveEvent(QMouseEvent *event);
    void mousePressEvent(QMouseEvent *event);
    void leaveEvent(QEvent *event);

signals:
    void mouseMovedToPacket(int);
    void mouseClickedOnPacket(int);

public slots:
    void clear();

private:
    int textPosToPacket(int text_pos) const;
    void addTruncated(int cur_pos);

    static const int        max_document_length_;
    bool                    truncated_;
    QMap<int, uint32_t>     text_pos_to_packet_;
    QColor                  metainfo_fg_;
};

#endif // FOLLOW_STREAM_TEXT_H