Libksieve

selectheadertypecombobox.h
1 /*
2  Copyright (C) 2013-2020 Laurent Montel <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 #ifndef SELECTHEADERTYPECOMBOBOX_H
20 #define SELECTHEADERTYPECOMBOBOX_H
21 
22 #include <QComboBox>
23 #include <QDialog>
24 
25 #include <QListWidget>
26 
27 class QLineEdit;
28 class QPushButton;
29 namespace KSieveUi {
30 class SelectHeadersWidget : public QListWidget
31 {
32  Q_OBJECT
33 public:
34  explicit SelectHeadersWidget(QWidget *parent = nullptr);
35  ~SelectHeadersWidget();
36 
37  Q_REQUIRED_RESULT QString headers() const;
38  void setListHeaders(const QMap<QString, QString> &lst, const QStringList &selectedHeaders);
39  void addNewHeader(const QString &header);
40 private:
41  enum HeaderEnum {
42  HeaderId = Qt::UserRole + 1
43  };
44 
45  void init();
46 };
47 
48 class SelectHeadersDialog : public QDialog
49 {
50  Q_OBJECT
51 public:
52  explicit SelectHeadersDialog(QWidget *parent = nullptr);
53  ~SelectHeadersDialog();
54 
55  Q_REQUIRED_RESULT QString headers() const;
56  void setListHeaders(const QMap<QString, QString> &lst, const QStringList &selectedHeaders);
57 
58 private:
59  void slotNewHeaderTextChanged(const QString &text);
60  void slotAddNewHeader();
61  void readConfig();
62  void writeConfig();
63  SelectHeadersWidget *mListWidget = nullptr;
64  QLineEdit *mNewHeader = nullptr;
65  QPushButton *mAddNewHeader = nullptr;
66 };
67 
68 class SelectHeaderTypeComboBox : public QComboBox
69 {
70  Q_OBJECT
71 public:
72  explicit SelectHeaderTypeComboBox(bool onlyEnvelopType = false, QWidget *parent = nullptr);
73  ~SelectHeaderTypeComboBox();
74 
75  Q_REQUIRED_RESULT QString code() const;
76  void setCode(const QString &code);
77 
78 Q_SIGNALS:
79  void valueChanged();
80 
81 private Q_SLOTS:
82  void slotSelectItem(const QString &str);
83 
84 private:
85  void initialize(bool onlyEnvelopType);
86  void changeReadOnlyStatus();
87  void headerMap(bool onlyEnvelopType);
88  QMap<QString, QString> mHeaderMap;
89  QString mCode;
90 };
91 }
92 
93 #endif // SELECTHEADERTYPECOMBOBOX_H
KCRASH_EXPORT void initialize()
Q_OBJECTQ_OBJECT
QCA_EXPORT void init()
void readConfig()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jun 5 2020 23:09:19 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.