当前位置: 首页>>代码示例>>C++>>正文


C++ QChar::isLetter方法代码示例

本文整理汇总了C++中QChar::isLetter方法的典型用法代码示例。如果您正苦于以下问题:C++ QChar::isLetter方法的具体用法?C++ QChar::isLetter怎么用?C++ QChar::isLetter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QChar的用法示例。


在下文中一共展示了QChar::isLetter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getWordUnderCursor

/**
 * Returns a the complete word defined by the current cursor position.
 * Attempts to extract a valid C symbol from the location of the cursor, by
 * starting at the current line and column, and looking forward and backward
 * for non-symbol characters.
 * @return	A C symbol under the cursor, if any, or QString::null otherwise
 */
QString EditorPage::getWordUnderCursor(uint* pPosInWord)
{
	KTextEditor::ViewCursorInterface* pCursor;
	KTextEditor::EditInterface* pEditIf;
	QString sLine;
	uint nLine, nCol, nFrom, nTo, nLast, nLength;
	QChar ch;

	// Get a cursor object
	pCursor = dynamic_cast<KTextEditor::ViewCursorInterface*>(m_pView);
	if (pCursor == NULL)
		return QString::null;

	// Get a pointer to the edit interface	
	pEditIf = dynamic_cast<KTextEditor::EditInterface*>(m_pDoc);
	if (!pEditIf)
		return QString::null;
	
	// Get the line on which the cursor is positioned
	pCursor->cursorPositionReal(&nLine, &nCol);
	sLine = pEditIf->textLine(nLine);
	
	// Find the beginning of the current word
	for (nFrom = nCol; nFrom > 0;) {
		ch = sLine.at(nFrom - 1);
		if (!ch.isLetter() && !ch.isDigit() && ch != '_')
			break;
		
		nFrom--;
	}
	
	// Find the end of the current word
	nLast = sLine.length();
	for (nTo = nCol; nTo < nLast;) {
		ch = sLine.at(nTo);
		if (!ch.isLetter() && !ch.isDigit() && ch != '_')
			break;
		
		nTo++;
	}
	
	// Mark empty words
	nLength = nTo - nFrom;
	if (nLength == 0)
		return QString::null;
	
	// Return the in-word position, if required
	if (pPosInWord != NULL)
		*pPosInWord = nCol - nFrom;
	
	// Extract the word under the cursor from the entire line
	return sLine.mid(nFrom, nLength);
}
开发者ID:VicHao,项目名称:kkscope,代码行数:60,代码来源:editorpage.cpp

示例2: dxfLayerName

QString QgsDxfExport::dxfLayerName( const QString& name )
{
  //dxf layers can be max 31 characters long
  QString layerName = name.left( 31 );

  //allowed characters are 0-9, A-Z, $, -, _
  for ( int i = 0; i < layerName.size(); ++i )
  {
    QChar c = layerName.at( i );
    if ( c > 122 )
    {
      layerName[i] = '_';
      continue;
    }

    if ( c.isNumber() )
    {
      continue;
    }
    if ( c == '$' || c == '-' || c == '_' )
    {
      continue;
    }

    if ( !c.isLetter() )
    {
      layerName[i] = '_';
    }
  }
  return layerName;
}
开发者ID:Aladar64,项目名称:QGIS,代码行数:31,代码来源:qgsdxfexport.cpp

示例3: setLetter

