KItinerary

priceutil.h
1/*
2 SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#ifndef KITINERARY_PRICEUTIL_H
7#define KITINERARY_PRICEUTIL_H
8
9#include "kitinerary_export.h"
10
11#include <qobjectdefs.h>
12
13class QString;
14class QStringView;
15class QVariant;
16
17namespace KItinerary {
18
19/** Utilities for dealing with price/currency information of items. */
20class KITINERARY_EXPORT PriceUtil
21{
22 Q_GADGET
23public:
24 /** Returns @c true if @p item has valid price and currency information. */
25 Q_INVOKABLE static bool hasPrice(const QVariant &item);
26
27 /** Returns @c true if @p item can have price/currency information. */
28 Q_INVOKABLE static bool canHavePrice(const QVariant &item);
29
30 /** Returns the price value from @p item. */
31 Q_INVOKABLE static double price(const QVariant &item);
32 /** Returns the currency value from @p item. */
33 Q_INVOKABLE static QString currency(const QVariant &item);
34
35 /** Sets @p price and @p currency on @p item. */
36 Q_INVOKABLE static void setPrice(QVariant &item, double price, const QString &currency);
37
38 /** Returns the number of decimals to represent the sub-unit of @p currency.
39 * @param currency ISO 4217 currency code
40 */
41 // TODO this is rather material for KI18nLocaleData
42 static int decimalCount(QStringView currency);
43 Q_INVOKABLE static int decimalCount(const QString &currency); // QML doesn't support QStringView yet...
44
45 // TODO add method for computing the total price of a set of items
46};
47
48}
49
50#endif
Utilities for dealing with price/currency information of items.
Definition priceutil.h:21
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 3 2024 11:45:33 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.