Akonadi Contacts

generalinfowidget.cpp
1 /*
2  This file is part of Contact Editor.
3 
4  SPDX-FileCopyrightText: 2016 eyeOS S.L.U., a Telefonica company, [email protected]
5  SPDX-FileCopyrightText: 2016-2020 Laurent Montel <montel.org>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 #include "generalinfowidget.h"
11 #include "namewidget.h"
12 #include "nicknamewidget.h"
13 #include "blogfeedwidget.h"
14 #include <QLabel>
15 #include <KLocalizedString>
16 #include "phone/phonelistwidget.h"
17 #include "messaging/messaginglistwidget.h"
18 #include "mail/maillistwidget.h"
19 #include "web/weblistwidget.h"
20 #include "categorieseditwidget.h"
21 #include "../widgets/imagewidget.h"
22 #include "messageformattingwidget.h"
23 #include <KPluginLoader>
24 #include <KPluginFactory>
25 #include <QVBoxLayout>
26 #include <QHBoxLayout>
27 using namespace ContactEditor;
28 
29 GeneralInfoWidget::GeneralInfoWidget(QWidget *parent)
30  : QWidget(parent)
31 {
32  QHBoxLayout *topLayout = new QHBoxLayout(this);
33 
34  QVBoxLayout *photoLayout = new QVBoxLayout;
35  topLayout->addLayout(photoLayout);
36  mPhotoWidget = new ImageWidget(ImageWidget::Photo);
37  mPhotoWidget->setObjectName(QStringLiteral("photowidget"));
38  photoLayout->addWidget(mPhotoWidget);
39  photoLayout->addStretch(1);
40 
41  QVBoxLayout *leftLayout = new QVBoxLayout;
42  topLayout->addLayout(leftLayout);
43 
44  QVBoxLayout *rightLayout = new QVBoxLayout;
45  topLayout->addLayout(rightLayout);
46 
47  mNameWidget = new NameWidget(this);
48  mNameWidget->setObjectName(QStringLiteral("namewidget"));
49  leftLayout->addWidget(mNameWidget);
50 
51  mNickNameWidget = new NicknameWidget(this);
52  mNickNameWidget->setObjectName(QStringLiteral("nicknamewidget"));
53  rightLayout->addWidget(mNickNameWidget);
54 
55  mPhoneListWidget = new PhoneListWidget(this);
56  mPhoneListWidget->setObjectName(QStringLiteral("phonelistwidget"));
57  leftLayout->addWidget(mPhoneListWidget);
58 
59  mWebListWidget = new WebListWidget(this);
60  mWebListWidget->setObjectName(QStringLiteral("weblistwidget"));
61  leftLayout->addWidget(mWebListWidget);
62 
63  mMessagingListWidget = new MessagingListWidget(this);
64  mMessagingListWidget->setObjectName(QStringLiteral("messaginglistwidget"));
65  rightLayout->addWidget(mMessagingListWidget);
66 
67  mMailListWidget = new MailListWidget(this);
68  mMailListWidget->setObjectName(QStringLiteral("maillistwidget"));
69  rightLayout->addWidget(mMailListWidget);
70 
71  QWidget *categoryWidget = new QWidget(this);
72  QVBoxLayout *categoryWidgetLayout = new QVBoxLayout(categoryWidget);
73  categoryWidgetLayout->setContentsMargins(0, 0, 0, 0);
74  QLabel *label = new QLabel(i18n("Tags"), this);
75  label->setObjectName(QStringLiteral("categorylabel"));
76  categoryWidgetLayout->addWidget(label);
77 
78  KPluginLoader loader(QStringLiteral("akonadi/contacts/plugins/categorieseditwidgetplugin"));
79  KPluginFactory *factory = loader.factory();
80  if (factory) {
81  mCategoriesWidget = factory->create<ContactEditor::CategoriesEditAbstractWidget>(parent);
82  } else {
83  mCategoriesWidget = new CategoriesEditWidget(parent);
84  label->setVisible(false);
85  }
86  mCategoriesWidget->setObjectName(QStringLiteral("categories"));
87  categoryWidgetLayout->addWidget(mCategoriesWidget);
88  leftLayout->addWidget(categoryWidget);
89 
90  mBlogFeedWidget = new BlogfeedWidget(this);
91  mBlogFeedWidget->setObjectName(QStringLiteral("blogfeed"));
92  rightLayout->addWidget(mBlogFeedWidget);
93 
94  mMessageFormattingWidget = new MessageFormattingWidget(this);
95  mMessageFormattingWidget->setObjectName(QStringLiteral("mMessageFormattingWidget"));
96  leftLayout->addWidget(mMessageFormattingWidget);
97 
98  leftLayout->addStretch(1);
99  rightLayout->addStretch(1);
100 }
101 
102 GeneralInfoWidget::~GeneralInfoWidget()
103 {
104 }
105 
106 void GeneralInfoWidget::setDisplayType(DisplayNameEditWidget::DisplayType type)
107 {
108  mNameWidget->setDisplayType(type);
109 }
110 
111 DisplayNameEditWidget::DisplayType GeneralInfoWidget::displayType() const
112 {
113  return mNameWidget->displayType();
114 }
115 
116 void GeneralInfoWidget::loadContact(const KContacts::Addressee &contact)
117 {
118  mPhoneListWidget->loadContact(contact);
119  mWebListWidget->loadContact(contact);
120  mMessagingListWidget->loadContact(contact);
121  mMailListWidget->loadContact(contact);
122  mNameWidget->loadContact(contact);
123  mNickNameWidget->loadContact(contact);
124  mBlogFeedWidget->loadContact(contact);
125  mPhotoWidget->loadContact(contact);
126  mCategoriesWidget->loadContact(contact);
127  mMessageFormattingWidget->loadContact(contact);
128 }
129 
130 void GeneralInfoWidget::storeContact(KContacts::Addressee &contact) const
131 {
132  mPhoneListWidget->storeContact(contact);
133  mWebListWidget->storeContact(contact);
134  mMessagingListWidget->storeContact(contact);
135  mMailListWidget->storeContact(contact);
136  mNameWidget->storeContact(contact);
137  mNickNameWidget->storeContact(contact);
138  mBlogFeedWidget->storeContact(contact);
139  mPhotoWidget->storeContact(contact);
140  mCategoriesWidget->storeContact(contact);
141  mMessageFormattingWidget->storeContact(contact);
142 }
143 
144 void GeneralInfoWidget::setReadOnly(bool readOnly)
145 {
146  mPhoneListWidget->setReadOnly(readOnly);
147  mWebListWidget->setReadOnly(readOnly);
148  mMessagingListWidget->setReadOnly(readOnly);
149  mMailListWidget->setReadOnly(readOnly);
150  mNameWidget->setReadOnly(readOnly);
151  mNickNameWidget->setReadOnly(readOnly);
152  mPhotoWidget->setReadOnly(readOnly);
153  mCategoriesWidget->setReadOnly(readOnly);
154  mMessageFormattingWidget->setReadOnly(readOnly);
155  mBlogFeedWidget->setReadOnly(readOnly);
156 }
void setContentsMargins(int left, int top, int right, int bottom)
T * create(QObject *parent=nullptr, const QVariantList &args=QVariantList())
virtual void setVisible(bool visible)
A widget for editing the categories of a contact.
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
DisplayType
Describes what the display name should look like.
QString label(StandardShortcut id)
void setObjectName(const QString &name)
QString i18n(const char *text, const TYPE &arg...)
void addStretch(int stretch)
QWidget(QWidget *parent, Qt::WindowFlags f)
QObject * parent() const const
void addLayout(QLayout *layout, int stretch)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Sep 25 2020 23:09:17 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.