515a535c920255c06e6c1f14c59576a178d177cb
[gd/wireshark/.git] / ui / qt / widgets / follow_stream_text.cpp
1 /* follow_stream_text.cpp
2  *
3  * Wireshark - Network traffic analyzer
4  * By Gerald Combs <gerald@wireshark.org>
5  * Copyright 1998 Gerald Combs
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later*/
8
9 #include <ui/qt/widgets/follow_stream_text.h>
10
11 #include <wireshark_application.h>
12
13 #include <QMouseEvent>
14 #include <QTextCursor>
15
16 // To do:
17 // - Draw text by hand similar to ByteViewText. This would let us add
18 //   extra information, e.g. a timestamp column and get rid of
19 //   max_document_length_ in FollowStreamDialog.
20
21 FollowStreamText::FollowStreamText(QWidget *parent) :
22     QPlainTextEdit(parent)
23 {
24     setMouseTracking(true);
25 //    setMaximumBlockCount(1);
26     QTextDocument *text_doc = document();
27     text_doc->setDefaultFont(wsApp->monospaceFont());
28 }
29
30 void FollowStreamText::mouseMoveEvent(QMouseEvent *event)
31 {
32     emit mouseMovedToTextCursorPosition(cursorForPosition(event->pos()).position());
33     QPlainTextEdit::mouseMoveEvent(event);
34 }
35
36 void FollowStreamText::mousePressEvent(QMouseEvent *event)
37 {
38     emit mouseClickedOnTextCursorPosition(cursorForPosition(event->pos()).position());
39     QPlainTextEdit::mousePressEvent(event);
40 }
41
42 void FollowStreamText::leaveEvent(QEvent *event)
43 {
44     emit mouseMovedToTextCursorPosition(-1);
45     QPlainTextEdit::leaveEvent(event);
46 }
47
48 /*
49  * Editor modelines
50  *
51  * Local Variables:
52  * c-basic-offset: 4
53  * tab-width: 8
54  * indent-tabs-mode: nil
55  * End:
56  *
57  * ex: set shiftwidth=4 tabstop=8 expandtab:
58  * :indentSize=4:tabSize=8:noTabs=true:
59  */