Pimcommon

simplestringlisteditor.h
1 /* -*- c++ -*-
2  simplestringlisteditor.h
3 
4  This file is part of KMail, the KDE mail client.
5  SPDX-FileCopyrightText: 2001 Marc Mutz <[email protected]>
6 
7  SPDX-FileCopyrightText: 2013-2023 Laurent Montel <[email protected]>
8 
9  SPDX-License-Identifier: GPL-2.0-or-later
10 */
11 
12 #pragma once
13 
14 #include <QStringList>
15 #include <QWidget>
16 
17 #include "pimcommon_export.h"
18 
19 //
20 //
21 // SimpleStringListEditor (a listbox with "add..." and "remove" buttons)
22 //
23 //
24 namespace PimCommon
25 {
26 class SimpleStringListEditorPrivate;
27 /**
28  * @brief The SimpleStringListEditor class
29  * @author Laurent Montel <[email protected]>
30  */
31 class PIMCOMMON_EXPORT SimpleStringListEditor : public QWidget
32 {
33  Q_OBJECT
34 public:
35  enum ButtonCode {
36  None = 0,
37  Add = 1,
38  Remove = 2,
39  Modify = 4,
40  Up = 8,
41  Down = 16,
42  Custom = 32,
43  All = Add | Remove | Modify | Up | Down,
44  Unsorted = Add | Remove | Modify
45  };
46 
47  /** Constructor. Populates the list with @p strings. */
48  explicit SimpleStringListEditor(QWidget *parent = nullptr,
49  ButtonCode buttons = Unsorted,
50  const QString &addLabel = QString(),
51  const QString &removeLabel = QString(),
52  const QString &modifyLabel = QString(),
53  const QString &addDialogLabel = QString());
54 
55  ~SimpleStringListEditor() override;
56  /** Sets the list of strings displayed to @p strings */
57  void setStringList(const QStringList &strings);
58 
59  /** Adds @p strings to the list of displayed strings */
60  void appendStringList(const QStringList &strings);
61 
62  /** Retrieves the current list of strings */
63  Q_REQUIRED_RESULT QStringList stringList() const;
64 
65  /** Sets the text of button @p button to @p text */
66  void setButtonText(ButtonCode button, const QString &text);
67 
68  void setUpDownAutoRepeat(bool b);
69  Q_REQUIRED_RESULT QSize sizeHint() const override;
70 
71  virtual void addNewEntry();
72  virtual QString customEntry(const QString &text);
73 
74  Q_REQUIRED_RESULT virtual QString modifyEntry(const QString &text);
75  void setAddDialogLabel(const QString &addDialogLabel);
76  void setAddDialogTitle(const QString &str);
77 
78  void setModifyDialogTitle(const QString &str);
79  void setModifyDialogLabel(const QString &str);
80 
81  void setRemoveDialogLabel(const QString &removeDialogLabel);
82 
83 Q_SIGNALS:
84  /** Connected slots can alter the argument to be added or set the
85  argument to QString() to suppress adding.
86  */
87  void aboutToAdd(QString &);
88  void changed();
89 
90 protected:
91  void insertNewEntry(const QString &newEntry);
92 
93 protected Q_SLOTS:
94  void slotAdd();
95  void slotRemove();
96  void slotModify();
97  void slotUp();
98  void slotDown();
99  void slotCustomize();
100 
101  void slotSelectionChanged();
102 
103 private:
104  void slotContextMenu(const QPoint &);
105  bool containsString(const QString &str);
106  std::unique_ptr<SimpleStringListEditorPrivate> const d;
107 };
108 }
folderdialogacltab.h
The SimpleStringListEditor class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:09:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.