File indexing completed on 2024-04-28 05:50:01
0001 /*************************************************************************** 0002 currencies.h - list of currencies 0003 ------------------- 0004 begin : sam déc 1 23:40:19 CET 2001 0005 copyright : (C) 2001-2022 by Éric Bischoff 0006 email : bischoff@kde.org 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 ***************************************************************************/ 0017 0018 #ifndef CURRENCIES_H 0019 #define CURRENCIES_H 0020 0021 #include <QString> 0022 #include <QObject> 0023 0024 #include <KIO/Job> 0025 0026 #define EURO_FIXED 0 0027 #define EURO_ECB 1 0028 //#define DOLLAR_NY_FRB 2 0029 #define EURO_TG 3 0030 0031 #define OFFICIAL_RULES 0 0032 #define SMALLEST_COIN 1 0033 #define NO_ROUNDING 2 0034 0035 struct currencyStruc 0036 { 0037 QString symbol; 0038 QString code; 0039 double officialRulesPrecision; 0040 double smallestCoinPrecision; 0041 QString name; 0042 QString newYorkName; 0043 double fixedRate; 0044 double rate; 0045 int position; 0046 }; 0047 0048 class Currencies : public QObject 0049 { 0050 Q_OBJECT 0051 0052 private: 0053 QString variableRates; 0054 int roundingMethod; 0055 int numCurrencies; 0056 int dollarCurrency, euroCurrency; 0057 QString date; 0058 currencyStruc *currency; 0059 0060 public: 0061 Currencies(); 0062 virtual ~Currencies(); 0063 0064 inline int number() const {return numCurrencies;} 0065 inline int dollar() const {return dollarCurrency;} 0066 inline int euro() const {return euroCurrency;} 0067 inline const QString &symbol(int num) const {return currency[num].symbol;} 0068 inline const QString &code(int num) const {return currency[num].code;} 0069 inline double officialRulesPrecision(int num) const {return currency[num].officialRulesPrecision;} 0070 inline double smallestCoinPrecision(int num) const {return currency[num].smallestCoinPrecision;} 0071 inline const QString &name(int num) const {return currency[num].name;} 0072 inline const QString &newYorkName(int num) const {return currency[num].newYorkName;} 0073 inline double fixedRate(int num) const {return currency[num].fixedRate;} 0074 inline double rate(int num) const {return currency[num].rate;} 0075 inline void setRate(int num, double rate) {currency[num].rate = rate;} 0076 inline int position(int num) const {return currency[num].position;} 0077 inline void setPosition(int num, int position) {currency[num].position = position;} 0078 0079 bool readCurrencies( const char *filename ); 0080 void clearRates(); 0081 void addFixedRates( int rounding, bool someMoreToCome = false ); 0082 void addECBRates( int rounding ); 0083 // void addNY_FRBRates( int rounding ); 0084 void addTGRates( int rounding ); 0085 0086 0087 private slots: 0088 virtual void httpDataECB(KIO::Job *, const QByteArray &); 0089 // virtual void httpDataNY_FRB(KIO::Job *, const QByteArray &); 0090 virtual void httpDataTG(KIO::Job *, const QByteArray &); 0091 virtual void httpResultECB(KJob *); 0092 // virtual void httpResultNY_FRB(KJob *); 0093 virtual void httpResultTG(KJob *); 0094 0095 signals: 0096 void endDownload(int defaultCurrency, const QString &date); 0097 }; 0098 0099 #endif