本文整理汇总了C++中QChar::isLetterOrNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ QChar::isLetterOrNumber方法的具体用法?C++ QChar::isLetterOrNumber怎么用?C++ QChar::isLetterOrNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QChar
的用法示例。
在下文中一共展示了QChar::isLetterOrNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: normalizedName
QString Driver::normalizedName(const QString &name)
{
QString result = name;
QChar *data = result.data();
for (int i = name.size(); --i >= 0; ++data) {
if (!data->isLetterOrNumber())
*data = QLatin1Char('_');
}
return result;
}
示例2: validateAlphaNum
/*
Returns true if none of the characters in [str] does not match isLetterOrNumber() and validChars.
*/
bool validateAlphaNum(const QString & str)
{
const QString validChars = "[email protected]:;,[](){}~#$! ";
for (uint i=0; i < str.length() ; i++)
{
QChar tmp = str.at(i);
if ((!tmp.isLetterOrNumber()) && (validChars.find(tmp) == -1))
return false;
}
return true;
}
示例3: normalizeString
void AIMLParser::normalizeString(QString &str)
{
QString newStr;
for (int i = 0; i < str.length(); i++)
{
QChar c = str.at(i);
if (c.isLetterOrNumber() || (c == '*') || (c == '_') || (c == ' '))
newStr += c.lower();
}
str = newStr;
}
示例4: acceptsIdleEditor
bool QssCompletionAssistProcessor::acceptsIdleEditor()
{
const int pos = m_interface->position();
QChar characterUnderCursor = m_interface->characterAt(pos);
if (!characterUnderCursor.isLetterOrNumber()) {
m_startPosition = findStartOfName();
if (pos - m_startPosition >= 3 && !isInComment())
return true;
}
return false;
}
示例5: assistInterface
IAssistProposal *DocumentContentCompletionProcessor::perform(const AssistInterface *interface)
{
QScopedPointer<const AssistInterface> assistInterface(interface);
if (running())
return nullptr;
int pos = interface->position();
QChar chr;
// Skip to the start of a name
do {
chr = interface->characterAt(--pos);
} while (chr.isLetterOrNumber() || chr == '_');
++pos;
int length = interface->position() - pos;
if (interface->reason() == IdleEditor) {
QChar characterUnderCursor = interface->characterAt(interface->position());
if (characterUnderCursor.isLetterOrNumber() || length < 3)
return nullptr;
}
const QString wordUnderCursor = interface->textAt(pos, length);
const QString text = interface->textDocument()->toPlainText();
m_watcher.setFuture(Utils::runAsync(&createProposal, text, wordUnderCursor));
QObject::connect(&m_watcher, &QFutureWatcher<QStringList>::resultReadyAt,
&m_watcher, [this, pos](int index){
const TextEditor::SnippetAssistCollector snippetCollector(
m_snippetGroup, QIcon(":/texteditor/images/snippet.png"));
QList<AssistProposalItemInterface *> items = snippetCollector.collect();
for (const QString &word : m_watcher.resultAt(index)) {
auto item = new AssistProposalItem();
item->setText(word);
items.append(item);
}
setAsyncProposalAvailable(new GenericProposal(pos, items));
});
return nullptr;
}
示例6: fixWord
QString WordFixFormattedStringVisitor::fixWord(const QString &content, const QString &word, const QString &fix)
{
QString result = content;
const int wordLength = word.length();
const int fixLength = fix.length();
int pos = 0;
while ((pos = result.indexOf(word, pos)) != -1)
{
bool beginsWord = (pos == 0);
if (!beginsWord)
{
const QChar ch(result.at(pos - 1));
beginsWord = !ch.isLetterOrNumber() && !ch.isMark() && ch != QLatin1Char('_');
if (!beginsWord)
{
pos += wordLength;
continue;
}
}
bool endsWord = (pos + wordLength == result.length());
if (!endsWord)
{
const QChar ch(result.at(pos + wordLength));
endsWord = !ch.isLetterOrNumber() && !ch.isMark() && ch != QLatin1Char('_');
if (!endsWord)
{
pos += wordLength;
continue;
}
}
result.replace(pos, wordLength, fix);
pos += fixLength;
}
return result;
}
示例7: isNumberChar
static bool isNumberChar(QChar ch)
{
switch (ch.unicode()) {
case '.':
case 'e':
case 'E': // ### more...
return true;
default:
return ch.isLetterOrNumber();
}
}
示例8: ibanToElectronic
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;
}
示例9: settingsKey
QWORKBENCH_UTILS_EXPORT QString settingsKey(const QString &category)
{
QString rc(category);
const QChar underscore = QLatin1Char('_');
const int size = rc.size();
for (int i = 0; i < size; i++) {
const QChar c = rc.at(i);
if (!c.isLetterOrNumber() && c != underscore)
rc[i] = underscore;
}
return rc;
}
示例10: cleanWord
/*
* Removes bad characters
*/
QString InstrumentData::cleanWord(QString data)
{
QString out;
QChar c;
for(auto i = data.begin(); i != data.end(); ++i){
c = *i;
if(c.isLetterOrNumber()||c.isPunct()) out.append(c);
}
return out;
}
示例11: wordUnderCursor
QString GLSLTextEditorWidget::wordUnderCursor() const
{
QTextCursor tc = textCursor();
const QChar ch = characterAt(tc.position() - 1);
// make sure that we're not at the start of the next word.
if (ch.isLetterOrNumber() || ch == QLatin1Char('_'))
tc.movePosition(QTextCursor::Left);
tc.movePosition(QTextCursor::StartOfWord);
tc.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
const QString word = tc.selectedText();
return word;
}
示例12: findStartOfName
int ProFileCompletionAssistProcessor::findStartOfName(int pos) const
{
if (pos == -1)
pos = m_interface->position();
QChar chr;
// Skip to the start of a name
do {
chr = m_interface->characterAt(--pos);
} while (chr.isLetterOrNumber() || chr == QLatin1Char('_'));
return pos + 1;
}
示例13: isIdentLetter
bool Lexer::isIdentLetter(QChar ch)
{
// ASCII-biased, since all reserved words are ASCII, aand hence the
// bulk of content to be parsed.
if ((ch >= QLatin1Char('a') && ch <= QLatin1Char('z'))
|| (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z'))
|| ch == QLatin1Char('$')
|| ch == QLatin1Char('_'))
return true;
if (ch.unicode() < 128)
return false;
return ch.isLetterOrNumber();
}
示例14: toAlphaNum
QString CppFileWizard::toAlphaNum(const QString &s)
{
QString rc;
const int len = s.size();
const QChar underscore = QLatin1Char('_');
for (int i = 0; i < len; i++) {
const QChar c = s.at(i);
if (c == underscore || c.isLetterOrNumber())
rc += c;
}
return rc;
}
示例15: expressionUnderCursor
QString VariableController::expressionUnderCursor(KTextEditor::Document* doc, const KTextEditor::Cursor& cursor)
{
QString line = doc->line(cursor.line());
int index = cursor.column();
QChar c = line[index];
if (!c.isLetterOrNumber() && c != '_' && c != '$')
return QString();
int start = Utils::expressionAt(line, index);
int end = index;
for (; end < line.size(); ++end) {
QChar c = line[end];
if (!(c.isLetterOrNumber() || c == '_' || c == '$'))
break;
}
if (!(start < end))
return QString();
QString expression(line.mid(start, end-start));
expression = expression.trimmed();
return expression;
}