generalinfowidget.cpp 5.39 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1 2 3 4
/*
    This file is part of Akonadi Contact.

    Copyright (C) 2016 eyeOS S.L.U., a Telefonica company, sales@eyeos.com
Laurent Montel's avatar
Laurent Montel committed
5
    Copyright (C) 2016-2017 Laurent Montel <laurent.montel@kdab.com>
Laurent Montel's avatar
Laurent Montel committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

    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 "generalinfowidget.h"
Laurent Montel's avatar
Laurent Montel committed
24
#include "namewidget.h"
Laurent Montel's avatar
Laurent Montel committed
25
#include "nicknamewidget.h"
Laurent Montel's avatar
Laurent Montel committed
26 27 28
#include <QGridLayout>
#include <QLabel>
#include <KLocalizedString>
Laurent Montel's avatar
Laurent Montel committed
29
#include <QLineEdit>
Laurent Montel's avatar
Laurent Montel committed
30 31 32 33
#include "phone/phonelistwidget.h"
#include "messaging/messaginglistwidget.h"
#include "mail/maillistwidget.h"
#include "web/weblistwidget.h"
Laurent Montel's avatar
Laurent Montel committed
34
#include "categorieseditwidget.h"
Laurent Montel's avatar
Laurent Montel committed
35
#include "../widgets/imagewidget.h"
36
#include "messageformattingwidget.h"
Laurent Montel's avatar
Laurent Montel committed
37

Laurent Montel's avatar
Laurent Montel committed
38 39 40 41 42
using namespace Akonadi;

GeneralInfoWidget::GeneralInfoWidget(QWidget *parent)
    : QWidget(parent)
{
Laurent Montel's avatar
Laurent Montel committed
43
    QHBoxLayout *topLayout = new QHBoxLayout(this);
Laurent Montel's avatar
Laurent Montel committed
44

Laurent Montel's avatar
Laurent Montel committed
45 46
    QVBoxLayout *photoLayout = new QVBoxLayout;
    topLayout->addLayout(photoLayout);
Laurent Montel's avatar
Laurent Montel committed
47 48
    mPhotoWidget = new ImageWidget(ImageWidget::Photo);
    mPhotoWidget->setObjectName(QStringLiteral("photowidget"));
Laurent Montel's avatar
Laurent Montel committed
49 50 51
    photoLayout->addWidget(mPhotoWidget);
    photoLayout->addStretch(1);

Laurent Montel's avatar
Laurent Montel committed
52 53
    QVBoxLayout *leftLayout = new QVBoxLayout;
    topLayout->addLayout(leftLayout);
Laurent Montel's avatar
Laurent Montel committed
54

Laurent Montel's avatar
Laurent Montel committed
55 56
    QVBoxLayout *rightLayout = new QVBoxLayout;
    topLayout->addLayout(rightLayout);
Laurent Montel's avatar
Laurent Montel committed
57

Laurent Montel's avatar
Laurent Montel committed
58 59
    mNameWidget = new NameWidget(this);
    mNameWidget->setObjectName(QStringLiteral("namewidget"));
Laurent Montel's avatar
Laurent Montel committed
60
    leftLayout->addWidget(mNameWidget);
Laurent Montel's avatar
Laurent Montel committed
61

Laurent Montel's avatar
Laurent Montel committed
62 63
    mNickNameWidget = new NicknameWidget(this);
    mNickNameWidget->setObjectName(QStringLiteral("nicknamewidget"));
Laurent Montel's avatar
Laurent Montel committed
64
    rightLayout->addWidget(mNickNameWidget);
Laurent Montel's avatar
Laurent Montel committed
65

Laurent Montel's avatar
Laurent Montel committed
66 67
    mPhoneListWidget = new PhoneListWidget(this);
    mPhoneListWidget->setObjectName(QStringLiteral("phonelistwidget"));
Laurent Montel's avatar
Laurent Montel committed
68
    leftLayout->addWidget(mPhoneListWidget);
Laurent Montel's avatar
Laurent Montel committed
69 70 71

    mWebListWidget = new WebListWidget(this);
    mWebListWidget->setObjectName(QStringLiteral("weblistwidget"));
Laurent Montel's avatar
Laurent Montel committed
72
    leftLayout->addWidget(mWebListWidget);
Laurent Montel's avatar
Laurent Montel committed
73 74 75

    mMessagingListWidget = new MessagingListWidget(this);
    mMessagingListWidget->setObjectName(QStringLiteral("messaginglistwidget"));
Laurent Montel's avatar
Laurent Montel committed
76
    rightLayout->addWidget(mMessagingListWidget);
Laurent Montel's avatar
Laurent Montel committed
77

Laurent Montel's avatar
Laurent Montel committed
78 79
    mMailListWidget = new MailListWidget(this);
    mMailListWidget->setObjectName(QStringLiteral("maillistwidget"));
Laurent Montel's avatar
Laurent Montel committed
80
    rightLayout->addWidget(mMailListWidget);
Laurent Montel's avatar
Laurent Montel committed
81

Laurent Montel's avatar
Laurent Montel committed
82 83 84 85 86 87 88 89 90 91
    QWidget *categoryWidget = new QWidget(this);
    QVBoxLayout *categoryWidgetLayout = new QVBoxLayout(categoryWidget);
    categoryWidgetLayout->setMargin(0);
    QLabel *label = new QLabel(i18n("Tags"), this);
    label->setObjectName(QStringLiteral("categorylabel"));
    categoryWidgetLayout->addWidget(label);

    mCategoriesWidget = new CategoriesEditWidget(this);
    mCategoriesWidget->setObjectName(QStringLiteral("categories"));
    categoryWidgetLayout->addWidget(mCategoriesWidget);
Laurent Montel's avatar
Laurent Montel committed
92
    leftLayout->addWidget(categoryWidget);
93 94 95 96 97

    mMessageFormattingWidget = new MessageFormattingWidget(this);
    mMessageFormattingWidget->setObjectName(QStringLiteral("mMessageFormattingWidget"));
    leftLayout->addWidget(mMessageFormattingWidget);

Laurent Montel's avatar
Laurent Montel committed
98 99
    leftLayout->addStretch(1);
    rightLayout->addStretch(1);
Laurent Montel's avatar
Laurent Montel committed
100 101 102 103 104 105
}

GeneralInfoWidget::~GeneralInfoWidget()
{

}
106

Laurent Montel's avatar
Laurent Montel committed
107 108 109 110 111 112 113 114 115 116
void GeneralInfoWidget::setDisplayType(DisplayNameEditWidget::DisplayType type)
{
    mNameWidget->setDisplayType(type);
}

DisplayNameEditWidget::DisplayType GeneralInfoWidget::displayType() const
{
    return mNameWidget->displayType();
}

117 118
void GeneralInfoWidget::loadContact(const KContacts::Addressee &contact)
{
Laurent Montel's avatar
Laurent Montel committed
119 120 121 122
    mPhoneListWidget->loadContact(contact);
    mWebListWidget->loadContact(contact);
    mMessagingListWidget->loadContact(contact);
    mMailListWidget->loadContact(contact);
Laurent Montel's avatar
Laurent Montel committed
123 124
    mNameWidget->loadContact(contact);
    mNickNameWidget->loadContact(contact);
Laurent Montel's avatar
Laurent Montel committed
125
    mPhotoWidget->loadContact(contact);
Laurent Montel's avatar
Laurent Montel committed
126
    mCategoriesWidget->loadContact(contact);
127
    mMessageFormattingWidget->loadContact(contact);
128 129 130 131
}

void GeneralInfoWidget::storeContact(KContacts::Addressee &contact) const
{
Laurent Montel's avatar
Laurent Montel committed
132 133 134 135
    mPhoneListWidget->storeContact(contact);
    mWebListWidget->storeContact(contact);
    mMessagingListWidget->storeContact(contact);
    mMailListWidget->storeContact(contact);
Laurent Montel's avatar
Laurent Montel committed
136 137
    mNameWidget->storeContact(contact);
    mNickNameWidget->storeContact(contact);
Laurent Montel's avatar
Laurent Montel committed
138
    mPhotoWidget->storeContact(contact);
Laurent Montel's avatar
Laurent Montel committed
139
    mCategoriesWidget->storeContact(contact);
140
    mMessageFormattingWidget->storeContact(contact);
Laurent Montel's avatar
Laurent Montel committed
141 142 143 144 145 146 147 148 149 150 151
}

void GeneralInfoWidget::setReadOnly(bool readOnly)
{
    mPhoneListWidget->setReadOnly(readOnly);
    mWebListWidget->setReadOnly(readOnly);
    mMessagingListWidget->setReadOnly(readOnly);
    mMailListWidget->setReadOnly(readOnly);
    mNameWidget->setReadOnly(readOnly);
    mNickNameWidget->setReadOnly(readOnly);
    mPhotoWidget->setReadOnly(readOnly);
Laurent Montel's avatar
Laurent Montel committed
152
    mCategoriesWidget->setReadOnly(readOnly);
153
    mMessageFormattingWidget->setReadOnly(readOnly);
154
}