File indexing completed on 2024-11-24 04:39:33
0001 /* 0002 SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "recipientspickerwidget.h" 0008 #include "contactstreemodel.h" 0009 #include "emailaddressselectionmodel.h" 0010 #include "emailaddressselectionwidget.h" 0011 #include "recipientseditormanager.h" 0012 #include <QAbstractItemView> 0013 #include <QHBoxLayout> 0014 #include <QTreeView> 0015 0016 using namespace Akonadi; 0017 RecipientsPickerWidget::RecipientsPickerWidget(bool onlyShowEmailWithAddress, QAbstractItemModel *model, QWidget *parent) 0018 : QWidget(parent) 0019 { 0020 auto layout = new QHBoxLayout(this); 0021 layout->setContentsMargins({}); 0022 0023 mView = 0024 new Akonadi::EmailAddressSelectionWidget(onlyShowEmailWithAddress, model ? model : Akonadi::RecipientsEditorManager::self()->model()->model(), this); 0025 layout->addWidget(mView); 0026 mView->view()->setSelectionMode(QAbstractItemView::ExtendedSelection); 0027 mView->view()->setAlternatingRowColors(true); 0028 mView->view()->setSortingEnabled(true); 0029 mView->view()->sortByColumn(0, Qt::AscendingOrder); 0030 } 0031 0032 RecipientsPickerWidget::~RecipientsPickerWidget() = default; 0033 0034 QTreeView *RecipientsPickerWidget::view() const 0035 { 0036 return mView->view(); 0037 } 0038 0039 Akonadi::EmailAddressSelectionWidget *RecipientsPickerWidget::emailAddressSelectionWidget() const 0040 { 0041 return mView; 0042 } 0043 0044 #include "moc_recipientspickerwidget.cpp"