File indexing completed on 2024-04-21 13:24:46

0001 /***************************************************************************
0002                           keurocalc.h  -  main widget
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 KEUROCALC_H
0019 #define KEUROCALC_H
0020 
0021 #include <QDialog>
0022 
0023 #include "ui_calculator.h"
0024 #include "../currencies/currencies.h"
0025 
0026 class KEuroCalc : public QDialog, public Ui::Calculator
0027 {
0028     Q_OBJECT 
0029 
0030 public:
0031     explicit KEuroCalc(QWidget* parent=0);
0032     virtual ~KEuroCalc();
0033     virtual void keyPressEvent( QKeyEvent *e ) override;
0034     bool readSplashScreen() const;
0035     void readOptions(int &oldReference, int &oldCurrency, int &oldRounding, QColor &oldDisplayColor, bool &oldSplashScreen) const;
0036     void writeOptions(int newReference, int newCurrency, int newRounding, const QColor &newDisplayColor, bool newSplashScreen);
0037 
0038     void setPreferences(int newReference, int newCurrency, int newRounding, const QColor &newDisplayColor, bool newSplashScreen);
0039 
0040 public slots:
0041     Q_SCRIPTABLE void InputDot();
0042     Q_SCRIPTABLE void InputZero();
0043     Q_SCRIPTABLE void InputOne();
0044     Q_SCRIPTABLE void InputTwo();
0045     Q_SCRIPTABLE void InputThree();
0046     Q_SCRIPTABLE void InputFour();
0047     Q_SCRIPTABLE void InputFive();
0048     Q_SCRIPTABLE void InputSix();
0049     Q_SCRIPTABLE void InputSeven();
0050     Q_SCRIPTABLE void InputEight();
0051     Q_SCRIPTABLE void InputNine();
0052     Q_SCRIPTABLE void InputPlus();
0053     Q_SCRIPTABLE void InputMinus();
0054     Q_SCRIPTABLE void InputAsterisk();
0055     Q_SCRIPTABLE void InputSlash();
0056     Q_SCRIPTABLE void InputBackspace();
0057     Q_SCRIPTABLE void ValidateReference();
0058     Q_SCRIPTABLE void ValidateCurrency();
0059     Q_SCRIPTABLE void ValidatePercent();
0060     Q_SCRIPTABLE void ValidateSimpleValue();
0061     Q_SCRIPTABLE void ChangeSign();
0062     Q_SCRIPTABLE void MemoryInput();
0063     Q_SCRIPTABLE void MemoryRecall();
0064     Q_SCRIPTABLE void MemoryPlus();
0065     Q_SCRIPTABLE void MemoryMinus();
0066     Q_SCRIPTABLE void Reset();
0067     Q_SCRIPTABLE void DisplayAbout();
0068     Q_SCRIPTABLE void DisplayHelp();
0069     Q_SCRIPTABLE void DisplaySettings();
0070     Q_SCRIPTABLE void SelectCurrency(int position);
0071 
0072     void endDownload(int defaultCurrency, const QString &date);
0073 
0074 private:  
0075     char operatorDisplay[2],
0076          inputDisplay[12];
0077     enum { beforeUnits,
0078        atUnits,
0079        afterUnits
0080     } inputPos;
0081 
0082     locale_t c_locale;
0083     bool isSimpleValue;
0084     double simpleValue,
0085            referenceValue,
0086            currencyValue;
0087     bool memorySet,
0088          isSimpleMemory;
0089     double simpleMemory,
0090            referenceMemory;
0091 
0092     int reference;
0093     int currencyNum;
0094     int rounding;
0095     QColor displayColor;
0096     bool splashScreen;
0097 
0098     Currencies currencies;
0099 
0100     void initButtons();
0101     void startDownload();
0102     void newRatesList(int defaultCurrency); 
0103 
0104     void inputDigit( char c );
0105     void inputCorrect();
0106     void inputOperator( char c );
0107     void resetInput();
0108     void displayNewInput();
0109     void displayNewResult();
0110     void displayNewCurrency();
0111     void displayMemoryButtons();
0112     void normalize( QString &numberDisplay );
0113 };
0114 
0115 #endif