Seamly2D
Code documentation
CalculatorUtil Class Reference

[0] More...

#include <calculator.h>

Inheritance diagram for CalculatorUtil:
Collaboration diagram for CalculatorUtil:

Public Member Functions

 CalculatorUtil (QWidget *parent=nullptr)
 [0] More...
 
virtual ~CalculatorUtil ()
 [6] More...
 

Private Types

enum  { NumDigitButtons = 10 }
 [9] //! [10] More...
 

Private Slots

void digitClicked ()
 [7] More...
 
void unaryOperatorClicked ()
 [7] More...
 
void additiveOperatorClicked ()
 [9] More...
 
void multiplicativeOperatorClicked ()
 [17] More...
 
void equalClicked ()
 [18] More...
 
void pointClicked ()
 [20] More...
 
void changeSignClicked ()
 [22] More...
 
void backspaceClicked ()
 [24] More...
 
void clear ()
 [26] More...
 
void clearAll ()
 [28] More...
 
void clearMemory ()
 [30] More...
 
void readMemory ()
 
void setMemory ()
 
void addToMemory ()
 

Private Member Functions

ButtoncreateButton (const QString &text, const char *member)
 [0] More...
 
void abortOperation ()
 [34] More...
 
bool calculate (double rightOperand, const QString &pendingOperator)
 [36] More...
 

Private Attributes

double sumInMemory
 [2] More...
 
double sumSoFar
 [3] //! [4] More...
 
double factorSoFar
 [4] //! [5] More...
 
QString pendingAdditiveOperator
 [5] //! [6] More...
 
QString pendingMultiplicativeOperator
 [6] //! [7] More...
 
bool waitingForOperand
 [7] //! [8] More...
 
QLineEdit * display
 [8] More...
 
ButtondigitButtons [NumDigitButtons]
 

Detailed Description

[0]

Definition at line 66 of file calculator.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

[9] //! [10]

Enumerator
NumDigitButtons 

Definition at line 117 of file calculator.h.

Constructor & Destructor Documentation

◆ CalculatorUtil()

CalculatorUtil::CalculatorUtil ( QWidget *  parent = nullptr)
explicit

◆ ~CalculatorUtil()

CalculatorUtil::~CalculatorUtil ( )
virtual

[6]

Definition at line 150 of file calculator.cpp.

Member Function Documentation

◆ abortOperation()

void CalculatorUtil::abortOperation ( )
private

[34]

[36]

Definition at line 391 of file calculator.cpp.

References clearAll(), and display.

Referenced by additiveOperatorClicked(), equalClicked(), multiplicativeOperatorClicked(), and unaryOperatorClicked().

◆ additiveOperatorClicked

void CalculatorUtil::additiveOperatorClicked ( )
privateslot

[9]

[10] [10] //! [11]

[11] //! [12]

[12] //! [13]

[13] //! [14]

[14] //! [15]

[15] //! [16]

[16] //! [17]

Definition at line 201 of file calculator.cpp.

References abortOperation(), calculate(), display, factorSoFar, pendingAdditiveOperator, pendingMultiplicativeOperator, sumSoFar, and waitingForOperand.

Referenced by CalculatorUtil().

◆ addToMemory

void CalculatorUtil::addToMemory ( )
privateslot

Definition at line 375 of file calculator.cpp.

References display, equalClicked(), and sumInMemory.

Referenced by CalculatorUtil().

◆ backspaceClicked

void CalculatorUtil::backspaceClicked ( )
privateslot

[24]

[26]

Definition at line 319 of file calculator.cpp.

References display, and waitingForOperand.

Referenced by CalculatorUtil().

◆ calculate()

bool CalculatorUtil::calculate ( double  rightOperand,
const QString &  pendingOperator 
)
private

[36]

[38]

Definition at line 399 of file calculator.cpp.

References factorSoFar, and sumSoFar.

Referenced by additiveOperatorClicked(), equalClicked(), and multiplicativeOperatorClicked().

◆ changeSignClicked

void CalculatorUtil::changeSignClicked ( )
privateslot

