本文整理汇总了C++中QChar::toLatin1方法的典型用法代码示例。如果您正苦于以下问题:C++ QChar::toLatin1方法的具体用法?C++ QChar::toLatin1怎么用?C++ QChar::toLatin1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QChar
的用法示例。
在下文中一共展示了QChar::toLatin1方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expandBackslashes
void cCmdParser::expandBackslashes (QString &command)
{
//do nothing if we don't want to expand here
if (!expandbackslashes)
return;
QString cmd = "";
bool backslash = false;
int len = command.length();
for (int i = 0; i < len; i++)
{
QChar ch = command[i];
if (backslash)
{
if (ch.toLatin1() == 't') //got \t
cmd += (QChar) '\t';
else if (ch.toLatin1() == 'e') //got \e
cmd += (QChar) '\e';
else if ((ch.toLatin1() == 'm') && (i == 1)) //got \m on the beginning of the string
cmd += (QChar) 0x02;
else
cmd += ch;
backslash = false;
}
else
{
if (ch == QChar ('\\'))
backslash = true;
else
cmd += command[i];
}
}
示例2: rx
QList<int> SweetDisplayStandby::getVirtualKey(QKeySequence keySequence)
{
QList<int> keys;
if ( !keySequence.toString().size() )
{
return keys;
}
QString sequenceString = keySequence.toString();
QRegExp rx("\\+");
QStringList query = sequenceString.split(rx);
uint modifiers=0;
int i = 0, vk =-1;
for (; i <query.length()-1; i++ )
{
if( query[i] == "Ctrl" )
{
modifiers |= MOD_CONTROL;
}
else if( query[i] == "Alt" )
{
modifiers |= MOD_ALT;
}
else if( query[i] == "Shift" )
{
modifiers |= MOD_SHIFT;
}
else if( query[i] == "Meta" )
{
modifiers |= MOD_WIN;
}
}
QString lastKey = query[i];
QRegExp frx ( "^F(\\d+)$"); // F group keys
QRegExp drx ( "^(\\d)$"); //digits
QRegExp lrx ( "^([A-Z])$"); //capital letters
frx.indexIn(lastKey);
drx.indexIn(lastKey);
lrx.indexIn(lastKey);
if (frx.capturedTexts()[1].length())
{
vk += VK_F1 + frx.capturedTexts()[1].toInt();
}
else if (drx.capturedTexts()[1].length())
{
QChar c = drx.capturedTexts()[1][0];
vk = c.toLatin1();
}
else if (lrx.capturedTexts()[1].length())
{
QChar c = lrx.capturedTexts()[1][0];
vk = c.toLatin1();
}
keys.append(modifiers);
keys.append(vk);
return keys;
}
示例3: code128Index
int code128Index(QChar code, int set) {
for(int idx = 0; _128codes[idx]._null == false; idx++) {
if(set == SETA && _128codes[idx].codea == code.toLatin1()) return idx;
if(set == SETB && _128codes[idx].codeb == code.toLatin1()) return idx;
if(set == SETC && _128codes[idx].codec == code.toLatin1()) return idx;
}
return -1; // couldn't find it
}
示例4: parseString
QVariant QJson::parseString(const QString &json, int &index, bool &success, QString *errorMessage)
{
Q_ASSERT(json[index] == '"');
index++;
QString string;
QChar ch;
while (checkAvailable(json, index, success, errorMessage))
{
ch = json[index++];
switch (ch.toLatin1())
{
case '\\':
// Escaped character
if (!checkAvailable(json, index, success, errorMessage))
return QVariant();
ch = json[index++];
switch (ch.toLatin1())
{
case 'b':
string.append('\b');
break;
case 'f':
string.append('\f');
break;
case 'n':
string.append('\n');
break;
case 'r':
string.append('\r');
break;
case 't':
string.append('\t');
break;
case 'u':
if (!checkAvailable(json, index, success, errorMessage, 4))
return QVariant();
string.append(QChar(json.mid(index, 4).toInt(0, 16)));
index += 4;
break;
default:
string.append(ch);
}
break;
case '"':
// End of string
return QVariant(string);
default:
string.append(ch);
}
}
return QVariant();
}
示例5: consumeUntil
void Scanner::consumeUntil(const char* stopAt, const char* stopAfter)
{
QChar ch = m_src.peek();
while (!ch.isNull() && !ch.isSpace() && !std::strchr(stopAt, ch.toLatin1())) {
m_src.move();
ch = m_src.peek();
if (stopAfter && !ch.isNull() && std::strchr(stopAfter, ch.toLatin1())) {
m_src.move();
break;
}
}
}
示例6: parseDate
static bool parseDate(const QString &str, int &day, int &month, int &year)
{
day = 0;
month = 0;
year = 0;
int p;
for (p = 0; p < (int)(str.length()); p++){
QChar cc = str[p];
char c = cc.toLatin1();
if (c == '_')
continue;
if ((c < '0') || (c > '9')){
p++;
break;
}
day = day * 10 + (c - '0');
}
for (; p < (int)(str.length()); p++){
QChar cc = str[p];
char c = cc.toLatin1();
if (c == '_')
continue;
if ((c < '0') || (c > '9')){
p++;
break;
}
month = month * 10 + (c - '0');
}
for (; p < (int)(str.length()); p++){
QChar cc = str[p];
char c = cc.toLatin1();
if (c == '_')
continue;
if ((c < '0') || (c > '9'))
return false;
year = year * 10 + (c - '0');
}
if (year < 1000) { /* Year must have 4 digits ! */
year = 0;
return true;
}
if (day && month && year){
QDate d(year, month, day);
if (d.isNull())
return false;
}
return true;
}
示例7: parseId
void SecurityGroup::parseId()
{
QString p = id();
m_belowLevelGroups.clear();
m_rootName.clear();
while(!p.isEmpty()) {
QString pi = p.section(Constants::S_DELIMITER,0,0);
if (m_rootName.isEmpty()) {
m_rootName = pi;
} else {
m_belowLevelGroups.append(pi);
}
p.remove(0, pi.length() + 1);
}
QString str = id().toLower();
QChar c;
m_uniquaId = 0;
foreach(c, str) {
#if QT_VERSION < 0x050000
m_uniquaId += c.toAscii();
#else
m_uniquaId += c.toLatin1();
#endif
}
示例8: SetChannelUser
void ChannelHandler::SetChannelUser (const QString& nick,
const QString& user, const QString& host)
{
QString nickName = nick;
bool hasRole = false;
QChar roleSign;
if (CM_->GetISupport ().contains ("PREFIX"))
{
const QStringList& prefixList = CM_->GetISupport () ["PREFIX"].split (')');
int id = prefixList.value (1).indexOf (nick [0]);
if (id != -1)
{
hasRole = true;
nickName = nickName.mid (1);
roleSign = prefixList.at (0) [id + 1];
}
}
CM_->ClosePrivateChat (nickName);
const auto existed = Nick2Entry_.contains (nickName);
ChannelParticipantEntry_ptr entry (GetParticipantEntry (nickName, false));
entry->SetUserName (user);
entry->SetHostName (host);
ChannelRole role;
if (hasRole)
switch (roleSign.toLatin1 ())
{
case 'v':
role = ChannelRole::Voiced;
break;
case 'h':
role = ChannelRole::HalfOperator;
break;
case 'o':
role = ChannelRole::Operator;
break;
case 'a':
role = ChannelRole::Admin;
break;
case 'q':
role = ChannelRole::Owner;
break;
default:
role = ChannelRole::Participant;
}
else
role = ChannelRole::Participant;
entry->SetRole (role);
entry->SetStatus (EntryStatus (SOnline, QString ()));
if (!existed)
CM_->GetAccount ()->handleGotRosterItems ({ entry.get () });
MakeJoinMessage (nickName);
}
示例9: 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;
}
示例10: while
const QString ctkLDAPExpr::ParseState::getAttributeValue()
{
QString sb;
bool exit = false;
while( !exit ) {
QChar c = peek( );
switch(c.toLatin1()) {
case '(':
case ')':
exit = true;
break;
case '*':
sb.append(WILDCARD);
break;
case '\\':
sb.append(m_str.at(++m_pos));
break;
default:
sb.append(c);
break;
}
if ( !exit )
{
m_pos++;
}
}
return sb;
}
示例11: highlightedText
QString LinkLocator::highlightedText()
{
// formating symbols must be prepended with a whitespace
if ( ( mPos > 0 ) && !mText[mPos-1].isSpace() ) {
return QString();
}
const QChar ch = mText[mPos];
if ( ch != '/' && ch != '*' && ch != '_' && ch != '-' ) {
return QString();
}
QRegExp re =
QRegExp( QString( "\\%1((\\w+)([\\s-']\\w+)*( ?[,.:\\?!;])?)\\%2" ).arg( ch ).arg( ch ) );
re.setMinimal( true );
if ( re.indexIn( mText, mPos ) == mPos ) {
int length = re.matchedLength();
// there must be a whitespace after the closing formating symbol
if ( mPos + length < mText.length() && !mText[mPos + length].isSpace() ) {
return QString();
}
mPos += length - 1;
switch ( ch.toLatin1() ) {
case '*':
return "<b>*" + re.cap( 1 ) + "*</b>";
case '_':
return "<u>_" + re.cap( 1 ) + "_</u>";
case '/':
return "<i>/" + re.cap( 1 ) + "/</i>";
case '-':
return "<strike>-" + re.cap( 1 ) + "-</strike>";
}
}
return QString();
}
示例12: sendMessage
void IpcMsg::sendMessage(QString msg)
{
auto shm = new QSharedMemory("TimeTrackShm");
shm->attach();
shm->lock();
// send the message
char *to = (char*)shm->data();
QChar *data = msg.data();
while(!data->isNull()){
memset(to, data->toLatin1(), 1);
++data;
++to;
}
memset(to, 0, 1);
shm->unlock();
delete shm;
// unlock the listener
auto sem = new QSystemSemaphore(
"TimeTrackSem", 0, QSystemSemaphore::Open);
sem->release();
delete sem;
}
示例13: textToScanCodes
QString ScanEdit::textToScanCodes(const QString text) {
QString scanCode;
for(int i = 0; i < text.length(); i++) {
QChar ch = text.at(i).toLatin1();
unsigned char code = 0;
if(ch == '\\') {
if(i + 1 != text.length()) {
QChar next = text.at(i + 1).toLatin1();
if(next == '\\') {
i++;
} else if(next == 't') {
i++;
code = TAB;
} else if(next == 'n') {
i++;
code = RETURN;
}
}
}
if(code == 0) {
code = key2usb[(int)ch.toLatin1()];
}
QString hexTxt = YubiKeyUtil::qstrHexEncode(&code, 1);
scanCode += hexTxt;
}
return scanCode;
}
示例14: to_char
inline char to_char(QChar c){
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
return c.toLatin1();
#else
return c.toAscii();
#endif
}
示例15:
static bool
isSeparator(const QChar& c)
{
switch (c.toLatin1()) {
case '.':
case ',':
case '?':
case '!':
case ':':
case ';':
case '-':
case '<':
case '>':
case '[':
case ']':
case '(':
case ')':
case '{':
case '}':
case '=':
case '/':
case '+':
case '%':
case '&':
case '^':
case '*':
case '\'':
case '"':
case '~':
case '|':
return true;
default:
return false;
}
}