File indexing completed on 2024-12-22 05:00:50
0001 /* 0002 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "formatcombobox.h" 0008 #include <KLocalizedString> 0009 0010 FormatComboBox::FormatComboBox(QWidget *parent) 0011 : QComboBox(parent) 0012 { 0013 // These combobox values have to stay in sync with the ArchiveType enum from BackupJob! 0014 addItem(i18n("Compressed Zip Archive (.zip)"), static_cast<int>(MailCommon::BackupJob::Zip)); 0015 addItem(i18n("Uncompressed Archive (.tar)"), static_cast<int>(MailCommon::BackupJob::Tar)); 0016 addItem(i18n("BZ2-Compressed Tar Archive (.tar.bz2)"), static_cast<int>(MailCommon::BackupJob::TarBz2)); 0017 addItem(i18n("GZ-Compressed Tar Archive (.tar.gz)"), static_cast<int>(MailCommon::BackupJob::TarGz)); 0018 setCurrentIndex(findData(static_cast<int>(MailCommon::BackupJob::TarBz2))); 0019 } 0020 0021 FormatComboBox::~FormatComboBox() = default; 0022 0023 void FormatComboBox::setFormat(MailCommon::BackupJob::ArchiveType type) 0024 { 0025 const int index = findData(static_cast<int>(type)); 0026 if (index != -1) { 0027 setCurrentIndex(index); 0028 } else { 0029 setCurrentIndex(0); 0030 } 0031 } 0032 0033 MailCommon::BackupJob::ArchiveType FormatComboBox::format() const 0034 { 0035 return static_cast<MailCommon::BackupJob::ArchiveType>(itemData(currentIndex()).toInt()); 0036 } 0037 0038 #include "moc_formatcombobox.cpp"