kMyMoneyCalculator Class Reference

#include <kmymoneycalculator.h>

Inheritance diagram for kMyMoneyCalculator:

Collaboration diagram for kMyMoneyCalculator:

Collaboration graph

List of all members.


void signalResultAvailable ()

Public Member Functions

 kMyMoneyCalculator (QWidget *parent=0, const char *name=0)
 ~kMyMoneyCalculator ()
const QString result (void) const
void setComma (const QChar ch)
void setInitialValues (const QString &value, QKeyEvent *ev)

Protected Slots

void digitClicked (int button)
void calculationClicked (int button)
void commaClicked (void)
void plusminusClicked (void)
void clearClicked (void)
void clearAllClicked (void)
void percentClicked (void)
void changeDisplay (const QString &str)

Protected Member Functions

void keyPressEvent (QKeyEvent *ev)
QString normalizeString (const double &val)

Private Types

enum  {

Private Attributes

QString operand
QString m_result
QChar m_comma
double op0
double op1
int op
int stackedOp
KPushButton * buttons [20]
bool m_clearOperandOnDigit

Detailed Description

Thomas Baumgart This class implements a simple electronic calculator with the ability of addition, subtraction, multiplication and division and percentage calculation. Memory locations are not available.
The first operand and operation can be loaded from an external source to switch from an edit-widget to the calculator widget without having the user to re-type the data. See setInitialValues() for details.

Member Enumeration Documentation

anonymous enum [private]

This enumeration type stores the values used for the various keys internally


Constructor & Destructor Documentation

kMyMoneyCalculator::kMyMoneyCalculator ( QWidget parent = 0,
const char *  name = 0 

kMyMoneyCalculator::~kMyMoneyCalculator (  ) 

Member Function Documentation

const QString kMyMoneyCalculator::result ( void   )  const

This methods is used to extract the result of the last calculation. The fractional part is separated from the integral part by the character setup using setComma().

QString representing the result of the last operation

void kMyMoneyCalculator::setComma ( const QChar  ch  )  [inline]

This method is used to set the character to be used as the separator between the integer and fractional part of an operand. Upon creation of the object, m_comma is set to the current locale setting of KDE's decimalSymbol.

ch QChar representing the character to be used

void kMyMoneyCalculator::setInitialValues ( const QString &  value,
QKeyEvent *  ev 

This method is used to preset the first operand and start execution of an operation. This method is currently used by kMyMoneyEdit. If ev is 0, then no operation will be started.

value reference to QString representing the operands value
ev pointer to QKeyEvent representing the operation's key

void kMyMoneyCalculator::signalResultAvailable (  )  [signal]

This signal is emitted, when a new result is available

void kMyMoneyCalculator::keyPressEvent ( QKeyEvent *  ev  )  [protected]

QString kMyMoneyCalculator::normalizeString ( const double &  val  )  [protected]

This method is used to transform a double into a QString and removing any trailing 0's and decimal seperators

val reference to double value to be converted
QString object containing the converted value

void kMyMoneyCalculator::digitClicked ( int  button  )  [protected, slot]

This method appends the digit represented by the parameter to the current operand

button integer value of the digit to be added in the range [0..9]

void kMyMoneyCalculator::calculationClicked ( int  button  )  [protected, slot]

This methods starts the operation contained in the parameter

button The Qt::Keycode for the button pressed or clicked

void kMyMoneyCalculator::commaClicked ( void   )  [protected, slot]

This method appends a period (comma) to initialize the fractional part of an operand. The period is only appended once.

void kMyMoneyCalculator::plusminusClicked ( void   )  [protected, slot]

This method reverses the sign of the current operand

void kMyMoneyCalculator::clearClicked ( void   )  [protected, slot]

This method clears the current operand

void kMyMoneyCalculator::clearAllClicked ( void   )  [protected, slot]

This method clears all registers

void kMyMoneyCalculator::percentClicked ( void   )  [protected, slot]

This method executes the percent operation

void kMyMoneyCalculator::changeDisplay ( const QString &  str  )  [protected, slot]

This method updates the display of the calculator with the text passed as argument

str reference to QString containing the new display contents

Member Data Documentation

QString kMyMoneyCalculator::operand [private]

This member variable stores the current (second) operand

QString kMyMoneyCalculator::m_result [private]

This member variable stores the last result

QChar kMyMoneyCalculator::m_comma [private]

This member variable stores the representation of the character to be used to separate the integer and fractional part of numbers. The internal representation is always a period.

double kMyMoneyCalculator::op0 [private]

The numeric representation of a stacked first operand

double kMyMoneyCalculator::op1 [private]

The numeric representation of the first operand

int kMyMoneyCalculator::op [private]

This member stores the operation to be performed between the first and the second operand.

This member stores a pending addition operation

This member stores a pointer to the display area

KPushButton* kMyMoneyCalculator::buttons[20] [private]

This member array stores the pointers to the various buttons of the calculator. It is setup during the constructor of this object

This flag signals, if the operand should be replaced upon a digit key pressure. Defaults to false and will be set, if setInitialValues() is called without an operation.

The documentation for this class was generated from the following file:

Generated on Wed Jan 26 13:07:55 2011 for KMyMoney by  doxygen 1.5.6