Akonadi Contacts

displaynameeditwidget.h
1 /*
2  This file is part of Contact Editor.
3 
4  SPDX-FileCopyrightText: 2009 Tobias Koenig <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #pragma once
10 
11 #include <QWidget>
12 
13 #include <KContacts/Addressee>
14 
15 class KComboBox;
16 
17 /**
18  * @short A widget for editing the display name of a contact.
19  *
20  * The widget will either use a predefined schema for formatting
21  * the name or a custom one.
22  */
24 {
25  Q_OBJECT
26 
27 public:
28  /**
29  * Describes what the display name should look like.
30  */
31  enum DisplayType {
32  SimpleName, ///< A name of the form: givenName familyName
33  FullName, ///< A name of the form: prefix givenName additionalName familyName suffix
34  ReverseNameWithComma, ///< A name of the form: familyName, givenName
35  ReverseName, ///< A name of the form: familyName givenName
36  Organization, ///< The organization name
37  CustomName ///< Let the user input a display name
38  };
39 
40  explicit DisplayNameEditWidget(QWidget *parent = nullptr);
41  ~DisplayNameEditWidget() override;
42 
43  void loadContact(const KContacts::Addressee &contact);
44  void storeContact(KContacts::Addressee &contact) const;
45 
46  void setReadOnly(bool readOnly);
47 
48  void setDisplayType(DisplayType type);
49  Q_REQUIRED_RESULT DisplayType displayType() const;
50 
51 public Q_SLOTS:
52  void changeName(const KContacts::Addressee &contact);
53  void changeOrganization(const QString &organization);
54 
55 protected:
56  bool eventFilter(QObject *object, QEvent *event) override;
57 
58 private:
59  void displayTypeChanged(int);
60  void setComboBoxEditable(bool);
61  void updateView();
62 
63  KComboBox *mView = nullptr;
64  KContacts::Addressee mContact;
65  QWidget *mViewport = nullptr;
66  DisplayType mDisplayType = DisplayType::SimpleName;
67  int mAdditionalPopupWidth;
68 };
Q_OBJECTQ_OBJECT
@ FullName
A name of the form: prefix givenName additionalName familyName suffix.
A widget for editing the display name of a contact.
Q_SLOTSQ_SLOTS
virtual bool event(QEvent *event) override
@ SimpleName
A name of the form: givenName familyName.
@ Organization
The organization name.
DisplayType
Describes what the display name should look like.
@ CustomName
Let the user input a display name.
@ ReverseName
A name of the form: familyName givenName.
@ ReverseNameWithComma
A name of the form: familyName, givenName.
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Apr 1 2023 04:09:04 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.