File indexing completed on 2024-11-24 04:43:05
0001 /* 0002 SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #include "mergecontactinfowidget.h" 0007 0008 #include <Akonadi/GrantleeContactViewer> 0009 0010 #include <QHBoxLayout> 0011 #include <QLabel> 0012 #include <QStackedWidget> 0013 0014 using namespace KABMergeContacts; 0015 0016 MergeContactInfoWidget::MergeContactInfoWidget(QWidget *parent) 0017 : QWidget(parent) 0018 , mStackWidget(new QStackedWidget(this)) 0019 , mNoContactSelected(new QLabel(this)) 0020 , mContactViewer(new KAddressBookGrantlee::GrantleeContactViewer(this)) 0021 { 0022 auto lay = new QHBoxLayout(this); 0023 mStackWidget->setObjectName(QLatin1StringView("stackedwidget")); 0024 0025 mContactViewer->setObjectName(QLatin1StringView("contactwidget")); 0026 mContactViewer->setForceDisableQRCode(true); 0027 0028 mStackWidget->addWidget(mContactViewer); 0029 0030 mNoContactSelected->setObjectName(QLatin1StringView("nocontact")); 0031 mStackWidget->addWidget(mNoContactSelected); 0032 0033 lay->addWidget(mStackWidget); 0034 mStackWidget->setCurrentWidget(mNoContactSelected); 0035 } 0036 0037 MergeContactInfoWidget::~MergeContactInfoWidget() = default; 0038 0039 void MergeContactInfoWidget::setContact(const Akonadi::Item &item) 0040 { 0041 if (item.isValid()) { 0042 mContactViewer->setContact(item); 0043 mStackWidget->setCurrentWidget(mContactViewer); 0044 } else { 0045 mStackWidget->setCurrentWidget(mNoContactSelected); 0046 } 0047 } 0048 0049 #include "moc_mergecontactinfowidget.cpp"