File indexing completed on 2025-01-05 04:49:34

0001 /*
0002   SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: GPL-2.0-only
0005 */
0006 
0007 #include "attachmentlistwidget.h"
0008 #include "selectattachmentdialog.h"
0009 
0010 #include <QPointer>
0011 #include <QPushButton>
0012 #include <QUrl>
0013 
0014 using namespace MailMerge;
0015 AttachmentListWidget::AttachmentListWidget(QWidget *parent, ButtonCode buttons, const QString &addLabel, const QString &removeLabel, const QString &modifyLabel)
0016     : PimCommon::SimpleStringListEditor(parent, buttons, addLabel, removeLabel, modifyLabel, QString())
0017 {
0018 }
0019 
0020 AttachmentListWidget::~AttachmentListWidget() = default;
0021 
0022 void AttachmentListWidget::addNewEntry()
0023 {
0024     QPointer<SelectAttachmentDialog> dlg = new SelectAttachmentDialog(this);
0025     if (dlg->exec()) {
0026         insertNewEntry(dlg->attachmentPath());
0027     }
0028     delete dlg;
0029 }
0030 
0031 QString AttachmentListWidget::modifyEntry(const QString &text)
0032 {
0033     QString attachmentPath;
0034     QPointer<SelectAttachmentDialog> dlg = new SelectAttachmentDialog(this);
0035     dlg->setAttachmentPath(QUrl::fromLocalFile(text));
0036     if (dlg->exec()) {
0037         attachmentPath = dlg->attachmentPath();
0038     }
0039     delete dlg;
0040     return attachmentPath;
0041 }
0042 
0043 #include "moc_attachmentlistwidget.cpp"