[22]

[24]

Definition at line 304 of file calculator.cpp.

References display.

Referenced by CalculatorUtil().

◆ clear

void CalculatorUtil::clear ( )
privateslot

[26]

[28]

Definition at line 335 of file calculator.cpp.

References display, and waitingForOperand.

Referenced by CalculatorUtil().

◆ clearAll

void CalculatorUtil::clearAll ( )
privateslot

◆ clearMemory

void CalculatorUtil::clearMemory ( )
privateslot

[30]

[32]

Definition at line 358 of file calculator.cpp.

References sumInMemory.

Referenced by CalculatorUtil().

◆ createButton()

Button * CalculatorUtil::createButton ( const QString &  text,
const char *  member 
)
private

[0]

[32] [34]

[1] [1] //! [2]

Definition at line 382 of file calculator.cpp.

Referenced by CalculatorUtil().

◆ digitClicked

void CalculatorUtil::digitClicked ( )
privateslot

[7]

Definition at line 155 of file calculator.cpp.

References display, and waitingForOperand.

Referenced by CalculatorUtil().

◆ equalClicked

void CalculatorUtil::equalClicked ( )
privateslot

◆ multiplicativeOperatorClicked

void CalculatorUtil::multiplicativeOperatorClicked ( )
privateslot

[17]

[18]

Definition at line 241 of file calculator.cpp.

References abortOperation(), calculate(), display, factorSoFar, pendingMultiplicativeOperator, and waitingForOperand.

Referenced by CalculatorUtil().

◆ pointClicked

void CalculatorUtil::pointClicked ( )
privateslot

[20]

[22]

Definition at line 293 of file calculator.cpp.

References display, and waitingForOperand.

Referenced by CalculatorUtil().

◆ readMemory

void CalculatorUtil::readMemory ( )
privateslot

Definition at line 363 of file calculator.cpp.

References display, sumInMemory, and waitingForOperand.

Referenced by CalculatorUtil().

◆ setMemory

void CalculatorUtil::setMemory ( )
privateslot

Definition at line 369 of file calculator.cpp.

References display, equalClicked(), and sumInMemory.

Referenced by CalculatorUtil().

◆ unaryOperatorClicked

void CalculatorUtil::unaryOperatorClicked ( )
privateslot

[7]

[8] [8] //! [9]

Definition at line 171 of file calculator.cpp.

References abortOperation(), display, and waitingForOperand.

Referenced by CalculatorUtil().

Member Data Documentation

◆ digitButtons

Button* CalculatorUtil::digitButtons[NumDigitButtons]
private

Definition at line 118 of file calculator.h.

Referenced by CalculatorUtil().

◆ display

◆ factorSoFar

double CalculatorUtil::factorSoFar
private

[4] //! [5]

Definition at line 104 of file calculator.h.

Referenced by additiveOperatorClicked(), calculate(), clearAll(), equalClicked(), and multiplicativeOperatorClicked().

◆ pendingAdditiveOperator

QString CalculatorUtil::pendingAdditiveOperator
private

[5] //! [6]

Definition at line 106 of file calculator.h.

Referenced by additiveOperatorClicked(), clearAll(), and equalClicked().

◆ pendingMultiplicativeOperator

QString CalculatorUtil::pendingMultiplicativeOperator
private

[6] //! [7]

Definition at line 108 of file calculator.h.

Referenced by additiveOperatorClicked(), clearAll(), equalClicked(), and multiplicativeOperatorClicked().

◆ sumInMemory

double CalculatorUtil::sumInMemory
private

[2]

[3]

Definition at line 100 of file calculator.h.

Referenced by addToMemory(), clearMemory(), readMemory(), and setMemory().

◆ sumSoFar

double CalculatorUtil::sumSoFar
private

[3] //! [4]

Definition at line 102 of file calculator.h.

Referenced by additiveOperatorClicked(), calculate(), clearAll(), and equalClicked().

◆ waitingForOperand

bool CalculatorUtil::waitingForOperand
private

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