File indexing completed on 2024-11-24 04:39:31
0001 /* 0002 This file is part of Contact Editor. 0003 0004 SPDX-FileCopyrightText: 2016 eyeOS S.L.U., a Telefonica company, sales@eyeos.com 0005 SPDX-FileCopyrightText: 2016-2020 Laurent Montel <montel.org> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #include "generalinfowidget.h" 0011 #include "../widgets/imagewidget.h" 0012 #include "blogfeedwidget.h" 0013 #include "categorieseditwidget.h" 0014 #include "mail/maillistwidget.h" 0015 #include "messageformattingwidget.h" 0016 #include "messaging/messaginglistwidget.h" 0017 #include "namewidget.h" 0018 #include "nicknamewidget.h" 0019 #include "phone/phonelistwidget.h" 0020 #include "web/weblistwidget.h" 0021 #include <KLocalizedString> 0022 #include <KPluginFactory> 0023 #include <QHBoxLayout> 0024 #include <QVBoxLayout> 0025 using namespace Akonadi; 0026 0027 GeneralInfoWidget::GeneralInfoWidget(QWidget *parent) 0028 : QWidget(parent) 0029 , mPhoneListWidget(new PhoneListWidget(this)) 0030 , mWebListWidget(new WebListWidget(this)) 0031 , mMessagingListWidget(new MessagingListWidget(this)) 0032 , mMailListWidget(new MailListWidget(this)) 0033 , mPhotoWidget(new ImageWidget(ImageWidget::Photo)) 0034 , mNameWidget(new NameWidget(this)) 0035 , mNickNameWidget(new NicknameWidget(this)) 0036 , mBlogFeedWidget(new BlogfeedWidget(this)) 0037 , mMessageFormattingWidget(new MessageFormattingWidget(this)) 0038 { 0039 auto topLayout = new QHBoxLayout(this); 0040 0041 auto photoLayout = new QVBoxLayout; 0042 topLayout->addLayout(photoLayout); 0043 mPhotoWidget->setObjectName(QLatin1StringView("photowidget")); 0044 photoLayout->addWidget(mPhotoWidget); 0045 photoLayout->addStretch(1); 0046 0047 auto leftLayout = new QVBoxLayout; 0048 topLayout->addLayout(leftLayout); 0049 0050 auto rightLayout = new QVBoxLayout; 0051 topLayout->addLayout(rightLayout); 0052 0053 mNameWidget->setObjectName(QLatin1StringView("namewidget")); 0054 leftLayout->addWidget(mNameWidget); 0055 0056 mNickNameWidget->setObjectName(QLatin1StringView("nicknamewidget")); 0057 rightLayout->addWidget(mNickNameWidget); 0058 0059 mPhoneListWidget->setObjectName(QLatin1StringView("phonelistwidget")); 0060 leftLayout->addWidget(mPhoneListWidget); 0061 0062 mWebListWidget->setObjectName(QLatin1StringView("weblistwidget")); 0063 leftLayout->addWidget(mWebListWidget); 0064 0065 mMessagingListWidget->setObjectName(QLatin1StringView("messaginglistwidget")); 0066 rightLayout->addWidget(mMessagingListWidget); 0067 0068 mMailListWidget->setObjectName(QLatin1StringView("maillistwidget")); 0069 rightLayout->addWidget(mMailListWidget); 0070 0071 auto categoryWidget = new QWidget(this); 0072 auto categoryWidgetLayout = new QVBoxLayout(categoryWidget); 0073 categoryWidgetLayout->setContentsMargins({}); 0074 mCategoriesWidget = new CategoriesEditWidget(parent); 0075 0076 mCategoriesWidget->setObjectName(QLatin1StringView("categories")); 0077 categoryWidgetLayout->addWidget(mCategoriesWidget); 0078 leftLayout->addWidget(categoryWidget); 0079 0080 mBlogFeedWidget->setObjectName(QLatin1StringView("blogfeed")); 0081 rightLayout->addWidget(mBlogFeedWidget); 0082 0083 mMessageFormattingWidget->setObjectName(QLatin1StringView("mMessageFormattingWidget")); 0084 leftLayout->addWidget(mMessageFormattingWidget); 0085 0086 leftLayout->addStretch(1); 0087 rightLayout->addStretch(1); 0088 } 0089 0090 GeneralInfoWidget::~GeneralInfoWidget() = default; 0091 0092 void GeneralInfoWidget::setDisplayType(DisplayNameEditWidget::DisplayType type) 0093 { 0094 mNameWidget->setDisplayType(type); 0095 } 0096 0097 DisplayNameEditWidget::DisplayType GeneralInfoWidget::displayType() const 0098 { 0099 return mNameWidget->displayType(); 0100 } 0101 0102 void GeneralInfoWidget::loadContact(const KContacts::Addressee &contact) 0103 { 0104 mPhoneListWidget->loadContact(contact); 0105 mWebListWidget->loadContact(contact); 0106 mMessagingListWidget->loadContact(contact); 0107 mMailListWidget->loadContact(contact); 0108 mNameWidget->loadContact(contact); 0109 mNickNameWidget->loadContact(contact); 0110 mBlogFeedWidget->loadContact(contact); 0111 mPhotoWidget->loadContact(contact); 0112 mCategoriesWidget->loadContact(contact); 0113 mMessageFormattingWidget->loadContact(contact); 0114 } 0115 0116 void GeneralInfoWidget::storeContact(KContacts::Addressee &contact) const 0117 { 0118 mPhoneListWidget->storeContact(contact); 0119 mWebListWidget->storeContact(contact); 0120 mMessagingListWidget->storeContact(contact); 0121 mMailListWidget->storeContact(contact); 0122 mNameWidget->storeContact(contact); 0123 mNickNameWidget->storeContact(contact); 0124 mBlogFeedWidget->storeContact(contact); 0125 mPhotoWidget->storeContact(contact); 0126 mCategoriesWidget->storeContact(contact); 0127 mMessageFormattingWidget->storeContact(contact); 0128 } 0129 0130 void GeneralInfoWidget::setReadOnly(bool readOnly) 0131 { 0132 mPhoneListWidget->setReadOnly(readOnly); 0133 mWebListWidget->setReadOnly(readOnly); 0134 mMessagingListWidget->setReadOnly(readOnly); 0135 mMailListWidget->setReadOnly(readOnly); 0136 mNameWidget->setReadOnly(readOnly); 0137 mNickNameWidget->setReadOnly(readOnly); 0138 mPhotoWidget->setReadOnly(readOnly); 0139 mCategoriesWidget->setReadOnly(readOnly); 0140 mMessageFormattingWidget->setReadOnly(readOnly); 0141 mBlogFeedWidget->setReadOnly(readOnly); 0142 } 0143 0144 #include "moc_generalinfowidget.cpp"