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 "unitcombobox.h" 0008 #include <KLocalizedString> 0009 0010 UnitComboBox::UnitComboBox(QWidget *parent) 0011 : QComboBox(parent) 0012 { 0013 addItem(i18n("Days"), static_cast<int>(ArchiveMailInfo::ArchiveDays)); 0014 addItem(i18n("Weeks"), static_cast<int>(ArchiveMailInfo::ArchiveWeeks)); 0015 addItem(i18n("Months"), static_cast<int>(ArchiveMailInfo::ArchiveMonths)); 0016 addItem(i18n("Years"), static_cast<int>(ArchiveMailInfo::ArchiveYears)); 0017 } 0018 0019 UnitComboBox::~UnitComboBox() = default; 0020 0021 void UnitComboBox::setUnit(ArchiveMailInfo::ArchiveUnit unit) 0022 { 0023 const int index = findData(static_cast<int>(unit)); 0024 if (index != -1) { 0025 setCurrentIndex(index); 0026 } else { 0027 setCurrentIndex(0); 0028 } 0029 } 0030 0031 ArchiveMailInfo::ArchiveUnit UnitComboBox::unit() const 0032 { 0033 return static_cast<ArchiveMailInfo::ArchiveUnit>(itemData(currentIndex()).toInt()); 0034 } 0035 0036 #include "moc_unitcombobox.cpp"