本文整理汇总了C++中QChar::isSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ QChar::isSpace方法的具体用法?C++ QChar::isSpace怎么用?C++ QChar::isSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QChar
的用法示例。
在下文中一共展示了QChar::isSpace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
ShellCommand::ShellCommand(const QString & fullCommand)
{
bool inQuotes = false;
QString builder;
for ( int i = 0 ; i < fullCommand.count() ; i++ ) {
QChar ch = fullCommand[i];
const bool isLastChar = ( i == fullCommand.count() - 1 );
const bool isQuote = ( ch == '\'' || ch == '\"' );
if ( !isLastChar && isQuote ) {
inQuotes = !inQuotes;
} else {
if ( (!ch.isSpace() || inQuotes) && !isQuote ) {
builder.append(ch);
}
if ( (ch.isSpace() && !inQuotes) || ( i == fullCommand.count()-1 ) ) {
_arguments << builder;
builder.clear();
}
}
}
}
示例2: split
QStringList NaturalQueryParser::split(const QString &query, bool is_user_query, QList<int> *positions) const
{
QStringList parts;
QString part;
int size = query.size();
bool between_quotes = false;
bool split_at_every_char = !localeWordsSeparatedBySpaces();
for (int i=0; i<size; ++i) {
QChar c = query.at(i);
if (!between_quotes && (is_user_query || part != QLatin1String("$")) &&
(split_at_every_char || c.isSpace() || (is_user_query && d->separators.contains(c)))) {
// If there is a cluster of several spaces in the input, part may be empty
if (part.size() > 0) {
parts.append(part);
part.clear();
}
// Add a separator, if any
if (!c.isSpace()) {
if (positions) {
positions->append(i);
}
part.append(c);
}
} else if (c == QLatin1Char('"')) {
between_quotes = !between_quotes;
} else {
if (is_user_query && part.length() == 1 && d->separators.contains(part.at(0))) {
// The part contains only a separator, split "-KMail" to "-", "KMail"
parts.append(part);
part.clear();
}
if (positions && part.size() == 0) {
// Start of a new part, save its position in the stream
positions->append(i);
}
part.append(c);
}
}
if (!part.isEmpty()) {
parts.append(part);
}
return parts;
}
示例3: isKeywordSeparator
bool LineParser::isKeywordSeparator(const QChar &ch)
{
return ch.isSpace()
|| (ch == QLatin1Char(':'))
|| (ch == QLatin1Char('/'))
|| (ch == QLatin1Char('*'));
}
示例4: nextToken
//-----------------------------------------------------------------------------
bool SqlTokenizer::nextToken()
{
sqlTokenStartM = sqlTokenEndM;
if (sqlTokenEndM == 0 || *sqlTokenEndM == 0)
{
sqlTokenTypeM = tkEOF;
return false;
}
// use QChar* member to scan
QChar c = *sqlTokenEndM;
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
keywordIdentifierToken();
else if (c == '"')
quotedIdentifierToken();
else if (c == '\'')
stringToken();
else if (c == '(')
symbolToken(tkPARENOPEN);
else if (c == ')')
symbolToken(tkPARENCLOSE);
else if (c == '=')
symbolToken(tkEQUALS);
else if (c == ',')
symbolToken(tkCOMMA);
else if (c == '/' && *(sqlTokenEndM + 1) == '*')
multilineCommentToken();
else if (c == '-' && *(sqlTokenEndM + 1) == '-')
singleLineCommentToken();
else if (c.isSpace())
whitespaceToken();
else
defaultToken();
return true;
}
示例5: trimWhiteSpace
/*
Transforms 'int x = 3 + 4' into 'int x=3+4'. A white space is kept
between 'int' and 'x' because it is meaningful in C++.
*/
static void trimWhiteSpace( QString& str )
{
enum { Normal, MetAlnum, MetSpace } state = Normal;
const int n = str.length();
int j = -1;
QChar *d = str.data();
for ( int i = 0; i != n; ++i ) {
const QChar c = d[i];
if ( c.isLetterOrNumber() ) {
if ( state == Normal ) {
state = MetAlnum;
} else {
if ( state == MetSpace )
str[++j] = c;
state = Normal;
}
str[++j] = c;
} else if ( c.isSpace() ) {
if ( state == MetAlnum )
state = MetSpace;
} else {
state = Normal;
str[++j] = c;
}
}
str.resize(++j);
}
示例6: scan
/**
* Split a line into lexemes.
*/
QStringList scan(const QString& lin)
{
QStringList result;
QString line = lin.trimmed();
if (line.isEmpty())
return result; // empty
QString lexeme;
const uint len = line.length();
bool inString = false;
for (uint i = 0; i < len; ++i) {
QChar c = line[i];
if (c == QLatin1Char('"')) {
lexeme += c;
if (inString) {
result.append(lexeme);
lexeme.clear();
}
inString = !inString;
} else if (inString ||
c.isLetterOrNumber() || c == QLatin1Char('_') || c == QLatin1Char('@')) {
lexeme += c;
} else {
if (!lexeme.isEmpty()) {
result.append(lexeme);
lexeme.clear();
}
if (! c.isSpace()) {
result.append(QString(c));
}
}
}
if (!lexeme.isEmpty())
result.append(lexeme);
return result;
}
示例7: validate
QValidator::State BitcoinAddressEntryValidator::validate(QString &input, int &pos) const
{
Q_UNUSED(pos);
// Empty address is "intermediate" input
if (input.isEmpty())
return QValidator::Intermediate;
// Correction
for (int idx = 0; idx < input.size();)
{
bool removeChar = false;
QChar ch = input.at(idx);
// Corrections made are very conservative on purpose, to avoid
// users unexpectedly getting away with typos that would normally
// be detected, and thus sending to the wrong address.
switch(ch.unicode())
{
// Qt categorizes these as "Other_Format" not "Separator_Space"
case 0x200B: // ZERO WIDTH SPACE
case 0xFEFF: // ZERO WIDTH NO-BREAK SPACE
removeChar = true;
break;
default:
break;
}
// Remove whitespace
if (ch.isSpace())
removeChar = true;
// To next character
if (removeChar)
input.remove(idx, 1);
else
++idx;
}
// Validation
QValidator::State state = QValidator::Acceptable;
for (int idx = 0; idx < input.size(); ++idx)
{
int ch = input.at(idx).unicode();
if (((ch >= '0' && ch<='9') ||
(ch >= 'a' && ch<='z') ||
(ch >= 'A' && ch<='Z') ||
(ch == ';')) &&//Allow for multiple address entries separated by a ;
ch != 'l' && ch != 'I' && ch != '0' && ch != 'O')
{
// Alphanumeric and not a 'forbidden' character
}
else
{
state = QValidator::Invalid;
}
}
return state;
}
示例8: keyPressEvent
void CodeEditor::keyPressEvent(QKeyEvent *event)
{
switch (event->key()) {
case Qt::Key_Return:
case Qt::Key_Enter:
{
QTextCursor tc = textCursor();
QString t = tc.block().text();
QString spaces;
QChar *data = t.data();
while (!data->isNull() && data->isSpace()) {
spaces.append(*data);
++data;
}
QPlainTextEdit::keyPressEvent(event);
insertPlainText(spaces);
}
break;
case Qt::Key_F1:
insertPlainText("\t");
break;
default:
QPlainTextEdit::keyPressEvent(event);
}
}
示例9: shouldInsertMatchingText
bool BraceMatcher::shouldInsertMatchingText(const QChar lookAhead) const
{
return lookAhead.isSpace()
|| isQuote(lookAhead)
|| isDelimiter(lookAhead)
|| isClosingBrace(lookAhead);
}
示例10: matchcharclass
static bool matchcharclass( uint *rxd, QChar c )
{
uint *d = rxd;
uint clcode = *d & MCD;
bool neg = clcode == CCN;
if ( clcode != CCL && clcode != CCN)
qWarning("QRegExp: Internal error, please report to [email protected]");
uint numFields = *d & MVL;
uint cval = (((uint)(c.row())) << 8) | ((uint)c.cell());
bool found = FALSE;
for ( int i = 0; i < (int)numFields; i++ ) {
d++;
if ( *d == PWS && c.isSpace() ) {
found = TRUE;
break;
}
if ( *d == PDG && c.isDigit() ) {
found = TRUE;
break;
}
else {
uint from = ( *d & MCD ) >> 16;
uint to = *d & MVL;
if ( (cval >= from) && (cval <= to) ) {
found = TRUE;
break;
}
}
}
return neg ? !found : found;
}
示例11: eventFilter
bool InputWidget::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() != QEvent::KeyPress)
return false;
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
// keys from BufferView should be sent to (and focus) the input line
BufferView *view = qobject_cast<BufferView *>(watched);
if (view) {
if (keyEvent->text().length() == 1 && !(keyEvent->modifiers() & (Qt::ControlModifier ^ Qt::AltModifier))) { // normal key press
QChar c = keyEvent->text().at(0);
if (c.isLetterOrNumber() || c.isSpace() || c.isPunct() || c.isSymbol()) {
setFocus();
QCoreApplication::sendEvent(inputLine(), keyEvent);
return true;
}
}
return false;
}
else if (watched == ui.inputEdit) {
if (keyEvent->matches(QKeySequence::Find)) {
QAction *act = GraphicalUi::actionCollection()->action("ToggleSearchBar");
if (act) {
act->toggle();
return true;
}
}
return false;
}
return false;
}
示例12: add
bool ChangeImportsVisitor::add(QmlJS::AST::UiProgram *ast, const Import &import)
{
setDidRewriting(false);
if (!ast)
return false;
if (ast->headers && ast->headers->headerItem) {
int insertionPoint = 0;
if (ast->members && ast->members->member)
insertionPoint = ast->members->member->firstSourceLocation().begin();
else
insertionPoint = m_source.length();
while (insertionPoint > 0) {
--insertionPoint;
const QChar c = m_source.at(insertionPoint);
if (!c.isSpace() && c != QLatin1Char(';'))
break;
}
replace(insertionPoint+1, 0, QStringLiteral("\n") + import.toImportString());
} else {
replace(0, 0, import.toImportString() + QStringLiteral("\n\n"));
}
setDidRewriting(true);
return true;
}
示例13: if
QList<QByteArray> KeymapParser::tokenize(const QByteArray &line)
{
bool quoted = false, separator = true;
QList<QByteArray> result;
QByteArray token;
for (int i = 0; i < line.length(); ++i) {
QChar c = line.at(i);
if (!quoted && c == '#' && separator)
break;
else if (!quoted && c == '"' && separator)
quoted = true;
else if (quoted && c == '"')
quoted = false;
else if (!quoted && c.isSpace()) {
separator = true;
if (!token.isEmpty()) {
result.append(token);
token.truncate(0);
}
}
else {
separator = false;
token.append(c);
}
}
if (!token.isEmpty())
result.append(token);
return result;
}
示例14: get
QString get(int type)
{
QChar current;
QString result;
passWhiteSpace();
while (true) {
current = next();
if (current.isNull()) {
break;
}
if (current.isSpace()) {
break;
}
bool number = isNumber(current);
if (type == GetDigit && !number) {
break;
}
if (type == GetString && number) {
break;
}
if(current == QLatin1Char( CONVERSION_CHAR )) {
break;
}
++m_index;
result += current;
}
return result;
}
示例15: validate
QValidator::State AddressValidator::validate( QString& string, int& pos ) const
{
Q_UNUSED( pos )
State result = QValidator::Acceptable;
if( mCodecId == ExpressionCoding )
{
string = string.trimmed();
if( ! expressionRegex.exactMatch(string) )
result = QValidator::Invalid;
//only prefix has been typed:
if( string == QStringLiteral("+")
|| string == QStringLiteral("-")
|| string.endsWith(QLatin1Char('x')) ) // 0x at end
result = QValidator::Intermediate;
}
else
{
const int stringLength = string.length();
for( int i=0; i<stringLength; ++i )
{
const QChar c = string.at( i );
if( !mValueCodec->isValidDigit( c.toLatin1() ) && !c.isSpace() )
{
result = QValidator::Invalid;
break;
}
}
}
if( string.isEmpty() )
result = QValidator::Intermediate;
return result;
}