void WordPredict::setLetter(QChar c, const QPoint &p)
{
    if (!c.isLetter()) // useless junk, dispose it!
      return;
    m_layout[c] = p;
    m_alphabet += c;
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:7,代码来源:pred.cpp

示例4: updateCompletionMap

void EditorCompletion::updateCompletionMap( Q3TextDocument *doc )
{
    bool strict = true;
    if ( doc != lastDoc )
	strict = false;
    lastDoc = doc;
    Q3TextParagraph *s = doc->firstParagraph();
    if ( !s->extraData() )
	s->setExtraData( new ParagData );
    while ( s ) {
	if ( s->length() == ( (ParagData*)s->extraData() )->lastLengthForCompletion ) {
	    s = s->next();
	    continue;
	}

	QChar c;
	QString buffer;
	for ( int i = 0; i < s->length(); ++i ) {
	    c = s->at( i )->c;
	    if ( c.isLetter() || c.isNumber() || c == '_' || c == '#' ) {
		buffer += c;
	    } else {
		addCompletionEntry( buffer, doc, strict );
		buffer = QString::null;
	    }
	}
	if ( !buffer.isEmpty() )
	    addCompletionEntry( buffer, doc, strict );

	( (ParagData*)s->extraData() )->lastLengthForCompletion = s->length();
	s = s->next();
    }
}
开发者ID:aschet,项目名称:qsaqt5,代码行数:33,代码来源:completion.cpp

示例5: slotAttemptAutoComplete

void QuickAddCapacitorDialog::slotAttemptAutoComplete()
{
    QString text = ui->capacitanceValueLineEdit->text().trimmed();
    //We accept 3 digit value codes with an optional tolerance code
    if(text.length()==3 || text.length()==4){
        QString multiplicandStr = text.left(2);
        QChar multiplierChar = text.at(2);
        bool multiplicandOk;
        int multiplicand = multiplicandStr.toInt(&multiplicandOk);        
        if(multiplicandOk && multiplierChar.isDigit()){
            double capacitance = multiplicand * pow10(-12);
            int multiplierIdx = to_char(multiplierChar) - '0';
            if(multiplierIdx >= 0 && multiplierIdx <= 9){
                capacitance = capacitance * MULTIPLIERS[multiplierIdx];
            }
            QString capacitanceStr = UnitFormatter::format(capacitance, _capacitanceParam.unitSymbol());
            ui->capacitanceValueLineEdit->setText(capacitanceStr);
        }
        if(text.length()==4){
            QChar toleranceChar = text.at(3);
            if(toleranceChar.isLetter()){
                QString tolerance = lookupTolerance(to_char(toleranceChar));
                if(!tolerance.isEmpty()){
                    ui->toleranceLineEdit->setText(tolerance);
                }
            }
        }
    }

}
开发者ID:jassuncao,项目名称:myparts,代码行数:30,代码来源:quickaddcapacitordialog.cpp

示例6: getWordUnderCursor

// TODO: will be a word in two lines ?
QString EditorPage::getWordUnderCursor(uint* pPosInWord)
{
	QString sLine;
	int nLine, nCol, nFrom, nTo, nLast, nLength;
	QChar ch;

	const KTextEditor::Cursor c = m_pView->cursorPosition();

	// Get the line on which the cursor is positioned
    c.position(nLine, nCol);
    const KTextEditor::Cursor cFrom(nLine, 0);
    const KTextEditor::Cursor cTo = m_pDoc->endOfLine(nLine);
    KTextEditor::Range range(cFrom, cTo);

    sLine = m_pDoc->text(range);
	
	// Find the beginning of the current word
	for (nFrom = nCol; nFrom > 0;) {
		ch = sLine.at(nFrom - 1);
		if (!ch.isLetter() && !ch.isDigit() && ch != '_')
			break;
		
		nFrom--;
	}
	
	// Find the end of the current word
	nLast = sLine.length();
	for (nTo = nCol; nTo < nLast;) {
		ch = sLine.at(nTo);
		if (!ch.isLetter() && !ch.isDigit() && ch != '_')
			break;
		
		nTo++;
	}

	// Mark empty words
	nLength = nTo - nFrom;
	if (nLength == 0)
		return QString::null;
	
	// Return the in-word position, if required
	if (pPosInWord != NULL)
		*pPosInWord = nCol - nFrom;
	
	// Extract the word under the cursor from the entire line
	return sLine.mid(nFrom, nLength);
}
开发者ID:choueric,项目名称:kscope-4,代码行数:48,代码来源:editorpage.cpp

示例7: consumeRegexpModifiers

void Scanner::consumeRegexpModifiers()
{
    QChar ch = m_src.peek();
    while (ch.isLetter() && ch.isLower()) {
        m_src.move();
        ch = m_src.peek();
    }
}
开发者ID:Kakadu,项目名称:qtcreator-ocaml-plugin,代码行数:8,代码来源:RubyScanner.cpp

示例8: isWordChar

bool Tokenizer::isWordChar(const QChar& c)
{
	// this method exists because some languages have non-letter category charaters
	// mixed with their letter character to make words (like hindi)
	// NOTE: this has to be extended then languages give problems,
	//       just add a category in the following test
	return (c.isLetter() || c.isMark());
}
开发者ID:garvitdelhi,项目名称:kturtle,代码行数:8,代码来源:tokenizer.cpp

示例9: setChar

void CellItem::setChar(QChar c) {
	if (c.isLetter())
	{
		is_empty = false;
		this->c = c.toUpper();
		update();
	}
}
开发者ID:krayushkin,项目名称:qt4balda,代码行数:8,代码来源:cell_item.cpp

示例10:

bool CSVWorld::IdValidator::isValid (const QChar& c, bool first) const
{
    if (c.isLetter() || c=='_')
        return true;

    if (!first && (c.isDigit()  || c.isSpace()))
        return true;

    return false;
}
开发者ID:AAlderman,项目名称:openmw,代码行数:10,代码来源:idvalidator.cpp

示例11: checkStartOfIdentifier

static bool checkStartOfIdentifier(const QString &word)
{
    if (! word.isEmpty()) {
        const QChar ch = word.at(0);
        if (ch.isLetter() || ch == QLatin1Char('_'))
            return true;
    }

    return false;
}
开发者ID:UIKit0,项目名称:qt-creator,代码行数:10,代码来源:glslcompletionassist.cpp

示例12: tokenizeNonQuoted

QStringList CommandExecutionEngine::tokenizeNonQuoted(const QString& string)
{
	//TODO The concept of tokens here is unclear. Define this better.
	QStringList result;
	QString str;

	QChar last;
	bool fractionInitiated = false;

	for (int i = 0; i < string.size(); ++i)
	{
		if ( string[i] == ' ' )
		{
			if ( !str.isNull() ) result.append(str);
			str = QString();
			fractionInitiated = false;
		}
		else if ( string[i].isDigit() && fractionInitiated && last == '.' )
		{
			str = result.last() + '.' + string[i];
			result.removeLast();
			fractionInitiated = false;
		}
		else if ( string[i].isDigit() && str.isNull() )
		{
			fractionInitiated = true;
			str += string[i];
		}
		else if ( string[i] == '.' && fractionInitiated )
		{
			result.append(str);
			str = ".";
		}
		else if ( string[i].isDigit() && fractionInitiated )
		{
			str += string[i];
		}
		else if ( (string[i].isLetter() || string[i].isDigit() || string[i] == '_') != (last.isLetter() || last.isDigit() || last == '_') )
		{
			if ( !str.isNull() ) result.append(str);
			str = string[i];
			fractionInitiated = false;
		}
		else
		{
			str += string[i];
		}

		last = string[i];
	}

	if ( !str.isNull() ) result.append(str);
	return result;
}
开发者ID:helandre,项目名称:Envision,代码行数:54,代码来源:CommandExecutionEngine.cpp

示例13: IsBoundary

bool HTMLSpellCheck::IsBoundary(QChar prev_c, QChar c, QChar next_c, const QString & wordChars)
{
    if (c.isLetter()) {
        return false;
    }

    // Single quotes of ' and curly version and hyphen/emdash are sometimes a boundary
    // and sometimes not, depending on whether they are surrounded by letters or not.
    // A sentence which 'has some text' should treat the ' as a boundary but didn't should not.
    bool is_potential_boundary = (c == '-' || 
                                  c == QChar(0x2012) || 
                                  c == '\'' || 
                                  c == QChar(0x2019) ||
                                  (!wordChars.isEmpty() && wordChars.contains(c)));

    if (is_potential_boundary && (!prev_c.isLetter() || !next_c.isLetter())) {
        return true;
    }

    return !(is_potential_boundary && (prev_c.isLetter() || next_c.isLetter()));
}
开发者ID:CedarLogic,项目名称:Sigil,代码行数:21,代码来源:HTMLSpellCheck.cpp

示例14: nextToken

TokenPtr Lexer::nextToken()
{
    while (true)
    {
        while (peek().isSpace())
        {
            consume();
        }

        QChar next = peek();
        d->newSpan();

        if (next.isNull())
        {
            return TokenPtr();
        }
        else if (next == '{')
        {
            consume();
            return TokenPtr(new LeftBraceToken(d->currentSpan()));
        }
        else if (next == '}')
        {
            consume();
            return TokenPtr(new RightBraceToken(d->currentSpan()));
        }
        else if (next == '=')
        {
            consume();
            return TokenPtr(new EqualsToken(d->currentSpan()));
        }
        else if (next.isLetter())
        {
            return lexIdentifiers();
        }
        else if (next == '"')
        {
            return lexStrings();
        }
        else if (next.isDigit() || next == '-')
        {
            return lexNumeric();
        }
        else if (next == '#')
        {
            consumeToEnd();
            continue;
        }

        throw exceptions::UnmatchedInputException(currentPos(), next);
    }
}
开发者ID:Fifty-Nine,项目名称:enigma-parser,代码行数:52,代码来源:Lexer.cpp

示例15: shouldStartCompletion

bool CodeCompletionModelControllerInterface::shouldStartCompletion(View* view, const QString &insertedText, bool userInsertion, const Cursor &position)
{
    Q_UNUSED(view);
    Q_UNUSED(position);
    if(insertedText.isEmpty())
        return false;

    QChar lastChar = insertedText.at(insertedText.count() - 1);
    if ((userInsertion && (lastChar.isLetter() || lastChar.isNumber() || lastChar == '_')) ||
        lastChar == '.' || insertedText.endsWith(QLatin1String("->"))) {
        return true;
    }
    return false;
}
开发者ID:ktuan89,项目名称:kate-4.8.0,代码行数:14,代码来源:codecompletionmodelcontrollerinterface.cpp


注:本文中的QChar::isLetter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。