aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/packet_diagram.h
blob: 9b2373fdadd43bc31ce5fad98103887fe7af3d51 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/** @file
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef PACKET_DIAGRAM_H
#define PACKET_DIAGRAM_H

#include <config.h>

#include <epan/proto.h>

#include "cfile.h"

#include <ui/qt/utils/field_information.h>

#include <QGraphicsView>

class DiagramLayout;

class PacketDiagram : public QGraphicsView
{
    Q_OBJECT
public:
    PacketDiagram(QWidget *parent = nullptr);
    ~PacketDiagram();
    void setRootNode(proto_node *root_node);
    void clear();

signals:
    void fieldSelected(FieldInformation *);

public slots:
    void setCaptureFile(capture_file *cf);
    void setFont(const QFont &font);
    void selectedFieldChanged(FieldInformation *finfo);
    void selectedFrameChanged(QList<int> frames);

protected:
    virtual bool event(QEvent *event) override;
    virtual void contextMenuEvent(QContextMenuEvent *event) override;

private slots:
    void connectToMainWindow();
    void sceneSelectionChanged();

private:
    void resetScene(bool reset_root = true);
    void addDiagram(proto_node *tl_node);
    void setSelectedField(field_info *fi);
    QImage exportToImage();
#if defined(QT_SVG_LIB) && 0
    QByteArray exportToSvg();
#endif

    void showFieldsToggled(bool checked);
    void saveAsTriggered();
    void copyAsRasterTriggered();
#if defined(QT_SVG_LIB) && !defined(Q_OS_MAC) && 0
    void copyAsSvgTriggered();
#endif

    DiagramLayout *layout_;
    capture_file *cap_file_;
    proto_node *root_node_;
    field_info *selected_field_;
    int y_pos_;
};

#endif // PACKET_DIAGRAM_H