void DialerWidget::buttonClicked(int index) { switch (layout) { case LAYOUT_123 : emit addDigit(QString(buttonsLayout[LAYOUT_123][index][0])); break; case LAYOUT_ABC : if (timer->isActive()) { timer->stop(); if (currentButton == index) { currentCharacter = (currentCharacter + 1) % buttonsLayout[LAYOUT_ABC][currentButton].size(); replaceDigit(QString(buttonsLayout[LAYOUT_ABC][currentButton][currentCharacter])); } else { currentButton = index; currentCharacter = 0; emit addDigit(QString(buttonsLayout[LAYOUT_ABC][currentButton][currentCharacter])); } timer->start(); } else { currentButton = index; currentCharacter = 0; emit addDigit(QString(buttonsLayout[LAYOUT_ABC][currentButton][0])); timer->start(); } break; } }
Version::Version(int major, int minor, int rev, int compilation) { if (major >= 0 || minor >= 0 || rev >= 0 || compilation >= 0) addDigit(major); if (minor >= 0 || rev >= 0 || compilation >= 0) addDigit(minor); if (rev >= 0 || compilation >= 0) addDigit(rev); if (compilation >= 0) addDigit(compilation); }
/*=============================================================*/ DIGITS* parseNumber(char *input){ int pos, start; DIGITS *head; head = NULL; pos = 0; start = pos; while (pos < strlen(input) && isdigit(input[pos])){ int digit = input[pos] - '0'; head = addDigit(head, digit); pos++; } return head; }
/** Append text to Expression. Overwrites a trailing operator with the new one, if a sequence of * two operators is input. * Recognizes and executes C, AC and = commands. */ void Calculator::addToExpressionText(const QString & buttonText) { QString text = buttonText; try{ if(text == "C") clearLast(); else if(text == "AC") clearAll(); else if(text == "+/-") changeSign(); else if(text == m_TextRad) setAngleMode(text); else if(text == m_TextDeg) setAngleMode(text); else if(text == "=") { if(isPlotExpression()) createPlot(); else parseExpression(); } else if(text=="x") addVariable(text); else if(text.startsWith("Plot")) plotter.processPlotCommand(text); else{ //we have a digit, operator or function //no clear or evaluate command if(text == "x^y") //convert to operator text = "^"; if(isNumber(text)){ //No parenthesis, we have a digit or a decimal separator addDigit(text); emit guiStateSuggested(STATE_STANDARD); //return to std page, if on Fn Page for entering E } else if(isOperator(text)) //operator or digit { addOperator(text); } else if(isParenthesis(text)) //we have a parenthesis { addParenthesis(text); } else if(isFunction(text)) //we have a function { addFunctionCall(text); } else if(isVariable(text)) //we have a variable { addVariable(text); } else throw ExExpressionError(tr("Unknown command:") + text); } //end digit operator or function m_ExpressionText = m_ExpressionParts.join(""); if(isPlotExpression()) emit expressionTextChanged("y=" + m_ExpressionText); else emit expressionTextChanged(m_ExpressionText); } //end try catch(ExExpressionError e) { emit guiStateSuggested(STATE_STANDARD); emit errorMessage(tr("Input Error"),e.what()); } catch(std::exception e) { emit guiStateSuggested(STATE_STANDARD); emit errorMessage(tr("Unknown Input Error"),e.what()); } }
void PatternFormatter::parse() { enum State { LITERAL_STATE, ESCAPE_STATE, MIN_STATE, DOT_STATE, MAX_STATE, CHARACTER_STATE, POSSIBLEOPTION_STATE, OPTION_STATE }; int i = 0; QChar c; char ch; State state = LITERAL_STATE; FormattingInfo formatting_info; QString literal; int converter_start; int option_start; while (i < mPattern.length()) { // i points to the current character // c contains the current character // ch contains the Latin1 equivalent of the current character // i is incremented at the end of the loop to consume the character // continue is used to change state without consuming the character c = mPattern.at(i); ch = c.toLatin1(); switch (state) { case LITERAL_STATE: if (ch == '%') { formatting_info.clear(); converter_start = i; state = ESCAPE_STATE; } else literal += c; break; case ESCAPE_STATE: if (ch == '%') { literal += c; state = LITERAL_STATE; } else if (ch == 'n') { literal += Layout::endOfLine(); state = LITERAL_STATE; } else { if (!literal.isEmpty()) { createLiteralConverter(literal); literal.clear(); } if (ch == '-') formatting_info.mLeftAligned = true; else if (c.isDigit()) { formatting_info.mMinLength = c.digitValue(); state = MIN_STATE; } else if (ch == '.') state = DOT_STATE; else { state = CHARACTER_STATE; continue; } } break; case MIN_STATE: if (!addDigit(c, formatting_info.mMinLength)) { if (ch == '.') state = DOT_STATE; else { state = CHARACTER_STATE; continue; } } break; case DOT_STATE: if (c.isDigit()) { formatting_info.mMaxLength = c.digitValue(); state = MAX_STATE; } else { LogError e = LOG4QT_ERROR(QT_TR_NOOP("Found character '%1' where digit was expected."), LAYOUT_EXPECTED_DIGIT_ERROR, "Log4Qt::PatternFormatter"); e << QString(c); logger()->error(e); } break; case MAX_STATE: if (!addDigit(c, formatting_info.mMaxLength)) { state = CHARACTER_STATE; continue; } break; case CHARACTER_STATE: if (mIgnoreCharacters.indexOf(c) >= 0) state = LITERAL_STATE; else if (mOptionCharacters.indexOf(c) >= 0) state = POSSIBLEOPTION_STATE; else if (mConversionCharacters.indexOf(c) >= 0) { createConverter(c, formatting_info); state = LITERAL_STATE; } else { logger()->warn("Invalid conversion character '%1' at %2 in pattern '%3'", c, i, mPattern); createLiteralConverter(mPattern.mid(converter_start, i - converter_start + 1)); state = LITERAL_STATE; } break; case POSSIBLEOPTION_STATE: if (ch == '{') { option_start = i; state = OPTION_STATE; } else { createConverter(mPattern.at(i - 1), formatting_info); state = LITERAL_STATE; continue; } break; case OPTION_STATE: if (ch == '}') { createConverter(mPattern.at(option_start - 1), formatting_info, mPattern.mid(option_start + 1, i - option_start - 1)); state = LITERAL_STATE; } break; default: Q_ASSERT_X(false, "PatternFormatter::parse()", "Unknown parsing state constant"); state = LITERAL_STATE; } i++; } if (state != LITERAL_STATE) { logger()->warn("Unexptected end of pattern '%1'", mPattern); if (state == ESCAPE_STATE) literal += c; else literal += mPattern.mid(converter_start); } if (!literal.isEmpty()) createLiteralConverter(literal); }
//SLOT void CDialogPassword::btNinePressed() { addDigit("9"); }
//SLOT void CDialogPassword::btEightPressed() { addDigit("8"); }
//SLOT void CDialogPassword::btSevenPressed() { addDigit("7"); }
//SLOT void CDialogPassword::btSixPressed() { addDigit("6"); }
//SLOT void CDialogPassword::btFivePressed() { addDigit("5"); }
//SLOT void CDialogPassword::btFourPressed() { addDigit("4"); }
//SLOT void CDialogPassword::btThreePressed() { addDigit("3"); }
//SLOT void CDialogPassword::btTwoPressed() { addDigit("2"); }
//SLOT void CDialogPassword::btOnePressed() { addDigit("1"); }
//SLOT void CDialogPassword::btZeroPressed() { addDigit("0"); }