diff --git a/src/contact-editor/editor/businesseditor/businesseditorwidget.cpp b/src/contact-editor/editor/businesseditor/businesseditorwidget.cpp index 1d7e62f2..24b09c67 100644 --- a/src/contact-editor/editor/businesseditor/businesseditorwidget.cpp +++ b/src/contact-editor/editor/businesseditor/businesseditorwidget.cpp @@ -1,176 +1,176 @@ /* This file is part of Contact Editor. Copyright (C) 2016-2019 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "businesseditorwidget.h" #include "../utils/utils.h" #include #include #include #include #include "freebusyeditwidget.h" #include "../widgets/imagewidget.h" #include using namespace ContactEditor; BusinessEditorWidget::BusinessEditorWidget(QWidget *parent) : QWidget(parent) { QHBoxLayout *topLayout = new QHBoxLayout(this); QVBoxLayout *logoLayout = new QVBoxLayout; topLayout->addLayout(logoLayout); // setup general group box mLogoWidget = new ImageWidget(ImageWidget::Logo); logoLayout->addWidget(mLogoWidget, Qt::AlignTop); logoLayout->addStretch(0); QGridLayout *generalLayout = new QGridLayout; topLayout->addLayout(generalLayout); QLabel *label = new QLabel(i18nc("@label The organization of a contact", "Organization:")); generalLayout->addWidget(label, 0, 0); mOrganizationWidget = new KLineEdit; mOrganizationWidget->setTrapReturnKey(true); mOrganizationWidget->setPlaceholderText(i18n("Add organization's name")); label->setBuddy(mOrganizationWidget); generalLayout->addWidget(mOrganizationWidget, 1, 0); label = new QLabel(i18nc("@label The profession of a contact", "Profession:")); generalLayout->addWidget(label, 0, 1); mProfessionWidget = new KLineEdit; mProfessionWidget->setPlaceholderText(i18n("Add profession")); mProfessionWidget->setTrapReturnKey(true); label->setBuddy(mProfessionWidget); generalLayout->addWidget(mProfessionWidget, 1, 1); label = new QLabel(i18nc("@label The title of a contact", "Title:")); generalLayout->addWidget(label, 3, 0); mTitleWidget = new KLineEdit; mTitleWidget->setPlaceholderText(i18n("Add the title")); mTitleWidget->setTrapReturnKey(true); label->setBuddy(mTitleWidget); generalLayout->addWidget(mTitleWidget, 4, 0); label = new QLabel(i18nc("@label The department of a contact", "Department:")); generalLayout->addWidget(label, 3, 1); mDepartmentWidget = new KLineEdit; mDepartmentWidget->setPlaceholderText(i18n("Add the department")); mDepartmentWidget->setTrapReturnKey(true); label->setBuddy(mDepartmentWidget); generalLayout->addWidget(mDepartmentWidget, 4, 1); label = new QLabel(i18nc("@label The office of a contact", "Office:")); generalLayout->addWidget(label, 5, 0); mOfficeWidget = new KLineEdit; mOfficeWidget->setTrapReturnKey(true); mOfficeWidget->setPlaceholderText(i18n("Add the office")); label->setBuddy(mOfficeWidget); generalLayout->addWidget(mOfficeWidget, 6, 0); label = new QLabel(i18nc("@label The manager's name of a contact", "Manager's name:")); generalLayout->addWidget(label, 5, 1); mManagerWidget = new KLineEdit; mManagerWidget->setPlaceholderText(i18n("Add manager's name")); mManagerWidget->setTrapReturnKey(true); label->setBuddy(mManagerWidget); generalLayout->addWidget(mManagerWidget, 6, 1); label = new QLabel(i18nc("@label The assistant's name of a contact", "Assistant's name:")); generalLayout->addWidget(label, 7, 0); mAssistantWidget = new KLineEdit; mAssistantWidget->setPlaceholderText(i18n("Add assistant's name")); mAssistantWidget->setTrapReturnKey(true); label->setBuddy(mAssistantWidget); generalLayout->addWidget(mAssistantWidget, 8, 0); // setup groupware group box label = new QLabel(i18nc("@label The free/busy information of a contact", "Free/Busy:")); generalLayout->addWidget(label, 7, 1); mFreeBusyWidget = new FreeBusyEditWidget; label->setBuddy(mFreeBusyWidget); generalLayout->addWidget(mFreeBusyWidget, 8, 1); generalLayout->setRowStretch(9, 1); connect(mOrganizationWidget, &KLineEdit::textChanged, this, &BusinessEditorWidget::organizationChanged); } BusinessEditorWidget::~BusinessEditorWidget() { } void BusinessEditorWidget::loadContact(const KContacts::Addressee &contact) { mLogoWidget->loadContact(contact); mOrganizationWidget->setText(contact.organization()); - mProfessionWidget->setText(ContactEditor::Utils::loadCustom(contact, QStringLiteral("X-Profession"))); + mProfessionWidget->setText(contact.profession()); mTitleWidget->setText(contact.title()); mDepartmentWidget->setText(contact.department()); - mOfficeWidget->setText(ContactEditor::Utils::loadCustom(contact, QStringLiteral("X-Office"))); - mManagerWidget->setText(ContactEditor::Utils::loadCustom(contact, QStringLiteral("X-ManagersName"))); - mAssistantWidget->setText(ContactEditor::Utils::loadCustom(contact, QStringLiteral("X-AssistantsName"))); + mOfficeWidget->setText(contact.office()); + mManagerWidget->setText(contact.managersName()); + mAssistantWidget->setText(contact.assistantsName()); // groupware group mFreeBusyWidget->loadContact(contact); } void BusinessEditorWidget::storeContact(KContacts::Addressee &contact) { // general group mLogoWidget->storeContact(contact); contact.setOrganization(mOrganizationWidget->text()); - ContactEditor::Utils::storeCustom(contact, QStringLiteral("X-Profession"), mProfessionWidget->text().trimmed()); + contact.setProfession(mProfessionWidget->text().trimmed()); contact.setTitle(mTitleWidget->text().trimmed()); contact.setDepartment(mDepartmentWidget->text().trimmed()); - ContactEditor::Utils::storeCustom(contact, QStringLiteral("X-Office"), mOfficeWidget->text().trimmed()); - ContactEditor::Utils::storeCustom(contact, QStringLiteral("X-ManagersName"), mManagerWidget->text().trimmed()); - ContactEditor::Utils::storeCustom(contact, QStringLiteral("X-AssistantsName"), mAssistantWidget->text().trimmed()); + contact.setOffice(mOfficeWidget->text().trimmed()); + contact.setManagersName(mManagerWidget->text().trimmed()); + contact.setAssistantsName(mAssistantWidget->text().trimmed()); // groupware group mFreeBusyWidget->storeContact(contact); } void BusinessEditorWidget::setReadOnly(bool readOnly) { mLogoWidget->setReadOnly(readOnly); mOrganizationWidget->setReadOnly(readOnly); mProfessionWidget->setReadOnly(readOnly); mTitleWidget->setReadOnly(readOnly); mDepartmentWidget->setReadOnly(readOnly); mOfficeWidget->setReadOnly(readOnly); mManagerWidget->setReadOnly(readOnly); mAssistantWidget->setReadOnly(readOnly); // widgets from groupware group mFreeBusyWidget->setReadOnly(readOnly); } diff --git a/src/contact-editor/editor/generalinfoeditor/blogfeedwidget.cpp b/src/contact-editor/editor/generalinfoeditor/blogfeedwidget.cpp index 0af067a8..103eb5ae 100644 --- a/src/contact-editor/editor/generalinfoeditor/blogfeedwidget.cpp +++ b/src/contact-editor/editor/generalinfoeditor/blogfeedwidget.cpp @@ -1,65 +1,65 @@ /* This file is part of Contact Editor. Copyright (C) 2018 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "blogfeedwidget.h" #include "../utils/utils.h" #include #include #include #include #include using namespace ContactEditor; BlogfeedWidget::BlogfeedWidget(QWidget *parent) : QWidget(parent) { QVBoxLayout *topLayout = new QVBoxLayout(this); topLayout->setContentsMargins(0, 0, 0, 0); topLayout->setObjectName(QStringLiteral("mainlayout")); QLabel *blogFeedLabel = new QLabel(i18n("Blog Feed"), this); blogFeedLabel->setObjectName(QStringLiteral("blogFeedLabel")); topLayout->addWidget(blogFeedLabel); mBlogFeed = new KLineEdit(this); mBlogFeed->setTrapReturnKey(true); mBlogFeed->setPlaceholderText(i18n("Add a Blog Feed")); mBlogFeed->setObjectName(QStringLiteral("blogfeed")); topLayout->addWidget(mBlogFeed); } BlogfeedWidget::~BlogfeedWidget() { } void BlogfeedWidget::loadContact(const KContacts::Addressee &contact) { - mBlogFeed->setText(ContactEditor::Utils::loadCustom(contact, QStringLiteral("BlogFeed"))); + mBlogFeed->setText(contact.blogFeed().url()); } void BlogfeedWidget::storeContact(KContacts::Addressee &contact) const { - ContactEditor::Utils::storeCustom(contact, QStringLiteral("BlogFeed"), mBlogFeed->text().trimmed()); + contact.setBlogFeed(QUrl(mBlogFeed->text().trimmed())); } void BlogfeedWidget::setReadOnly(bool readOnly) { mBlogFeed->setReadOnly(readOnly); } diff --git a/src/contact-editor/editor/personaleditor/personaleditorwidget.cpp b/src/contact-editor/editor/personaleditor/personaleditorwidget.cpp index a2bb4662..6a092f82 100644 --- a/src/contact-editor/editor/personaleditor/personaleditorwidget.cpp +++ b/src/contact-editor/editor/personaleditor/personaleditorwidget.cpp @@ -1,99 +1,99 @@ /* This file is part of Contact Editor. Copyright (C) 2016-2019 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "personaleditorwidget.h" #include "../utils/utils.h" #include #include #include #include #include "dateeditwidget.h" #include using namespace ContactEditor; PersonalEditorWidget::PersonalEditorWidget(QWidget *parent) : QWidget(parent) { QGridLayout *mainLayout = new QGridLayout(this); QLabel *label = new QLabel(i18nc("@label The birthdate of a contact", "Birthdate:")); mainLayout->addWidget(label, 0, 0); mBirthdateWidget = new DateEditWidget(DateEditWidget::Birthday); label->setBuddy(mBirthdateWidget); mainLayout->addWidget(mBirthdateWidget, 1, 0); label = new QLabel(i18nc("@label The wedding anniversary of a contact", "Anniversary:")); mainLayout->addWidget(label, 0, 1); mAnniversaryWidget = new DateEditWidget(DateEditWidget::Anniversary); label->setBuddy(mAnniversaryWidget); mainLayout->addWidget(mAnniversaryWidget, 1, 1); label = new QLabel(i18nc("@label The partner's name of a contact", "Partner's name:")); mainLayout->addWidget(label, 0, 2); mPartnerWidget = new KLineEdit; mPartnerWidget->setPlaceholderText(i18n("Add name")); mPartnerWidget->setTrapReturnKey(true); label->setBuddy(mPartnerWidget); mainLayout->addWidget(mPartnerWidget, 1, 2); mainLayout->setColumnStretch(1, 1); mainLayout->setColumnStretch(0, 1); mainLayout->setColumnStretch(2, 1); mainLayout->setRowStretch(2, 1); } PersonalEditorWidget::~PersonalEditorWidget() { } void PersonalEditorWidget::loadContact(const KContacts::Addressee &contact) { mBirthdateWidget->setDate(contact.birthday().date()); - mAnniversaryWidget->setDate(QDate::fromString(ContactEditor::Utils::loadCustom(contact, QStringLiteral("X-Anniversary")), - Qt::ISODate)); + mAnniversaryWidget->setDate(contact.anniversary()); + // family group - mPartnerWidget->setText(ContactEditor::Utils::loadCustom(contact, QStringLiteral("X-SpousesName"))); + mPartnerWidget->setText(contact.spousesName()); } void PersonalEditorWidget::storeContact(KContacts::Addressee &contact) { contact.setBirthday(mBirthdateWidget->date()); - ContactEditor::Utils::storeCustom(contact, QStringLiteral("X-Anniversary"), mAnniversaryWidget->date().toString(Qt::ISODate)); + contact.setAnniversary(mAnniversaryWidget->date()); // family group - ContactEditor::Utils::storeCustom(contact, QStringLiteral("X-SpousesName"), mPartnerWidget->text().trimmed()); + contact.setSpousesName(mPartnerWidget->text().trimmed()); } void PersonalEditorWidget::setReadOnly(bool readOnly) { // widgets from dates group mBirthdateWidget->setReadOnly(readOnly); mAnniversaryWidget->setReadOnly(readOnly); // widgets from family group mPartnerWidget->setReadOnly(readOnly); }