Warning, /pim/itinerary/src/app/FormPriceDelegate.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org>
0002 // SPDX-License-Identifier: LGPL-2.0-or-later
0003 
0004 import QtQuick
0005 import QtQuick.Layouts
0006 import QtQuick.Controls as QQC2
0007 import org.kde.kirigami as Kirigami
0008 import org.kde.kirigamiaddons.formcard as FormCard
0009 import org.kde.i18n.localeData
0010 import org.kde.kitinerary
0011 import org.kde.itinerary
0012 
0013 FormCard.FormTextDelegate {
0014     id: root
0015 
0016     /** The element of which the price properties should be shown. */
0017     required property var item
0018 
0019     text: i18nc("@label", "Price")
0020     visible: PriceUtil.hasPrice(root.item)
0021 
0022     description: {
0023         const price = PriceUtil.price(root.item);
0024         const currency = PriceUtil.currency(root.item);
0025         const homeCurrency = Country.fromAlpha2(Settings.homeCountryIsoCode).currencyCode;
0026 
0027         if (Settings.performCurrencyConversion && homeCurrency != currency) {
0028             const convertedPrice = UnitConversion.convertCurrency(price, currency, homeCurrency);
0029             if (!isNaN(convertedPrice) && convertedPrice != 0.0) {
0030                 return i18nc("prices in local and home currency", "%1 (%2)",
0031                             Localizer.formatCurrency(price, currency),
0032                             Localizer.formatCurrency(convertedPrice, homeCurrency));
0033             }
0034         }
0035 
0036         return Localizer.formatCurrency(price, currency);
0037     }
0038 }