9 #include "businesseditorwidget.h"
10 #include "../utils/utils.h"
13 #include <KLocalizedString>
14 #include <QGridLayout>
17 #include "../widgets/imagewidget.h"
18 #include "freebusyeditwidget.h"
20 #include <KContacts/Addressee>
22 using namespace ContactEditor;
24 BusinessEditorWidget::BusinessEditorWidget(
QWidget *parent)
26 , mOrganizationWidget(new
KLineEdit(this))
33 , mFreeBusyWidget(new FreeBusyEditWidget(this))
34 , mLogoWidget(new ImageWidget(ImageWidget::Logo, this))
43 logoLayout->addStretch(0);
48 auto label =
new QLabel(
i18nc(
"@label The organization of a contact",
"Organization:"),
this);
49 generalLayout->addWidget(label, 0, 0);
51 mOrganizationWidget->setTrapReturnKey(
true);
52 mOrganizationWidget->setPlaceholderText(
i18n(
"Add organization's name"));
53 label->setBuddy(mOrganizationWidget);
54 generalLayout->addWidget(mOrganizationWidget, 1, 0);
56 label =
new QLabel(
i18nc(
"@label The profession of a contact",
"Profession:"),
this);
57 generalLayout->addWidget(label, 0, 1);
59 mProfessionWidget->setPlaceholderText(
i18n(
"Add profession"));
60 mProfessionWidget->setTrapReturnKey(
true);
61 label->setBuddy(mProfessionWidget);
62 generalLayout->addWidget(mProfessionWidget, 1, 1);
65 generalLayout->addWidget(label, 3, 0);
67 mTitleWidget->setPlaceholderText(
i18n(
"Add the title"));
68 mTitleWidget->setTrapReturnKey(
true);
69 label->setBuddy(mTitleWidget);
70 generalLayout->addWidget(mTitleWidget, 4, 0);
72 label =
new QLabel(
i18nc(
"@label The department of a contact",
"Department:"),
this);
73 generalLayout->addWidget(label, 3, 1);
75 mDepartmentWidget->setPlaceholderText(
i18n(
"Add the department"));
76 mDepartmentWidget->setTrapReturnKey(
true);
77 label->setBuddy(mDepartmentWidget);
78 generalLayout->addWidget(mDepartmentWidget, 4, 1);
80 label =
new QLabel(
i18nc(
"@label The office of a contact",
"Office:"),
this);
81 generalLayout->addWidget(label, 5, 0);
83 mOfficeWidget->setTrapReturnKey(
true);
84 mOfficeWidget->setPlaceholderText(
i18n(
"Add the office"));
86 label->setBuddy(mOfficeWidget);
87 generalLayout->addWidget(mOfficeWidget, 6, 0);
89 label =
new QLabel(
i18nc(
"@label The manager's name of a contact",
"Manager's name:"),
this);
90 generalLayout->addWidget(label, 5, 1);
92 mManagerWidget->setPlaceholderText(
i18n(
"Add manager's name"));
93 mManagerWidget->setTrapReturnKey(
true);
94 label->setBuddy(mManagerWidget);
95 generalLayout->addWidget(mManagerWidget, 6, 1);
97 label =
new QLabel(
i18nc(
"@label The assistant's name of a contact",
"Assistant's name:"),
this);
98 generalLayout->addWidget(label, 7, 0);
100 mAssistantWidget->setPlaceholderText(
i18n(
"Add assistant's name"));
101 mAssistantWidget->setTrapReturnKey(
true);
102 label->setBuddy(mAssistantWidget);
103 generalLayout->addWidget(mAssistantWidget, 8, 0);
106 label =
new QLabel(
i18nc(
"@label The free/busy information of a contact",
"Free/Busy:"));
107 generalLayout->addWidget(label, 7, 1);
109 label->setBuddy(mFreeBusyWidget);
110 generalLayout->addWidget(mFreeBusyWidget, 8, 1);
111 generalLayout->setRowStretch(9, 1);
115 BusinessEditorWidget::~BusinessEditorWidget() =
default;
119 mLogoWidget->loadContact(contact);
121 mProfessionWidget->setText(contact.
profession());
122 mTitleWidget->setText(contact.
title());
123 mDepartmentWidget->setText(contact.
department());
124 mOfficeWidget->setText(contact.
office());
129 mFreeBusyWidget->loadContact(contact);
135 mLogoWidget->storeContact(contact);
138 contact.
setTitle(mTitleWidget->text().trimmed());
140 contact.
setOffice(mOfficeWidget->text().trimmed());
145 mFreeBusyWidget->storeContact(contact);
148 void BusinessEditorWidget::setReadOnly(
bool readOnly)
150 mLogoWidget->setReadOnly(readOnly);
151 mOrganizationWidget->setReadOnly(readOnly);
152 mProfessionWidget->setReadOnly(readOnly);
153 mTitleWidget->setReadOnly(readOnly);
154 mDepartmentWidget->setReadOnly(readOnly);
155 mOfficeWidget->setReadOnly(readOnly);
156 mManagerWidget->setReadOnly(readOnly);
157 mAssistantWidget->setReadOnly(readOnly);
160 mFreeBusyWidget->setReadOnly(readOnly);