File indexing completed on 2024-12-08 04:34:21
0001 /* 0002 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "exportmessageswidget.h" 0008 #include <KLocalizedString> 0009 #include <QComboBox> 0010 #include <QDateEdit> 0011 #include <QFormLayout> 0012 0013 ExportMessagesWidget::ExportMessagesWidget(QWidget *parent) 0014 : QWidget(parent) 0015 , mFromDate(new QDateEdit(QDate::currentDate(), this)) 0016 , mToDate(new QDateEdit(QDate::currentDate(), this)) 0017 , mFormat(new QComboBox(this)) 0018 { 0019 auto mainLayout = new QFormLayout(this); 0020 mainLayout->setContentsMargins({}); 0021 mainLayout->setObjectName(QStringLiteral("mainLayout")); 0022 0023 mFromDate->setObjectName(QStringLiteral("mFromDate")); 0024 mainLayout->addRow(i18n("From:"), mFromDate); 0025 0026 mToDate->setObjectName(QStringLiteral("mToDate")); 0027 mainLayout->addRow(i18n("To:"), mToDate); 0028 0029 mFormat->setObjectName(QStringLiteral("mFormat")); 0030 mainLayout->addRow(i18n("Output Format:"), mFormat); 0031 fillFormat(); 0032 } 0033 0034 ExportMessagesWidget::~ExportMessagesWidget() = default; 0035 0036 void ExportMessagesWidget::fillFormat() 0037 { 0038 mFormat->addItem(i18n("Json"), QVariant::fromValue(RocketChatRestApi::RoomsExportJob::RoomsExportInfo::FileFormat::Json)); 0039 mFormat->addItem(i18n("Html"), QVariant::fromValue(RocketChatRestApi::RoomsExportJob::RoomsExportInfo::FileFormat::Html)); 0040 } 0041 0042 RocketChatRestApi::RoomsExportJob::RoomsExportInfo ExportMessagesWidget::roomExportInfo() const 0043 { 0044 RocketChatRestApi::RoomsExportJob::RoomsExportInfo info; 0045 info.exportAs = RocketChatRestApi::RoomsExportJob::RoomsExportInfo::ExportAs::File; // For the moment we can't choose Email 0046 0047 info.fileFormat = mFormat->currentData().value<RocketChatRestApi::RoomsExportJob::RoomsExportInfo::FileFormat>(); 0048 info.dateFrom = mFromDate->dateTime(); 0049 info.dateTo = mToDate->dateTime(); 0050 return info; 0051 } 0052 0053 #include "moc_exportmessageswidget.cpp"