kmymoneycalculator.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           kmymoneycalculator.h  -  description
00003                              -------------------
00004     begin                : Sat Oct 19 2002
00005     copyright            : (C) 2000-2002 by Michael Edwardes
00006     email                : mte@users.sourceforge.net
00007                            Javier Campos Morales <javi_c@users.sourceforge.net>
00008                            Felix Rodriguez <frodriguez@users.sourceforge.net>
00009                            John C <thetacoturtle@users.sourceforge.net>
00010                            Thomas Baumgart <ipwizard@users.sourceforge.net>
00011                            Kevin Tambascio <ktambascio@users.sourceforge.net>
00012  ***************************************************************************/
00013 
00014 /***************************************************************************
00015  *                                                                         *
00016  *   This program is free software; you can redistribute it and/or modify  *
00017  *   it under the terms of the GNU General Public License as published by  *
00018  *   the Free Software Foundation; either version 2 of the License, or     *
00019  *   (at your option) any later version.                                   *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 #ifndef KMYMONEYCALCULATOR_H
00024 #define KMYMONEYCALCULATOR_H
00025 
00026 // ----------------------------------------------------------------------------
00027 // QT Includes
00028 
00029 #include <qwidget.h>
00030 #include <qframe.h>
00031 #include <qlayout.h>
00032 #include <qgrid.h>
00033 #include <qlcdnumber.h>
00034 #include <qlineedit.h>
00035 #include <qlabel.h>
00036 
00037 // ----------------------------------------------------------------------------
00038 // KDE Includes
00039 
00040 #include <kpushbutton.h>
00041 
00042 // ----------------------------------------------------------------------------
00043 // Project Includes
00044 
00059 class kMyMoneyCalculator : public QFrame  {
00060    Q_OBJECT
00061 public:
00062   kMyMoneyCalculator(QWidget* parent = 0, const char *name = 0);
00063   ~kMyMoneyCalculator();
00064 
00073   const QString result(void) const;
00074 
00083   void setComma(const QChar ch) { m_comma = ch; };
00084 
00094   void setInitialValues(const QString& value, QKeyEvent* ev);
00095 
00096 signals:
00100   void signalResultAvailable();
00101 
00102 protected:
00103   void keyPressEvent(QKeyEvent* ev);
00104 
00112   QString normalizeString(const double& val);
00113 
00114 protected slots:
00122   void digitClicked(int button);
00123 
00129   void calculationClicked(int button);
00130 
00135   void commaClicked(void);
00136 
00140   void plusminusClicked(void);
00141 
00145   void clearClicked(void);
00146 
00150   void clearAllClicked(void);
00151 
00155   void percentClicked(void);
00156 
00163   void changeDisplay(const QString& str);
00164 
00165 private:
00169   QString operand;
00170 
00174   QString m_result;
00175 
00181   QChar m_comma;
00182 
00186   double op0;
00187 
00191   double op1;
00192 
00197   int op;
00198 
00202   int stackedOp;
00203 
00207   QLabel *display;
00208 
00214   KPushButton *buttons[20];
00215 
00220   enum {
00221     /* 0-9 are used by digits */
00222     COMMA = 10,
00223     /*
00224      * make sure, that PLUS through EQUAL remain in
00225      * the order they are. Otherwise, check the calculation
00226      * signal mapper
00227      */
00228     PLUS,
00229     MINUS,
00230     SLASH,
00231     STAR,
00232     EQUAL,
00233     PLUSMINUS,
00234     PERCENT,
00235     CLEAR,
00236     CLEARALL,
00237     /* insert new buttons before this line */
00238     MAX_BUTTONS
00239   };
00240 
00246   bool m_clearOperandOnDigit;
00247 };
00248 
00249 #endif

Generated on Wed Jan 26 13:03:17 2011 for KMyMoney by  doxygen 1.5.6