summaryrefslogtreecommitdiffstats
path: root/plugins/epan/pluginifdemo/ui/pluginifdemo_main.h
blob: e0bafaab27e3042a227b395e2ea5e65ac30f682e (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* pluginifdemo_main.h
 *
 * Author: Roland Knall <rknall@gmail.com>
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef PLUGINIFDEMO_MAIN_H_
#define PLUGINIFDEMO_MAIN_H_

#include <QWidget>
#include <QDialog>
#include <QAbstractButton>
#include <QListWidget>
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>

#include <epan/plugin_if.h>

namespace Ui {
class PluginIFDemo_Main;
}

class PluginIfType
{
public:
    PluginIfType(const QString &label, const ext_toolbar_item_t &itemType);

    QString label() const;
    ext_toolbar_item_t itemType() const;
private:
    QString m_label;
    ext_toolbar_item_t m_itemType;
};

class PluginIfTypeModel : public QAbstractListModel
{
    Q_OBJECT
public:
    PluginIfTypeModel(QObject * parent = 0);

    void addPluginIfType(const PluginIfType & pluginIfType);

    int rowCount(const QModelIndex & parent = QModelIndex()) const;
    QVariant data(const QModelIndex & idx, int role = Qt::DisplayRole) const;

private:
    QList<PluginIfType> m_pluginIfTypes;

};

class PluginIfTypeSortFilterProxyModel : public QSortFilterProxyModel
{
    Q_OBJECT
public:
    PluginIfTypeSortFilterProxyModel(QObject * parent = 0);

    bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;

    void setFilterElement(ext_toolbar_item_t filterType);

private:
    ext_toolbar_item_t m_filterType;
};

class PluginIFDemo_Main : public QDialog
{
    Q_OBJECT

public:
    explicit PluginIFDemo_Main(QWidget *parent = 0);
    ~PluginIFDemo_Main();

    void setToolbar(ext_toolbar_t * &toolbar);

private slots:
    void on_buttonBox_clicked(QAbstractButton *button);
    void on_btnSendButtonText_clicked();
    void on_btnSendText_clicked();
    void on_btnSendUpdateItem_clicked();
    void on_chkTestCheckbox_stateChanged(int newState);
    void on_tabInterfaceTypes_currentChanged(int newTab);
    void on_btnAddItem_clicked();
    void on_btnRemoveItem_clicked();
    void on_btnSendList_clicked();
    void on_cmbElements_currentTextChanged(const QString & newText);
    void on_lstItems_clicked(const QModelIndex &idx);
    void on_btnEnable_clicked();
    void on_btnDisable_clicked();

    void logChanged(QString message);
    void closeDialog();

private:
    Ui::PluginIFDemo_Main *ui;

    PluginIfTypeModel * sourceModel;
    PluginIfTypeSortFilterProxyModel * proxyModel;
    QStandardItemModel * listModel;
    QStandardItemModel * indexModel;

    ext_toolbar_t * _toolbar;
};


#endif /* PLUGINIFDEMO_MAIN_H_ */

/*
 * Editor modelines
 *
 * Local Variables:
 * c-basic-offset: 4
 * tab-width: 8
 * indent-tabs-mode: nil
 * End:
 *
 * ex: set shiftwidth=4 tabstop=8 expandtab:
 * :indentSize=4:tabSize=8:noTabs=true:
 */