本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
}
}
}
}
示例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);
}
示例7: consumeRegexpModifiers
void Scanner::consumeRegexpModifiers()
{
QChar ch = m_src.peek();
while (ch.isLetter() && ch.isLower()) {
m_src.move();
ch = m_src.peek();
}
}
示例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());
}
示例9: setChar
void CellItem::setChar(QChar c) {
if (c.isLetter())
{
is_empty = false;
this->c = c.toUpper();
update();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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()));
}
示例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);
}
}
示例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;
}