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


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

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


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

示例1: doSanitizeKeyword

    QString doSanitizeKeyword(const QString &keyword) {
        QString allowed = QString(ALLOWED_SYMBOLS);
        int start = 0;
        int length = keyword.length();
        QChar c;
        while (start < length) {
            c = keyword.at(start);
            if (c.isLetterOrNumber() ||
                    allowed.contains(c) ||
                    c.category() == QChar::Symbol_Currency) {
                break;
            } else {
                start++;
            }
        }

        int end = length - 1;
        while (end >= 0) {
            c = keyword.at(end);
            if (c.isLetterOrNumber() ||
                    allowed.contains(c) ||
                    c.category() == QChar::Symbol_Currency) {
                break;
            } else {
                end--;
            }
        }

        QString result;
        if (start <= end) {
            result = keyword.mid(start, end - start + 1).simplified();
        }

        return result;
    }
开发者ID:Ribtoks,项目名称:xpiks,代码行数:35,代码来源:keywordshelpers.cpp

示例2: isIdentifierPart

static bool isIdentifierPart(QChar ch)
{
    // fast path for ascii
    if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') ||
        (ch.unicode() >= 'A' && ch.unicode() <= 'Z') ||
        (ch.unicode() >= '0' && ch.unicode() <= '9') ||
        ch == '$' || ch == '_' ||
        ch.unicode() == 0x200c /* ZWNJ */ || ch.unicode() == 0x200d /* ZWJ */)
        return true;

    switch (ch.category()) {
    case QChar::Mark_NonSpacing:
    case QChar::Mark_SpacingCombining:

    case QChar::Number_DecimalDigit:
    case QChar::Number_Letter:

    case QChar::Letter_Uppercase:
    case QChar::Letter_Lowercase:
    case QChar::Letter_Titlecase:
    case QChar::Letter_Modifier:
    case QChar::Letter_Other:

    case QChar::Punctuation_Connector:
        return true;
    default:
        break;
    }
    return false;
}
开发者ID:livecv,项目名称:livecv,代码行数:30,代码来源:qmljslexer.cpp

示例3: searchTargetFromScreen

 void searchTargetFromScreen(QEditor *editor, const QChar &target)
 {
   m_targetPos.clear();
   if (editor == NULL) {
     return;
   }
   m_currentGroup = 0;
   m_targetChar = target;
   QTextDocument *doc = editor->document();
   int cursorPos = editor->textCursor().position();
   QPair<int, int> visibleRange = getFirstAndLastVisiblePosition(editor);
   int  firstPos = visibleRange.first;
   int lastPos = visibleRange.second;
   bool notCaseSensative = target.category() != QChar::Letter_Uppercase;
   for (int offset = 1; cursorPos - offset >= firstPos || cursorPos + offset <= lastPos; offset++) {
     if (cursorPos + offset <= lastPos) {
       QChar c = doc->characterAt(cursorPos + offset);
       if (notCaseSensative) {
         c = c.toLower();
       }
       if (c == target) {
         m_targetPos << (cursorPos + offset);
       }
     }
     if (cursorPos - offset >= firstPos) {
       QChar c = doc->characterAt(cursorPos - offset);
       if (notCaseSensative) {
         c = c.toLower();
       }
       if (c == target) {
         m_targetPos << (cursorPos - offset);
       }
     }
   }
 }
开发者ID:kubaroth,项目名称:QtCreator-EasyMotion,代码行数:35,代码来源:easymotionplugin.cpp

示例4: vowels

