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

#ifndef PROFILE_DIALOG_H
#define PROFILE_DIALOG_H

#include "config.h"

#include <ui/qt/geometry_state_dialog.h>
#include <ui/qt/models/profile_model.h>
#include <ui/qt/widgets/profile_tree_view.h>

#include <QPushButton>
#include <QTreeWidgetItem>

namespace Ui {
class ProfileDialog;
}

class ProfileDialog : public GeometryStateDialog
{
    Q_OBJECT

public:
    enum ProfileAction {
        ShowProfiles, NewProfile, ImportZipProfile, ImportDirProfile,
        ExportSingleProfile, ExportAllProfiles, EditCurrentProfile, DeleteCurrentProfile
    };

    explicit ProfileDialog(QWidget *parent = Q_NULLPTR);
    ~ProfileDialog();
    int execAction(ProfileAction profile_action);

    /**
     * @brief Select the profile with the given name.
     *
     * If the profile name is empty, the currently selected profile will be choosen instead.
     * If the choosen profile is invalid, the first row will be choosen.
     *
     * @param profile the name of the profile to be selected
     */
    void selectProfile(QString profile = QString());

protected:
    virtual void keyPressEvent(QKeyEvent *event);

private:
    Ui::ProfileDialog *pd_ui_;
    QPushButton *ok_button_;
    QPushButton *import_button_;
#ifdef HAVE_MINIZIP
    QPushButton *export_button_;
    QAction *export_selected_entry_;
#endif
    ProfileModel *model_;
    ProfileSortModel *sort_model_;

    void updateWidgets();
    void resetTreeView();

    QString lastOpenDir();
    void storeLastDir(QString dir);
    void finishImport(QFileInfo fi, int count, int skipped, QStringList import);

private slots:
    void currentItemChanged(const QModelIndex & c = QModelIndex(), const QModelIndex & p = QModelIndex());
#ifdef HAVE_MINIZIP
    void exportProfiles(bool exportAllPersonalProfiles = false);
    void importFromZip();
#endif
    void importFromDirectory();

    void on_newToolButton_clicked();
    void on_deleteToolButton_clicked();
    void on_copyToolButton_clicked();
    void on_buttonBox_accepted();
    void on_buttonBox_rejected();
    void on_buttonBox_helpRequested();
    void dataChanged(const QModelIndex &);

    void filterChanged(const QString &);

    void selectionChanged();
    QModelIndexList selectedProfiles();

    // QWidget interface

};

#endif // PROFILE_DIALOG_H