File indexing completed on 2025-01-05 04:49:27
0001 /* 0002 SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "selectmailwidget.h" 0008 0009 #include <QHBoxLayout> 0010 #include <QTreeView> 0011 0012 #include <Akonadi/EmailAddressSelectionWidget> 0013 0014 SelectMailWidget::SelectMailWidget(QWidget *parent) 0015 : QWidget(parent) 0016 , mView(new Akonadi::EmailAddressSelectionWidget(true, nullptr, this)) 0017 { 0018 auto layout = new QHBoxLayout(this); 0019 layout->setObjectName(QLatin1StringView("mainlayout")); 0020 layout->setContentsMargins({}); 0021 0022 mView->setObjectName(QLatin1StringView("emailaddressselectionwidget")); 0023 layout->addWidget(mView); 0024 mView->view()->setSelectionMode(QAbstractItemView::ExtendedSelection); 0025 mView->view()->setAlternatingRowColors(true); 0026 mView->view()->setSortingEnabled(true); 0027 mView->view()->sortByColumn(0, Qt::AscendingOrder); 0028 connect(mView, &Akonadi::EmailAddressSelectionWidget::doubleClicked, this, &SelectMailWidget::doubleClicked); 0029 } 0030 0031 SelectMailWidget::~SelectMailWidget() = default; 0032 0033 QStringList SelectMailWidget::selectedEmails() const 0034 { 0035 QStringList lst; 0036 const auto selectedAddress = mView->selectedAddresses(); 0037 lst.reserve(selectedAddress.count()); 0038 for (const Akonadi::EmailAddressSelection &selection : selectedAddress) { 0039 lst.append(selection.email()); 0040 } 0041 return lst; 0042 } 0043 0044 #include "moc_selectmailwidget.cpp"