int KNewPasswordWidget::KNewPasswordWidgetPrivate::effectivePasswordLength(const QString &password)
{
    enum Category {
        Digit,
        Upper,
        Vowel,
        Consonant,
        Special
    };

    Category previousCategory = Vowel;
    QString vowels(QStringLiteral("aeiou"));
    int count = 0;

    for (int i = 0; i < password.length(); ++i) {
        QChar currentChar = password.at(i);
        if (!password.leftRef(i).contains(currentChar)) {
            Category currentCategory;
            switch (currentChar.category()) {
            case QChar::Letter_Uppercase:
                currentCategory = Upper;
                break;
            case QChar::Letter_Lowercase:
                if (vowels.contains(currentChar)) {
                    currentCategory = Vowel;
                } else {
                    currentCategory = Consonant;
                }
                break;
            case QChar::Number_DecimalDigit:
                currentCategory = Digit;
                break;
            default:
                currentCategory = Special;
                break;
            }
            switch (currentCategory) {
            case Vowel:
                if (previousCategory != Consonant) {
                    ++count;
                }
                break;
            case Consonant:
                if (previousCategory != Vowel) {
                    ++count;
                }
                break;
            default:
                if (previousCategory != currentCategory) {
                    ++count;
                }
                break;
            }
            previousCategory = currentCategory;
        }
    }
    return count;
}
开发者ID:SpiritSPb,项目名称:kwidgetsaddons,代码行数:58,代码来源:knewpasswordwidget.cpp

示例5: formatCharacter

static void formatCharacter(QTextStream &str, const QChar &qc, FormattingContext &context)
{
    const ushort unicode = qc.unicode();
    str << "U+" << qSetFieldWidth(4) << qSetPadChar('0') << uppercasedigits << hex << unicode
        << dec << qSetFieldWidth(0) << ' ';

    const EnumLookup *specialChar = enumLookup(unicode, specialCharactersEnumLookup, sizeof(specialCharactersEnumLookup) / sizeof(EnumLookup));
    if (specialChar)
        str << specialChar->description;
    else
        str << "'" << qc << '\'';

    const int category = qc.category();
    if (category != context.category) {
        str << " category="
            << enumName(category, categoryEnumLookup, sizeof(categoryEnumLookup) / sizeof(EnumLookup));
        context.category = category;
    }
#if QT_VERSION >= 0x050100
    const int script = qc.script();
    if (script != context.script) {
        str << " script="
            << enumName(script, scriptEnumLookup, sizeof(scriptEnumLookup) / sizeof(EnumLookup))
            << '(' << script << ')';
        context.script = script;
    }
#endif // Qt 5
    const int direction = qc.direction();
    if (direction != context.direction) {
        str << " direction="
            << enumName(direction, directionEnumLookup, sizeof(directionEnumLookup) / sizeof(EnumLookup));
        context.direction = direction;
    }
#if QT_VERSION >= 0x050000
    const int joiningType = qc.joiningType();
    if (joiningType != context.joiningType) {
        str << " joiningType="
            << enumName(joiningType, joiningTypeEnumLookup, sizeof(joiningTypeEnumLookup) / sizeof(EnumLookup));
        context.joiningType = joiningType;
    }
#endif // Qt 5QWidget
    const int decompositionTag = qc.decompositionTag();
    if (decompositionTag != context.decompositionTag) {
        str << " decomposition="
            << enumName(decompositionTag, decompositionEnumLookup, sizeof(decompositionEnumLookup) / sizeof(EnumLookup));
        context.decompositionTag = decompositionTag;
    }
    const int unicodeVersion = qc.unicodeVersion();
    if (unicodeVersion != context.unicodeVersion) {
        str << " version="
        << enumName(unicodeVersion, unicodeVersionEnumLookup, sizeof(unicodeVersionEnumLookup) / sizeof(EnumLookup));
        context.unicodeVersion = unicodeVersion;
    }
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:54,代码来源:textdump.cpp

示例6:

QString Private::Converter::toPortablePath(const QString &path) const
{
    if (path.isEmpty() || m_baseDir.path().isEmpty())
        return path;

#ifdef Q_OS_WIN
    if (QDir::isAbsolutePath(path)) {
        QChar driveLeter = path[0].toUpper();
        QChar baseDriveLetter = m_baseDir.path()[0].toUpper();
        bool onSameDrive = (driveLeter.category() == QChar::Letter_Uppercase) && (driveLeter == baseDriveLetter);
        if (!onSameDrive)
            return path;
    }
#endif
    return m_baseDir.relativeFilePath(path);
}
开发者ID:ATGardner,项目名称:qBittorrent,代码行数:16,代码来源:profile_p.cpp

示例7: isValidKeyword

    bool isValidKeyword(const QString &keyword) {
        bool isValid = false;
        int length = keyword.length();

        if (2 <= length && length < 30) {
            isValid = true;
        }

        if (length == 1) {
            QChar symbol = keyword.at(0);
            if (symbol.isLetterOrNumber() ||
                    QString(ALLOWED_SYMBOLS).contains(symbol) ||
                    symbol.category() == QChar::Symbol_Currency) {
                isValid = true;
            }
        }

        return isValid;
    }
开发者ID:Ribtoks,项目名称:xpiks,代码行数:19,代码来源:keywordshelpers.cpp

示例8: isIdentifierStart

static inline bool isIdentifierStart(QChar ch)
{
    // fast path for ascii
    if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') ||
        (ch.unicode() >= 'A' && ch.unicode() <= 'Z') ||
        ch == '$' || ch == '_')
        return true;

    switch (ch.category()) {
    case QChar::Number_Letter:
    case QChar::Letter_Uppercase:
    case QChar::Letter_Lowercase:
    case QChar::Letter_Titlecase:
    case QChar::Letter_Modifier:
    case QChar::Letter_Other:
        return true;
    default:
        break;
    }
    return false;
}
开发者ID:livecv,项目名称:livecv,代码行数:21,代码来源:qmljslexer.cpp

