本文整理汇总了C++中qstring::const_iterator::toLower方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::toLower方法的具体用法?C++ const_iterator::toLower怎么用?C++ const_iterator::toLower使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qstring::const_iterator
的用法示例。
在下文中一共展示了const_iterator::toLower方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: guessKeyFromText
// static
ChromaticKey KeyUtils::guessKeyFromText(const QString& text) {
QString trimmed = text.trimmed();
// Try using the user's custom notation.
{
QMutexLocker locker(&s_notationMutex);
QMap<QString, ChromaticKey>::const_iterator it = s_reverseNotation.find(text);
if (it != s_reverseNotation.end()) {
return it.value();
}
}
QRegExp openKeyMatcher(s_openKeyPattern, Qt::CaseInsensitive);
if (openKeyMatcher.exactMatch(trimmed)) {
bool ok = false;
int openKeyNumber = openKeyMatcher.cap(1).toInt(&ok);
// Regex should mean this never happens.
if (!ok || openKeyNumber < 1 || openKeyNumber > 12) {
return mixxx::track::io::key::INVALID;
}
bool major = openKeyMatcher.cap(2)
.compare("d", Qt::CaseInsensitive) == 0;
return openKeyNumberToKey(openKeyNumber, major);
}
QRegExp lancelotKeyMatcher(s_lancelotKeyPattern, Qt::CaseInsensitive);
if (lancelotKeyMatcher.exactMatch(trimmed)) {
bool ok = false;
int lancelotNumber = lancelotKeyMatcher.cap(1).toInt(&ok);
// Regex should mean this never happens.
if (!ok || lancelotNumber < 1 || lancelotNumber > 12) {
return mixxx::track::io::key::INVALID;
}
int openKeyNumber = lancelotNumberToOpenKeyNumber(lancelotNumber);
bool major = lancelotKeyMatcher.cap(2)
.compare("b", Qt::CaseInsensitive) == 0;
return openKeyNumberToKey(openKeyNumber, major);
}
QRegExp keyMatcher(s_keyPattern, Qt::CaseInsensitive);
if (keyMatcher.exactMatch(trimmed)) {
// Take the first letter, lowercase it and subtract 'a' and we get a
// number between 0-6. Look up the major key associated with that letter
// from s_letterToMajorKey. Upper-case means major, lower-case means
// minor. Then apply the sharps or flats to the key.
QChar letter = keyMatcher.cap(1).at(0);
int letterIndex = letter.toLower().toAscii() - 'a';
bool major = letter.isUpper();
// Now apply sharps and flats to the letter key.
QString adjustments = keyMatcher.cap(2);
int steps = 0;
for (QString::const_iterator it = adjustments.begin();
it != adjustments.end(); ++it) {
// An m only comes at the end and
if (it->toLower() == 'm') {
major = false;
break;
}
steps += (*it == '#' || *it == s_sharpSymbol[0]) ? 1 : -1;
}
ChromaticKey letterKey = static_cast<ChromaticKey>(
s_letterToMajorKey[letterIndex] + (major ? 0 : 12));
return scaleKeySteps(letterKey, steps);
}
// We didn't figure out the key. Womp womp.
return mixxx::track::io::key::INVALID;
}