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


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

本文整理汇总了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];
    }
  }
开发者ID:FractalBobz,项目名称:kmuddy,代码行数:33,代码来源:ccmdparser.cpp

示例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;
}
开发者ID:Vavooon,项目名称:SweetDisplayStandby,代码行数:59,代码来源:sweetdisplaystandby.cpp

示例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
}
开发者ID:0TheFox0,项目名称:MayaOpenRPT,代码行数:8,代码来源:code128.cpp

示例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();
}
开发者ID:HoS0,项目名称:DesktopManager,代码行数:58,代码来源:qjson.cpp

示例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;
        }
    }
}
开发者ID:Kakadu,项目名称:qtcreator-ocaml-plugin,代码行数:12,代码来源:RubyScanner.cpp

示例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;
}
开发者ID:BackupTheBerlios,项目名称:sim-im-svn,代码行数:48,代码来源:datepicker.cpp

示例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
    }
开发者ID:wulff007,项目名称:Veda,代码行数:29,代码来源:securitygroup.cpp

示例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);
	}
开发者ID:ForNeVeR,项目名称:leechcraft,代码行数:60,代码来源:channelhandler.cpp

示例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;
}
开发者ID:KDE,项目名称:okteta,代码行数:33,代码来源:addressvalidator.cpp

示例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;
}
开发者ID:sixthfore,项目名称:CTK,代码行数:28,代码来源:ctkLDAPExpr.cpp

示例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();
}
开发者ID:pvuorela,项目名称:kcalcore,代码行数:35,代码来源:linklocator.cpp

示例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;
}
开发者ID:skriticos,项目名称:timetrack,代码行数:25,代码来源:ipcmsg.cpp

示例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;
}
开发者ID:DavidWittman,项目名称:yubikey-personalization-gui,代码行数:27,代码来源:scanedit.cpp

示例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
}
开发者ID:jassuncao,项目名称:myparts,代码行数:7,代码来源:quickaddcapacitordialog.cpp

示例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;
	}
}
开发者ID:amottola,项目名称:slew,代码行数:35,代码来源:format.cpp


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