示例9: getToken

Token* Tokenizer::getToken()
{
	int startRow = row;
	int startCol = col;

	QChar c = getChar();  // get and store the next character from the string

	// catch the end of the input string
	if (atEnd)
		return new Token(Token::EndOfInput, "END", row, col, row, col);

	int cType = translator->look2type(c);  // since we need to know it often we store it

	// catch spaces
	if (isSpace(c)) {
		QString look;
		do {
			look += (isTab(c) ? "  " : " ");
			c = getChar();
		} while (isSpace(c) && !atEnd);
		ungetChar();
		return new Token(Token::WhiteSpace, look, startRow, startCol, row, col);
	}

	// catch EndOfLine's
	if (isBreak(c)) {
		return new Token(Token::EndOfLine, "\\n", startRow, startCol, startRow+1, 1);
	}

	// catch comments
	if (cType == Token::Comment) {
		QString look;
		do {
			look += c;
			c = getChar();
		} while (!isBreak(c) && !atEnd);
		ungetChar();
		return new Token(Token::Comment, look, startRow, startCol, row, col);
	}

	// catch strings
	if (cType == Token::StringDelimiter) {
		QString look = QString(c);
		do {
			c = getChar();
			look += c;
		} while (!(translator->look2type(c) == Token::StringDelimiter && look.right(2) != "\\\"") &&
		         !isBreak(c) && !atEnd);
		return new Token(Token::String, look, startRow, startCol, row, col);
	}

	// catch variables
	if (cType == Token::VariablePrefix) {
		QString look;
		do {
			look += c;
			c = getChar();
		} while (isWordChar(c) || c.category() == QChar::Number_DecimalDigit || c == '_');
		ungetChar();
		return new Token(Token::Variable, look, startRow, startCol, row, col);
	}

	// catch words (known commands or function calls)
	if (isWordChar(c)) {  // first char has to be a letter
		QString look;
		do {
			look += c;
			c = getChar();
		} while (isWordChar(c) || c.isDigit() || c == '_');  // next chars
		ungetChar();
		int type = translator->look2type(look);
		if (type == Token::Unknown)
			type = Token::FunctionCall;
		return new Token(type, look, startRow, startCol, row, col);
	}

	// catch numbers
	if (c.isDigit() || cType == Token::DecimalSeparator) {
		bool hasDot = false;

		int localType = cType;
		QString look;
		do {
			if (localType == Token::DecimalSeparator) hasDot = true;
			look += c;
			c = getChar();
			localType = translator->look2type(c);
		} while (c.isDigit() || (localType == Token::DecimalSeparator && !hasDot));
		ungetChar();
		
		// if all we got is a dot then this is not a number, so return an Error token here
		if (translator->look2type(look) == Token::DecimalSeparator)
			return new Token(Token::Error, look, startRow, startCol, row, col);
		
		return new Token(Token::Number, look, startRow, startCol, row, col);
	}

	// catch previously uncatched 'double charactered tokens' (tokens that ar not in letters, like: == != >= <=)
	{
		QString look = QString(c).append(getChar());
//.........这里部分代码省略.........
开发者ID:garvitdelhi,项目名称:kturtle,代码行数:101,代码来源:tokenizer.cpp

示例10: isSpace

bool Tokenizer::isSpace(const QChar& c)
{
	return (c.category() == QChar::Separator_Space || c == ' ' || isTab(c));
}
开发者ID:garvitdelhi,项目名称:kturtle,代码行数:4,代码来源:tokenizer.cpp

示例11: formattedString

/**
 * \sa format()
 * \sa setFormat(const QString&)
 */
QString AbstractStringAppender::formattedString(const QDateTime& timeStamp, Logger::LogLevel logLevel, const char* file,
                                                int line, const char* function, const QString& category, const QString& message) const
{
  QString f = format();
  const int size = f.size();

  QString result;

  int i = 0;
  while (i < f.size())
  {
    QChar c = f.at(i);

    // We will silently ignore the broken % marker at the end of string
    if (c != QLatin1Char(formattingMarker) || (i + 2) >= size)
    {
      result.append(c);
    }
    else
    {
      i += 2;
      QChar currentChar = f.at(i);
      QString command;
      int fieldWidth = 0;

      if (currentChar.isLetter())
      {
        command.append(currentChar);
        int j = 1;
        while ((i + j) < size && f.at(i + j).isLetter())
        {
          command.append(f.at(i+j));
          j++;
        }

        i+=j;
        currentChar = f.at(i);

        // Check for the padding instruction
        if (currentChar == QLatin1Char(':'))
        {
          currentChar = f.at(++i);
          if (currentChar.isDigit() || currentChar.category() == QChar::Punctuation_Dash)
          {
            int j = 1;
            while ((i + j) < size && f.at(i + j).isDigit())
              j++;
            fieldWidth = f.mid(i, j).toInt();

            i += j;
          }
        }
      }

      // Log record chunk to insert instead of formatting instruction
      QString chunk;

      // Time stamp
      if (command == QLatin1String("time"))
      {
        if (f.at(i + 1) == QLatin1Char('{'))
        {
          int j = 1;
          while ((i + 2 + j) < size && f.at(i + 2 + j) != QLatin1Char('}'))
            j++;

          if ((i + 2 + j) < size)
          {
            chunk = timeStamp.toString(f.mid(i + 2, j));

            i += j;
            i += 2;
          }
        }

        if (chunk.isNull())
          chunk = timeStamp.toString(QLatin1String("HH:mm:ss.zzz"));
      }

      // Log level
      else if (command == QLatin1String("type"))
        chunk = Logger::levelToString(logLevel);

      // Uppercased log level
      else if (command == QLatin1String("Type"))
        chunk = Logger::levelToString(logLevel).toUpper();

      // One letter log level
      else if (command == QLatin1String("typeOne"))
          chunk = Logger::levelToString(logLevel).left(1).toLower();

      // One uppercase letter log level
      else if (command == QLatin1String("TypeOne"))
          chunk = Logger::levelToString(logLevel).left(1).toUpper();

      // Filename
//.........这里部分代码省略.........
开发者ID:Kirek,项目名称:deepin-session-ui-manjaro,代码行数:101,代码来源:AbstractStringAppender.cpp

示例12: isEndOfWordChar

static bool isEndOfWordChar(const QChar &c)
{
    return !c.isLetterOrNumber() && c.category() != QChar::Punctuation_Connector;
}
开发者ID:AltarBeastiful,项目名称:qt-creator,代码行数:4,代码来源:completingtextedit.cpp

示例13: if

void
Main_GUI::check_number_set()
{
  QString text = snapping_line->text();
  QString qs;

  // construct ASCII string from arbitrary Unicode data;
  // the idea is to accept, say, CJK fullwidth digits also
  for (int i = 0; i < text.size(); i++)
  {
    QChar c = text.at(i);

    int digit = c.digitValue();
    if (digit >= 0)
      qs += QString::number(digit);
    else if (c.isSpace())
      qs += ' ';
    // U+30FC KATAGANA-HIRAGANA PROLONGED SOUND MARK is assigned
    // to the `-' key in some Japanese input methods
    else if (c.category() == QChar::Punctuation_Dash
             || c == QChar(0x30FC))
      qs += '-';
    // various Unicode COMMA characters,
    // including representation forms
    else if (c == QChar(',')
             || c == QChar(0x055D)
             || c == QChar(0x060C)
             || c == QChar(0x07F8)
             || c == QChar(0x1363)
             || c == QChar(0x1802)
             || c == QChar(0x1808)
             || c == QChar(0x3001)
             || c == QChar(0xA4FE)
             || c == QChar(0xA60D)
             || c == QChar(0xA6F5)
             || c == QChar(0xFE10)
             || c == QChar(0xFE11)
             || c == QChar(0xFE50)
             || c == QChar(0xFE51)
             || c == QChar(0xFF0C)
             || c == QChar(0xFF64))
      qs += ',';
    else
      qs += c; // we do error handling below
  }

  if (x_height_snapping_exceptions)
    number_set_free(x_height_snapping_exceptions);

  QByteArray str = qs.toLocal8Bit();
  const char* s = number_set_parse(str.constData(),
                                   &x_height_snapping_exceptions,
                                   6, 0x7FFF);
  if (s && *s)
  {
    statusBar()->setStyleSheet("color: red;");
    if (x_height_snapping_exceptions == NUMBERSET_ALLOCATION_ERROR)
      statusBar()->showMessage(
        tr("allocation error"));
    else if (x_height_snapping_exceptions == NUMBERSET_INVALID_CHARACTER)
      statusBar()->showMessage(
        tr("invalid character (use digits, dashes, commas, and spaces)"));
    else if (x_height_snapping_exceptions == NUMBERSET_OVERFLOW)
      statusBar()->showMessage(
        tr("overflow"));
    else if (x_height_snapping_exceptions == NUMBERSET_INVALID_RANGE)
      statusBar()->showMessage(
        tr("invalid range (minimum is 6, maximum is 32767)"));
    else if (x_height_snapping_exceptions == NUMBERSET_OVERLAPPING_RANGES)
      statusBar()->showMessage(
        tr("overlapping ranges"));
    else if (x_height_snapping_exceptions == NUMBERSET_NOT_ASCENDING)
      statusBar()->showMessage(
        tr("values und ranges must be specified in ascending order"));

    snapping_line->setText(qs);
    snapping_line->setFocus(Qt::OtherFocusReason);
    snapping_line->setCursorPosition(s - str.constData());

    x_height_snapping_exceptions = NULL;
  }
  else
  {
    // normalize if there is no error
    char* new_str = number_set_show(x_height_snapping_exceptions,
                                    6, 0x7FFF);
    snapping_line->setText(new_str);
    free(new_str);
  }
}
开发者ID:Youscribe,项目名称:ttfautohint,代码行数:90,代码来源:maingui.cpp

示例14: isSentenceSeparator

static inline bool isSentenceSeparator(const QChar &character)
{
    return character.isMark() || character.isPunct() || character.category() == QChar::Separator_Paragraph;
}
开发者ID:Chocimier,项目名称:otter-browser,代码行数:4,代码来源:textbreaks.cpp


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