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 <mutz@kde.org>
6
7 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
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//
24namespace PimCommon
25{
26class SimpleStringListEditorPrivate;
27/**
28 * @brief The SimpleStringListEditor class
29 * @author Laurent Montel <montel@kde.org>
30 */
31class PIMCOMMON_EXPORT SimpleStringListEditor : public QWidget
32{
33 Q_OBJECT
34 Q_PROPERTY(QStringList stringList READ stringList WRITE setStringList NOTIFY changed USER true)
35public:
36 enum ButtonCode : uint8_t {
37 None = 0,
38 Add = 1,
39 Remove = 2,
40 Modify = 4,
41 Up = 8,
42 Down = 16,
43 Custom = 32,
44 All = Add | Remove | Modify | Up | Down,
45 Unsorted = Add | Remove | Modify
46 };
47
48 /** Constructor. Populates the list with @p strings. */
49 explicit SimpleStringListEditor(QWidget *parent = nullptr,
50 ButtonCode buttons = Unsorted,
51 const QString &addLabel = QString(),
52 const QString &removeLabel = QString(),
53 const QString &modifyLabel = QString(),
54 const QString &addDialogLabel = QString());
55
56 ~SimpleStringListEditor() override;
57 /** Sets the list of strings displayed to @p strings */
58 void setStringList(const QStringList &strings);
59
60 /** Adds @p strings to the list of displayed strings */
61 void appendStringList(const QStringList &strings);
62
63 /** Retrieves the current list of strings */
64 [[nodiscard]] QStringList stringList() const;
65
66 /** Sets the text of button @p button to @p text */
67 void setButtonText(ButtonCode button, const QString &text);
68
69 void setUpDownAutoRepeat(bool b);
70 [[nodiscard]] QSize sizeHint() const override;
71
72 virtual void addNewEntry();
73 [[nodiscard]] virtual QString customEntry(const QString &text);
74
75 [[nodiscard]] virtual QString modifyEntry(const QString &text);
76 void setAddDialogLabel(const QString &addDialogLabel);
77 void setAddDialogTitle(const QString &str);
78
79 void setModifyDialogTitle(const QString &str);
80 void setModifyDialogLabel(const QString &str);
81
82 void setRemoveDialogLabel(const QString &removeDialogLabel);
83
84Q_SIGNALS:
85 /** Connected slots can alter the argument to be added or set the
86 argument to QString() to suppress adding.
87 */
89 void changed();
90
91protected:
92 void insertNewEntry(const QString &newEntry);
93
94protected Q_SLOTS:
95 void slotAdd();
96 void slotRemove();
97 void slotModify();
98 void slotUp();
99 void slotDown();
100 void slotCustomize();
101
102 void slotSelectionChanged();
103
104private:
105 PIMCOMMON_NO_EXPORT void slotContextMenu(const QPoint &);
106 PIMCOMMON_NO_EXPORT bool containsString(const QString &str);
107 std::unique_ptr<SimpleStringListEditorPrivate> const d;
108};
109}
The SimpleStringListEditor class.
void aboutToAdd(QString &)
Connected slots can alter the argument to be added or set the argument to QString() to suppress addin...
folderdialogacltab.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:39:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.