File indexing completed on 2025-02-16 04:49:22

0001 /*
0002     SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "mergecontactselectinformationtabwidget.h"
0008 #include "widgets/mergecontactselectinformationscrollarea.h"
0009 #include <KLocalizedString>
0010 #include <QTabBar>
0011 
0012 using namespace KABMergeContacts;
0013 
0014 MergeContactSelectInformationTabWidget::MergeContactSelectInformationTabWidget(QWidget *parent)
0015     : QTabWidget(parent)
0016 {
0017 }
0018 
0019 MergeContactSelectInformationTabWidget::~MergeContactSelectInformationTabWidget() = default;
0020 
0021 void MergeContactSelectInformationTabWidget::updateTabWidget()
0022 {
0023     tabBar()->setVisible(count() > 1);
0024 }
0025 
0026 bool MergeContactSelectInformationTabWidget::tabBarVisible() const
0027 {
0028     return tabBar()->isVisible();
0029 }
0030 
0031 void MergeContactSelectInformationTabWidget::addNewWidget(const KABMergeContacts::MergeConflictResult &list, const Akonadi::Collection &col)
0032 {
0033     auto area = new KABMergeContacts::MergeContactSelectInformationScrollArea;
0034     area->setContacts(list.conflictInformation, list.list, col);
0035     addTab(area, i18n("Duplicate contact %1", count() + 1));
0036 }
0037 
0038 void MergeContactSelectInformationTabWidget::setRequiresSelectInformationWidgets(const QList<KABMergeContacts::MergeConflictResult> &list,
0039                                                                                  const Akonadi::Collection &col)
0040 {
0041     clear();
0042     for (const KABMergeContacts::MergeConflictResult &lst : list) {
0043         addNewWidget(lst, col);
0044     }
0045     updateTabWidget();
0046 }
0047 
0048 #include "moc_mergecontactselectinformationtabwidget.cpp"