int BC_GEN::insertbuf(const QChar & bc)
{
	for(int index=0;index<(CODE39_SIZE+1);++index){//include '*'
		if(bc.toUpper().toLatin1()==code39_table[index]){//found char
			global_Xposition+=INTER_GAP_LEN;//char gap
			for(int i=0;i<CODE39_CODE_LEN;++i){
				switch(code39_code_table[index][i]){
					case 'B':
						for(int j=0;j<WIDE_BAR_LEN_R3;++j){
							encode_buf->append(QLine(global_Xposition,global_Yposition,global_Xposition,global_Yposition+global_height));
							global_Xposition+=1;}
						break;
					case 'b':
						for(int j=0;j<NARROW_BAR_LEN;++j){
							encode_buf->append(QLine(global_Xposition,global_Yposition,global_Xposition,global_Yposition+global_height));
							global_Xposition+=1;}
						break;
					case 'W':
						global_Xposition+=WIDE_BAR_LEN_R3;
						break;
					case 'w':
						global_Xposition+=NARROW_BAR_LEN;
						break;
					default:
						return -2;//code error
				}
			}
			chksum+=index;
			return 1;//insert successful
		}
	}
	return -3;//not found char
}
QString Q_GUI_EXPORT qt_accHotKey(const QString &text)
{
#ifndef QT_NO_SHORTCUT
    if (text.isEmpty())
        return text;

    int fa = 0;
    QChar ac;
    while ((fa = text.indexOf(QLatin1Char('&'), fa)) != -1) {
        ++fa;
        if (fa < text.length()) {
            // ignore "&&"
            if (text.at(fa) == QLatin1Char('&')) {
                ++fa;
                continue;
            } else {
                ac = text.at(fa);
                break;
            }
        }
    }
    if (ac.isNull())
        return QString();
    return (QString)QKeySequence(Qt::ALT) + ac.toUpper();
#else
    Q_UNUSED(text);
    return QString();
#endif
}
int BC_GEN::findPos(const QChar &bc)
{
	for(int index=0;index<(CODE39_SIZE);++index)
		if(bc.toUpper().toLatin1()==code39_table[index])
			return index;
	return -1;
}
Esempio n. 4
0
// Function: PROPER
Value func_proper(valVector args, ValueCalc *calc, FuncExtra *)
{
    QString str = calc->conv()->asString(args[0]).asString().toLower();

    QChar f;
    bool  first = true;

    for (int i = 0; i < str.length(); ++i) {
        if (first) {
            f = str[i];
            if (f.isNumber())
                continue;

            f = f.toUpper();

            str[i] = f;
            first = false;

            continue;
        }

        if (str[i].isSpace() || str[i].isPunct())
            first = true;
    }

    return Value(str);
}
Esempio n. 5
0
int codeIndex(QChar code) {
    // we are a case insensitive search
    code = code.toUpper();
    for(int idx = 0; _3of9codes[idx].code != '\0'; idx++) {
        if(_3of9codes[idx].code == code.toAscii()) return idx;
    }
    return -1;  // couldn't find it
}
Esempio n. 6
0
void CellItem::setChar(QChar c) {
	if (c.isLetter())
	{
		is_empty = false;
		this->c = c.toUpper();
		update();
	}
}
Esempio n. 7
0
// special characters are not properly converted by QChar::upper()
// of course still misses a lot.
QChar convertToUpper(const QChar& letter)
{
    const short offset = 32; //offset between upper and lower case letter
    if ( letter >= QChar(0x00e0) && letter <= QChar(0x00fe)) // special chars range
	return QChar(letter.unicode() - offset);
    else if ( letter == QChar(0x00ff) )
	return QChar(0x0179);
    return letter.toUpper();
}
Esempio n. 8
0
int codeIndexP(QChar code)
{
    // we are a case insensitive search
    const char latin1Code = code.toUpper().toLatin1();
    for (int idx = 0; _3of9codes[idx].code != '\0'; idx++) {
        if (_3of9codes[idx].code == latin1Code) return idx;
    }
    return -1;  // couldn't find it
}
// Corrections
QRowVector VnaPowerCorrections::corrections_dB(QChar wave, uint port) {
    QString scpi = "SENS%1:CORR:POW:DATA? \'%2%3\'";
    scpi = scpi.arg(_channelIndex);
    scpi = scpi.arg(wave.toUpper());
    scpi = scpi.arg(port);

    // Don't know size a priori!
    return _vna->queryVector(scpi, 10001*8);
}
Esempio n. 10
0
// Function: TOGGLE
Value func_toggle(valVector args, ValueCalc *calc, FuncExtra *)
{
    QString str = calc->conv()->asString(args[0]).asString();
    int i;
    int l = str.length();

    for (i = 0; i < l; ++i) {
        QChar c = str[i];
        QChar lc = c.toLower();
        QChar uc = c.toUpper();

        if (c == lc) // it is in lowercase
            str[i] = c.toUpper();
        else if (c == uc) // it is in uppercase
            str[i] = c.toLower();
    }

    return Value(str);
}
Esempio n. 11
0
void VnaPowerCorrections::setCorrections(QChar wave, uint port, QRowVector values_dB) {
    QString scpi = "SENS%1:CORR:POW:DATA \'%2%3\',";
    scpi = scpi.arg(_channelIndex);
    scpi = scpi.arg(wave.toUpper());
    scpi = scpi.arg(port);

    QByteArray _scpi = scpi.toLocal8Bit();
    _scpi.append(toBlockDataFormat(values_dB));
    _vna->binaryWrite(_scpi);
}
Esempio n. 12
0
bool NoteEntry::setFX(QChar fx)
{
	if(fx.isLetterOrNumber() || fx == '-')
	{
		// TODO: check if param match, if not reset to 00
		effect=fx.toUpper().toAscii();
		return true;
	}
	return false;
}
Esempio n. 13
0
void Key::labelAddChar()
{
    QChar tmp = m_character;
    if (m_altern) {
        tmp=m_alterncharacter;
    }
    if (m_level == 1) {
        tmp = tmp.toUpper();
    }
    LabelInstance::Instance()->addCharacter(tmp);
}
Esempio n. 14
0
static QString charFilterRegExp(QString const & filter)
{
	QString re;
	for (int i = 0; i < filter.length(); ++i) {
		QChar c = filter[i];
		if (c.isLower())
			re += ".*[" + QRegExp::escape(c) + QRegExp::escape(c.toUpper()) + "]";
		else
			re += ".*" + QRegExp::escape(c);
	}
	return re;
}
Esempio n. 15
0
QString ibanBic::ibanToElectronic(const QString& iban)
{
  QString canonicalIban;
  const int length = iban.length();
  for (int i = 0; i < length; ++i) {
    const QChar letter = iban.at(i);
    if (letter.isLetterOrNumber())
      canonicalIban.append(letter.toUpper());
  }

  return canonicalIban;
}
Esempio n. 16
0
// convert single roman character to decimal
// return < 0 if invalid
int func_arabic_helper(QChar c)
{
    switch (c.toUpper().unicode()) {
    case 'M': return 1000;
    case 'D': return 500;
    case 'C': return 100;
    case 'L': return 50;
    case 'X': return 10;
    case 'V': return 5;
    case 'I': return 1;
    }
    return -1;
}
Esempio n. 17
0
bool HbIconSource::canKeepOpen() const
{
#ifdef Q_OS_SYMBIAN
    if (mFullFilename.isEmpty()) {
        return false;
    } else {
        QChar driveLetter = mFullFilename.at(0);
        return driveLetter.toUpper() == 'Z';
    }
#else
    return false;
#endif
}
Esempio n. 18
0
static double AngleToFloat(const QString &angle, bool translated = true)
{
    if (angle.length() < 2)
        return 0.0;

    double pos;
    QChar postfix = angle.at(angle.length() - 1);
    if (postfix.isLetter())
    {
        pos = angle.left(angle.length() - 1).toDouble();
        if ((translated &&
             (postfix.toUpper() ==
              DeviceTree::tr("W", "Western Hemisphere")[0])) ||
            (!translated && (postfix.toUpper() == 'W')))
        {
            pos = -pos;
        }
    }
    else
        pos = angle.toDouble();

    return pos;
}
Esempio n. 19
0
void LetterButton::toggleCase()
{
    if ( skip ) {
        // Don't toggle case the first time
        skip=false;
        return;
    }

    QChar ch = text()[0];
    QChar nch = ch.toLower();
    if ( ch == nch )
        nch = ch.toUpper();
    setText(QString(nch));
}
Esempio n. 20
0
static QString makeMixedCaseHeader(const QString &s)
{
	QString out;
	for(int n = 0; n < s.length(); ++n)
	{
		QChar c = s[n];
		if(n == 0 || (n - 1 >= 0 && s[n - 1] == '-'))
			out += c.toUpper();
		else
			out += c;
	}

	return out;
}
Esempio n. 21
0
QString FormatKey(QString pKey)
{
    QString result = "";
    QChar *base = pKey.data();
    QChar *ch;
    int max = pKey.length();
    for (int pos = 0; pos < max; pos++)
    {
        ch = base + pos;
        if (pos == 0) result += QString(ch->toUpper());
        else if (*ch > 64 && *ch < 91) result += " " + QString(*ch);
        else result += QString(*ch);
    }

    return result;
}
Esempio n. 22
0
int GuiFontMetrics::smallcapsWidth(char_type c) const
{
	// FIXME: Optimisation probably needed: we don't use the width cache.
	if (is_utf16(c)) {
		QChar const qc = ucs4_to_qchar(c);
		QChar const uc = qc.toUpper();
		if (qc != uc)
			return smallcaps_metrics_.width(uc);
		else
			return metrics_.width(qc);
	} else {
		QString const s = toqstr(docstring(1, c));
		QString const us = s.toUpper();
		if (s != us)
			return smallcaps_metrics_.width(us);
		else
			return metrics_.width(s);
	}
}
Esempio n. 23
0
QString toCommand(GCommands gcode, QChar &c)
{
    switch (gcode) {
    case G28: {
        if(c.isNull())
            return QString("G28");
        else
            return QString("G28 %1").arg(c.toUpper());
    }
    case G32:
        return QString("G32 S1");
    case G90:
        return QString("G90");
    case G91:
        return QString("G91");
    default:
        return QString("Not implemented or not supported!");

    }
}
int JavascriptInvocation::keyCodeFor(const QChar &key) {
  switch(key.unicode()) {
    case 0x18:
      return Qt::Key_Cancel;
    case 0x08:
      return Qt::Key_Backspace;
    case 0x09:
      return Qt::Key_Tab;
    case 0x0A:
      return Qt::Key_Return;
    case 0x1B:
      return Qt::Key_Escape;
    case 0x7F:
      return Qt::Key_Delete;
    default:
      int keyCode = key.toUpper().toLatin1();
      if (keyCode >= Qt::Key_Space || keyCode <= Qt::Key_AsciiTilde)
        return keyCode;
      else
        return Qt::Key_unknown;
  }
}
Esempio n. 25
0
File: chord.cpp Progetto: Pfeil/CAN2
int parseBase( const QChar & c )
{
    switch (c.toUpper().cell())
    {
    case 'C':
        return 0;
    case 'D':
        return 2;
    case 'E':
        return 4;
    case 'F':
        return 5;
    case 'G':
        return 7;
    case 'A':
        return 9;
    case 'B':
        return 11;
    default:
        return -1;
    }
}
Esempio n. 26
0
static bool isAnsiCCharacter(const QChar& c)
{
    return (c.toUpper() >= QLatin1Char('A') && c.toUpper() <= QLatin1Char('Z'))
           || c.isDigit() || c == QLatin1Char('_');
}
static int qt_mac_get_key(int modif, const QChar &key, int virtualKey)
{
#ifdef DEBUG_KEY_BINDINGS
    qDebug("**Mapping key: %d (0x%04x) - %d (0x%04x)", key.unicode(), key.unicode(), virtualKey, virtualKey);
#endif

    if (key == kClearCharCode && virtualKey == 0x47)
        return Qt::Key_Clear;

    if (key.isDigit()) {
#ifdef DEBUG_KEY_BINDINGS
            qDebug("%d: got key: %d", __LINE__, key.digitValue());
#endif
        return key.digitValue() + Qt::Key_0;
    }

    if (key.isLetter()) {
#ifdef DEBUG_KEY_BINDINGS
        qDebug("%d: got key: %d", __LINE__, (key.toUpper().unicode() - 'A'));
#endif
        return (key.toUpper().unicode() - 'A') + Qt::Key_A;
    }
    if (key.isSymbol()) {
#ifdef DEBUG_KEY_BINDINGS
        qDebug("%d: got key: %d", __LINE__, (key.unicode()));
#endif
        return key.unicode();
    }

    for (int i = 0; qt_mac_keyboard_symbols[i].qt_code; i++) {
        if (qt_mac_keyboard_symbols[i].mac_code == key) {
            /* To work like Qt for X11 we issue Backtab when Shift + Tab are pressed */
            if (qt_mac_keyboard_symbols[i].qt_code == Qt::Key_Tab && (modif & Qt::ShiftModifier)) {
#ifdef DEBUG_KEY_BINDINGS
                qDebug("%d: got key: Qt::Key_Backtab", __LINE__);
#endif
                return Qt::Key_Backtab;
            }

#ifdef DEBUG_KEY_BINDINGS
            qDebug("%d: got key: %s", __LINE__, qt_mac_keyboard_symbols[i].desc);
#endif
            return qt_mac_keyboard_symbols[i].qt_code;
        }
    }

    //last ditch try to match the scan code
    for (int i = 0; qt_mac_keyvkey_symbols[i].qt_code; i++) {
        if (qt_mac_keyvkey_symbols[i].mac_code == virtualKey) {
#ifdef DEBUG_KEY_BINDINGS
            qDebug("%d: got key: %s", __LINE__, qt_mac_keyvkey_symbols[i].desc);
#endif
            return qt_mac_keyvkey_symbols[i].qt_code;
        }
    }

    // check if they belong to key codes in private unicode range
    if (key >= 0xf700 && key <= 0xf747) {
        if (key >= 0xf704 && key <= 0xf726) {
            return Qt::Key_F1 + (key.unicode() - 0xf704) ;
        }
        for (int i = 0; qt_mac_private_unicode[i].qt_code; i++) {
            if (qt_mac_private_unicode[i].mac_code == key) {
                return qt_mac_private_unicode[i].qt_code;
            }
        }

    }

    //oh well
#ifdef DEBUG_KEY_BINDINGS
    qDebug("Unknown case.. %s:%d %d[%d] %d", __FILE__, __LINE__, key.unicode(), key.toLatin1(), virtualKey);
#endif
    return Qt::Key_unknown;
}
Esempio n. 28
0
QString ToolTipFiller::filterActionTipContents(const FilterAction& action)
{
    if (action.isNull())
    {
        return QString();
    }

    QString            str;
    DToolTipStyleSheet cnt(ApplicationSettings::instance()->getToolTipsFont());
    QString            tip = cnt.tipHeader;

    tip += cnt.headBeg + i18n("Filter") + cnt.headEnd;

    // Displayable name
    tip += cnt.cellBeg + i18n("Name:") + cnt.cellMid
        + DImgFilterManager::instance()->i18nDisplayableName(action) + cnt.cellEnd;

    // Category
    QString reproducible("---");

    switch (action.category())
    {
        case FilterAction::ReproducibleFilter:
            reproducible = i18nc("Image filter reproducible: Yes", "Yes");
            break;
        case FilterAction::ComplexFilter:
            reproducible = i18nc("Image filter reproducible: Partially", "Partially");
            break;
        case FilterAction::DocumentedHistory:
            reproducible = i18nc("Image filter reproducible: No", "No");
            break;
        default:
            break;
    };

    tip += cnt.cellBeg + i18n("Reproducible:") + cnt.cellMid
         + reproducible + cnt.cellEnd;

    // Description

    str = action.description();

    if (str.isEmpty())
    {
        str = QString("---");
    }

    tip += cnt.cellSpecBeg + i18nc("Image filter description", "Description:") + cnt.cellSpecMid
        + cnt.breakString(str) + cnt.cellSpecEnd;

    // Identifier + version
    tip += cnt.cellBeg + i18n("Identifier:") + cnt.cellMid
        + action.identifier() + " (v" + QString::number(action.version()) + ") " + cnt.cellEnd;

    if (action.hasParameters())
    {
        tip += cnt.headBeg + i18n("Technical Parameters") + cnt.headEnd;

        const QHash<QString, QVariant>& params = action.parameters();
        QList<QString> keys                    = params.keys();
        qSort(keys);

        foreach(const QString& key, keys)
        {
            QHash<QString, QVariant>::const_iterator it;

            for (it = params.find(key); it != params.end() && it.key() == key; ++it)
            {
                if (it.key().isEmpty() || !it.value().isValid())
                {
                    continue;
                }

                if (it.key().startsWith(QLatin1String("curveData")))
                {
                    str = i18n("<i>Binary Data</i>");
                }
                else
                {
                    str = it.value().toString();
                }

                if (str.length() > cnt.maxStringLength)
                {
                    str = cnt.elidedText(str, Qt::ElideRight);
                }

                QString key = it.key();
                QChar first = key.at(0);

                if (first.isLower())
                {
                    key.replace(0, 1, first.toUpper());
                }

                tip += cnt.cellBeg + key + cnt.cellMid
                    + str + cnt.cellEnd;
            }
        }
Esempio n. 29
0
TokenList KoEnhancedPathFormula::scan( const QString &formula ) const
{
  // parsing state
  enum { Start, Finish, Bad, InNumber, InDecimal, InExpIndicator, InExponent,
    InString, InIdentifier } state;

    TokenList tokens;

    int i = 0;
    state = Start;
    int tokenStart = 0;
    QString tokenText;
    QString expr = formula + QChar();

    // main loop
    while( (state != Bad) && (state != Finish) && (i < expr.length() ) )
    {
        QChar ch = expr[i];

        switch( state )
        {
            case Start:
                tokenStart = i;

                // skip any whitespaces
                if( ch.isSpace() )
                {
                    i++;
                }
                // check for number
                else if( ch.isDigit() )
                {
                    state = InNumber;
                }
                // beginning with alphanumeric ?
                // could be identifier, function, function reference, modifier reference
                else if( isIdentifier( ch ) )
                {
                    state = InIdentifier;
                }
                // decimal dot ?
                else if ( ch == '.' )
                {
                    tokenText.append( expr[i++] );
                    state = InDecimal;
                }
                // terminator character
                else if ( ch == QChar::Null )
                {
                    state = Finish;
                }
                // look for operator match
                else
                {
                    QString opString( ch );
                    int op = matchOperator( opString );

                    // any matched operator ?
                    if( op != FormulaToken::OperatorInvalid )
                    {
                        i++;
                        tokens.append( FormulaToken( FormulaToken::TypeOperator, opString, tokenStart ) );
                    }
                    else state = Bad;
                }
            break;
            case InIdentifier:
                // consume as long as alpha, dollar sign, question mark, or digit
                if( isIdentifier( ch ) || ch.isDigit() )
                {
                    tokenText.append( expr[i++] );
                }
                // a '(' ? then this must be a function identifier
                else if( ch == '(' )
                {
                    tokens.append( FormulaToken( FormulaToken::TypeFunction, tokenText, tokenStart) );
                    tokenStart = i;
                    tokenText = "";
                    state = Start;
                }
                // we're done with identifier
                else
                {
                    tokens.append( FormulaToken( FormulaToken::TypeReference, tokenText, tokenStart) );
                    tokenStart = i;
                    tokenText = "";
                    state = Start;
                }
            break;
            case InNumber:
                // consume as long as it's digit
                if( ch.isDigit() )
                {
                    tokenText.append( expr[i++] );
                }
                // decimal dot ?
                else if( ch == '.' )
                {
                    tokenText.append( '.' );
                    i++;
                    state = InDecimal;
                }
                // exponent ?
                else if( ch.toUpper() == 'E' )
                {
                    tokenText.append( 'E' );
                    i++;
                    state = InExpIndicator;
                }
                // we're done with integer number
                else
                {
                    tokens.append( FormulaToken( FormulaToken::TypeNumber, tokenText, tokenStart ) );
                    tokenText = "";
                    state = Start;
                };
            break;
            case InDecimal:
                // consume as long as it's digit
                if( ch.isDigit() )
                {
                    tokenText.append( expr[i++] );
                }
                // exponent ?
                else if( ch.toUpper() == 'E' )
                {
                    tokenText.append( 'E' );
                    i++;
                    state = InExpIndicator;
                }
                // we're done with floating-point number
                else
                {
                    tokens.append( FormulaToken( FormulaToken::TypeNumber, tokenText, tokenStart ) );
                    tokenText = "";
                    state = Start;
                };
            break;
            case InExpIndicator:
                // possible + or - right after E, e.g 1.23E+12 or 4.67E-8
                if( ( ch == '+' ) || ( ch == '-' ) )
                {
                    tokenText.append( expr[i++] );
                }
                // consume as long as it's digit
                else if( ch.isDigit() )
                {
                    state = InExponent;
                }
                // invalid thing here
                else state = Bad;
            break;
            case InExponent:
                // consume as long as it's digit
                if( ch.isDigit() )
                {
                    tokenText.append( expr[i++] );
                }
                // we're done with floating-point number
                else
                {
                    tokens.append( FormulaToken( FormulaToken::TypeNumber, tokenText, tokenStart ) );
                    tokenText = "";
                    state = Start;
                };
                break;
            case Bad:
            default:
            break;
        }
    }
     return tokens;
}
Esempio n. 30
0
	inline static QChar map(const QChar& ch) { return ch.toUpper(); }