File indexing completed on 2025-02-16 04:55:55
0001 /* 0002 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #include "selectmimetypecombobox.h" 0007 #include "autocreatescripts/autocreatescriptutil_p.h" 0008 0009 #include <KLocalizedString> 0010 0011 using namespace KSieveUi; 0012 0013 SelectMimeTypeComboBox::SelectMimeTypeComboBox(QWidget *parent) 0014 : QComboBox(parent) 0015 { 0016 initialize(); 0017 connect(this, &SelectMimeTypeComboBox::activated, this, &SelectMimeTypeComboBox::valueChanged); 0018 } 0019 0020 SelectMimeTypeComboBox::~SelectMimeTypeComboBox() = default; 0021 0022 void SelectMimeTypeComboBox::initialize() 0023 { 0024 // TODO verify 0025 addItem(i18n("JPEG"), QStringLiteral("image/jpeg")); 0026 addItem(i18n("TIFF"), QStringLiteral("image/tiff")); 0027 addItem(i18n("PNG"), QStringLiteral("image/png")); 0028 addItem(i18n("BMP"), QStringLiteral("image/bmp")); 0029 } 0030 0031 QString SelectMimeTypeComboBox::code() const 0032 { 0033 return QStringLiteral("\"%1\"").arg(itemData(currentIndex()).toString()); 0034 } 0035 0036 void SelectMimeTypeComboBox::setCode(const QString &code, const QString &name, QString &error) 0037 { 0038 const int index = findData(code); 0039 if (index != -1) { 0040 setCurrentIndex(index); 0041 } else { 0042 AutoCreateScriptUtil::comboboxItemNotFound(code, name, error); 0043 setCurrentIndex(0); 0044 } 0045 } 0046 0047 #include "moc_selectmimetypecombobox.cpp"