File indexing completed on 2024-05-12 16:42:43

0001 /*
0002     SPDX-FileCopyrightText: 2002-2003 Michael Edwardes <mte@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2002-2016 Thomas Baumgart <tbaumgart@kde.org>
0004     SPDX-FileCopyrightText: 2002 Kevin Tambascio <ktambascio@users.sourceforge.net>
0005     SPDX-FileCopyrightText: 2017 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef MYMONEYUTILS_H
0010 #define MYMONEYUTILS_H
0011 
0012 #include <QString>
0013 #include "kmm_mymoney_export.h"
0014 
0015 class MyMoneyMoney;
0016 class MyMoneySecurity;
0017 class MyMoneyAccount;
0018 class QDate;
0019 class QString;
0020 
0021 //class that has utility functions to use throughout the application.
0022 namespace MyMoneyUtils
0023 {
0024 KMM_MYMONEY_EXPORT QString getFileExtension(QString strFileName);
0025 
0026 /**
0027  * This is a convenience method. It behaves exactly as
0028  * MyMoneyMoney::formatMoney, but takes the information
0029  * about currency symbol and precision out of the MyMoneySecurity
0030  * and MyMoneyAccount objects @a acc and @a sec. The value to be
0031  * formatted is passed as @a val.
0032  */
0033 KMM_MYMONEY_EXPORT QString formatMoney(const MyMoneyMoney& val,
0034                                        const MyMoneyAccount& acc,
0035                                        const MyMoneySecurity& sec,
0036                                        bool showThousandSeparator = true);
0037 
0038 /**
0039  * This is a convenience method. It behaves exactly as the above one,
0040  * but takes the information about currency symbol and precision out
0041  * of the MyMoneySecurity object @a sec.  The value to be
0042  * formatted is passed as @a val.
0043  */
0044 KMM_MYMONEY_EXPORT QString formatMoney(const MyMoneyMoney& val,
0045                                        const MyMoneySecurity& sec,
0046                                        bool showThousandSeparator = true);
0047 
0048 /**
0049  * This function returns a date in the form specified by Qt::ISODate.
0050  * If the @p date is invalid an empty string will be returned.
0051  *
0052  * @param date const reference to date to be converted
0053  * @return QString containing the converted date
0054  */
0055 KMM_MYMONEY_EXPORT QString dateToString(const QDate& date);
0056 
0057 /**
0058  * This function returns a date as QDate object as specified by
0059  * the parameter @p str. @p str must be in Qt::ISODate format.
0060  * If @p str is empty or contains an invalid date, QDate() is
0061  * returned.
0062  *
0063  * @param str date in Qt::ISODate format
0064  * @return QDate object
0065  */
0066 KMM_MYMONEY_EXPORT QDate stringToDate(const QString& str);
0067 
0068 KMM_MYMONEY_EXPORT QString QStringEmpty(const QString&);
0069 
0070 KMM_MYMONEY_EXPORT unsigned long extractId(const QString& txt);
0071 
0072 KMM_MYMONEY_EXPORT QString formatDate(const QDate& date);
0073 
0074 KMM_MYMONEY_EXPORT bool isRunningAsAppImage();
0075 }
0076 
0077 #endif