#include <kmymoneycalculator.h>
Signals | |
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 | { COMMA = 10, PLUS, MINUS, SLASH, STAR, EQUAL, PLUSMINUS, PERCENT, CLEAR, CLEARALL, MAX_BUTTONS } |
Private Attributes | |
QString | operand |
QString | m_result |
QChar | m_comma |
double | op0 |
double | op1 |
int | op |
int | stackedOp |
QLabel * | display |
KPushButton * | buttons [20] |
bool | m_clearOperandOnDigit |
anonymous enum [private] |
kMyMoneyCalculator::kMyMoneyCalculator | ( | QWidget * | parent = 0 , |
|
const char * | name = 0 | |||
) |
kMyMoneyCalculator::~kMyMoneyCalculator | ( | ) |
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().
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 |
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 |
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.
int kMyMoneyCalculator::stackedOp [private] |
This member stores a pending addition operation
QLabel* kMyMoneyCalculator::display [private] |
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
bool kMyMoneyCalculator::m_clearOperandOnDigit [private] |
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.