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, sales@eyeos.com
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 "../widgets/imagewidget.h"
12#include "blogfeedwidget.h"
13#include "categorieseditwidget.h"
14#include "mail/maillistwidget.h"
15#include "messageformattingwidget.h"
16#include "messaging/messaginglistwidget.h"
17#include "namewidget.h"
18#include "nicknamewidget.h"
19#include "phone/phonelistwidget.h"
20#include "web/weblistwidget.h"
21#include <KLocalizedString>
22#include <KPluginFactory>
23#include <QHBoxLayout>
24#include <QVBoxLayout>
25using namespace Akonadi;
26
27GeneralInfoWidget::GeneralInfoWidget(QWidget *parent)
28 : QWidget(parent)
29 , mPhoneListWidget(new PhoneListWidget(this))
30 , mWebListWidget(new WebListWidget(this))
31 , mMessagingListWidget(new MessagingListWidget(this))
32 , mMailListWidget(new MailListWidget(this))
33 , mPhotoWidget(new ImageWidget(ImageWidget::Photo))
34 , mNameWidget(new NameWidget(this))
35 , mNickNameWidget(new NicknameWidget(this))
36 , mBlogFeedWidget(new BlogfeedWidget(this))
37 , mMessageFormattingWidget(new MessageFormattingWidget(this))
38{
39 auto topLayout = new QHBoxLayout(this);
40
41 auto photoLayout = new QVBoxLayout;
42 topLayout->addLayout(photoLayout);
43 mPhotoWidget->setObjectName(QLatin1StringView("photowidget"));
44 photoLayout->addWidget(mPhotoWidget);
45 photoLayout->addStretch(1);
46
47 auto leftLayout = new QVBoxLayout;
48 topLayout->addLayout(leftLayout);
49
50 auto rightLayout = new QVBoxLayout;
51 topLayout->addLayout(rightLayout);
52
53 mNameWidget->setObjectName(QLatin1StringView("namewidget"));
54 leftLayout->addWidget(mNameWidget);
55
56 mNickNameWidget->setObjectName(QLatin1StringView("nicknamewidget"));
57 rightLayout->addWidget(mNickNameWidget);
58
59 mPhoneListWidget->setObjectName(QLatin1StringView("phonelistwidget"));
60 leftLayout->addWidget(mPhoneListWidget);
61
62 mWebListWidget->setObjectName(QLatin1StringView("weblistwidget"));
63 leftLayout->addWidget(mWebListWidget);
64
65 mMessagingListWidget->setObjectName(QLatin1StringView("messaginglistwidget"));
66 rightLayout->addWidget(mMessagingListWidget);
67
68 mMailListWidget->setObjectName(QLatin1StringView("maillistwidget"));
69 rightLayout->addWidget(mMailListWidget);
70
71 auto categoryWidget = new QWidget(this);
72 auto categoryWidgetLayout = new QVBoxLayout(categoryWidget);
73 categoryWidgetLayout->setContentsMargins({});
74 mCategoriesWidget = new CategoriesEditWidget(parent);
75
76 mCategoriesWidget->setObjectName(QLatin1StringView("categories"));
77 categoryWidgetLayout->addWidget(mCategoriesWidget);
78 leftLayout->addWidget(categoryWidget);
79
80 mBlogFeedWidget->setObjectName(QLatin1StringView("blogfeed"));
81 rightLayout->addWidget(mBlogFeedWidget);
82
83 mMessageFormattingWidget->setObjectName(QLatin1StringView("mMessageFormattingWidget"));
84 leftLayout->addWidget(mMessageFormattingWidget);
85
86 leftLayout->addStretch(1);
87 rightLayout->addStretch(1);
88}
89
90GeneralInfoWidget::~GeneralInfoWidget() = default;
91
92void GeneralInfoWidget::setDisplayType(DisplayNameEditWidget::DisplayType type)
93{
94 mNameWidget->setDisplayType(type);
95}
96
97DisplayNameEditWidget::DisplayType GeneralInfoWidget::displayType() const
98{
99 return mNameWidget->displayType();
100}
101
102void GeneralInfoWidget::loadContact(const KContacts::Addressee &contact)
103{
104 mPhoneListWidget->loadContact(contact);
105 mWebListWidget->loadContact(contact);
106 mMessagingListWidget->loadContact(contact);
107 mMailListWidget->loadContact(contact);
108 mNameWidget->loadContact(contact);
109 mNickNameWidget->loadContact(contact);
110 mBlogFeedWidget->loadContact(contact);
111 mPhotoWidget->loadContact(contact);
112 mCategoriesWidget->loadContact(contact);
113 mMessageFormattingWidget->loadContact(contact);
114}
115
116void GeneralInfoWidget::storeContact(KContacts::Addressee &contact) const
117{
118 mPhoneListWidget->storeContact(contact);
119 mWebListWidget->storeContact(contact);
120 mMessagingListWidget->storeContact(contact);
121 mMailListWidget->storeContact(contact);
122 mNameWidget->storeContact(contact);
123 mNickNameWidget->storeContact(contact);
124 mBlogFeedWidget->storeContact(contact);
125 mPhotoWidget->storeContact(contact);
126 mCategoriesWidget->storeContact(contact);
127 mMessageFormattingWidget->storeContact(contact);
128}
129
130void GeneralInfoWidget::setReadOnly(bool readOnly)
131{
132 mPhoneListWidget->setReadOnly(readOnly);
133 mWebListWidget->setReadOnly(readOnly);
134 mMessagingListWidget->setReadOnly(readOnly);
135 mMailListWidget->setReadOnly(readOnly);
136 mNameWidget->setReadOnly(readOnly);
137 mNickNameWidget->setReadOnly(readOnly);
138 mPhotoWidget->setReadOnly(readOnly);
139 mCategoriesWidget->setReadOnly(readOnly);
140 mMessageFormattingWidget->setReadOnly(readOnly);
141 mBlogFeedWidget->setReadOnly(readOnly);
142}
143
144#include "moc_generalinfowidget.cpp"
A widget for editing the categories of a contact.
A widget for editing the display name of a contact.
void addLayout(QLayout *layout, int stretch)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:36:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.