MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); convert_value = 1.2607; coma_here = false; current_op = NONE; operand_1 = 0.; operand_2 = 0.; connect(ui->actionQuitter, SIGNAL(triggered()), this, SLOT(close())); connect(ui->actionA_propos, SIGNAL(triggered()), this, SLOT(onAPropos())); connect(ui->actionA_propos_de_Qt, SIGNAL(triggered()), this, SLOT(onAProposDeQt())); connect(ui->actionParam_tres_conversion, SIGNAL(triggered()), this, SLOT(onParametreConversion())); connect(ui->pushButton_0, SIGNAL(clicked()), this, SLOT(on0())); connect(ui->pushButton_1, SIGNAL(clicked()), this, SLOT(on1())); connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(on2())); connect(ui->pushButton_3, SIGNAL(clicked()), this, SLOT(on3())); connect(ui->pushButton_4, SIGNAL(clicked()), this, SLOT(on4())); connect(ui->pushButton_5, SIGNAL(clicked()), this, SLOT(on5())); connect(ui->pushButton_6, SIGNAL(clicked()), this, SLOT(on6())); connect(ui->pushButton_7, SIGNAL(clicked()), this, SLOT(on7())); connect(ui->pushButton_8, SIGNAL(clicked()), this, SLOT(on8())); connect(ui->pushButton_9, SIGNAL(clicked()), this, SLOT(on9())); connect(ui->pushButton_coma, SIGNAL(clicked()), this, SLOT(onComa())); connect(ui->pushButton_equal, SIGNAL(clicked()), this, SLOT(onEqual())); connect(ui->pushButton_divided, SIGNAL(clicked()), this, SLOT(onDivided())); connect(ui->pushButton_plus, SIGNAL(clicked()), this, SLOT(onPlus())); connect(ui->pushButton_minus, SIGNAL(clicked()), this, SLOT(onMinus())); connect(ui->pushButton_times, SIGNAL(clicked()), this, SLOT(onMultiplicate())); connect(ui->pushButton_dollar_euro, SIGNAL(clicked()), this, SLOT(onDollarEuro())); connect(ui->pushButton_euro_dollar, SIGNAL(clicked()), this, SLOT(onEuroDollar())); // shortcuts QShortcut *scDel = new QShortcut(QKeySequence("Del"), this); connect(scDel, SIGNAL(activated()), this, SLOT(clearLine())); QShortcut *scBackspace = new QShortcut(QKeySequence("Backspace"), this); connect(scBackspace, SIGNAL(activated()), this, SLOT(clearLastChar())); // QShortcut *scEnter = new QShortcut(QKeySequence("Enter"), this); // connect(scEnter, SIGNAL(activated()), this, SLOT(onEqual())); // QShortcut *sc0 = new QShortcut(QKeySequence("0"), this); // connect(scBackspace, SIGNAL(activated()), this, SLOT(on0())); }
void cParser::parse(void) { m_bEnd = false; m_varLine = 0; m_curLine = 0; m_errorID = 0; while(!m_strText.empty() && !m_bEnd) { char ch = m_strText[0]; m_strText = m_strText.substr(1); switch(ch) { case '{' : onLBraket(); break; case '}' : onRBraket(); break; case '=' : onEqual(); break; case '\n' : onReturn(); break; case ' ' : case '\t': onSpace(); break; case '#' : onComment(); break; case ';': break; default: onOther(ch); break; } if (error()) { onError(); } } onEnd(); }