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.h>
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 };
69 
Let the user input a display name.
A widget for editing the display name of a contact.
A name of the form: prefix givenName additionalName familyName suffix.
A name of the form: familyName givenName.
A name of the form: familyName, givenName.
Q_OBJECTQ_OBJECT
DisplayType
Describes what the display name should look like.
A name of the form: givenName familyName.
Q_SLOTSQ_SLOTS
QObject * parent() const const
virtual bool event(QEvent *event) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Jun 17 2021 23:09:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.