summaryrefslogtreecommitdiffstats
path: root/ui/qt/widgets/filter_expression_toolbar.h
blob: 80724a27f1d0cdd6b8cae1d3b33a91d2f024a4df (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
/** @file
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include <ui/qt/widgets/drag_drop_toolbar.h>

#include <glib.h>

#include <QMenu>

#ifndef FILTER_EXPRESSION_TOOLBAR_H
#define FILTER_EXPRESSION_TOOLBAR_H

class FilterExpressionToolBar : public DragDropToolBar
{
    Q_OBJECT
public:
    explicit FilterExpressionToolBar(QWidget * parent = Q_NULLPTR);

protected:
    virtual bool event(QEvent *event) override;
    virtual bool eventFilter(QObject *obj, QEvent *ev) override;

    virtual WiresharkMimeData * createMimeData(QString name, int position) override;

public slots:
    void filterExpressionsChanged();

signals:
    void filterSelected(QString, bool);
    void filterPreferences();
    void filterEdit(int uatIndex);

protected slots:
    void onCustomMenuHandler(const QPoint &pos);
    void onActionMoved(QAction * action, int oldPos, int newPos);
    void onFilterDropped(QString description, QString filter);

private slots:
    void removeFilter();
    void disableFilter();
    void editFilter();
    void filterClicked();
    void toolBarShowPreferences();

    void closeMenu(QAction *);

private:
    void updateStyleSheet();
    int uatRowIndexForFilter(QString label, QString expression);

    void customMenu(FilterExpressionToolBar * target, QAction * filterAction, const QPoint& pos);

    static bool filter_expression_add_action(const void *key, void *value, void *user_data);
    static QMenu * findParentMenu(const QStringList tree, void *fed_data, QMenu *parent = Q_NULLPTR);
};

#endif //FILTER_EXPRESSION_TOOLBAR_H