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


C++ KviCString::cutToFirst方法代码示例

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


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

示例1: setContentFromEditor

	void KviVariantTableItem::setContentFromEditor(QWidget * w)
	{
		switch(m_property.type())
		{
			case QVariant::String:
				m_property = QVariant(((QLineEdit *)w)->text());
			break;
			case QVariant::Int:
				m_property = QVariant(((QLineEdit *)w)->text().toInt());
			break;
			case QVariant::UInt:
				m_property = QVariant(((QLineEdit *)w)->text().toUInt());
			break;
			case QVariant::Bool:
				m_property = QVariant(((QComboBox *)w)->currentItem(),1);
			break;
			case QVariant::Color:
				m_property.asColor().setNamedColor(((QLineEdit *)w)->text());
			break;
			case QVariant::Font:
			{
				KviCString txt = ((QComboBox *)w)->currentText();
				if(txt.hasData())
				{
					KviCString fam = txt;
					fam.cutFromFirst(',',true);
					fam.trimmed();
					KviCString psz = txt;
					psz.cutToFirst(',',true);
					psz.trimmed();
					bool bOk;
					unsigned int uSize = psz.toUInt(&bOk);
					if(!bOk)uSize = 12;
					m_property = QVariant(QFont(fam.ptr(),uSize));
				}
			}
			break;
			default:
			break;
		}
	}
开发者ID:netrunner-debian-kde-extras,项目名称:kvirc,代码行数:41,代码来源:canvaswidget.cpp

示例2: fi

LogFile::LogFile(const QString & szName)
{
    m_szFilename = szName;

    QFileInfo fi(m_szFilename);
    QString szTmpName = fi.fileName();

    m_bCompressed = (fi.suffix() == "gz");
    if(m_bCompressed)
    {
        //removes trailing dot and extension
        szTmpName.chop(3);
    }
    QString szTypeToken = szTmpName.section('_',0,0);
    // Ignore non-logs files, this includes '.' and '..'
    if(KviQString::equalCI(szTypeToken,"channel") || KviQString::equalCI(szTypeToken,"deadchannel"))
    {
        m_szType = "channel";
        m_eType = Channel;
    } else if(KviQString::equalCI(szTypeToken,"console"))
    {
        m_szType = "console";
        m_eType = Console;
    } else if(KviQString::equalCI(szTypeToken,"query"))
    {
        m_szType = "query";
        m_eType = Query;
    } else if(KviQString::equalCI(szTypeToken,"dccchat"))
    {
        m_szType = "dccchat";
        m_eType = DccChat;
    } else {
        m_szType = "";
        m_eType = Other;
    }

    KviCString szUndecoded = szTmpName.section('.',0,0);
    szUndecoded.cutToFirst('_');
    m_szName = szUndecoded.hexDecode(szUndecoded.ptr()).ptr();

    szUndecoded = szTmpName.section('.',1).section('_',0,-2);
    m_szNetwork = szUndecoded.hexDecode(szUndecoded.ptr()).ptr();

    QString szDate = szTmpName.section('_',-1).section('.',0,-2);

    switch(KVI_OPTION_UINT(KviOption_uintOutputDatetimeFormat))
    {
    case 1:
        m_date = QDate::fromString(szDate, Qt::ISODate);
        break;
    case 2:
        m_date = QDate::fromString(szDate, Qt::SystemLocaleShortDate);
        if(!m_date.isValid())
        {
            // some locale date formats use '/' as a separator; we change them to '-'
            // when creating log files. Try to reverse that change here
            QString szUnescapedDate = szDate;
            szUnescapedDate.replace('-', KVI_PATH_SEPARATOR_CHAR);
            m_date = QDate::fromString(szUnescapedDate, Qt::SystemLocaleShortDate);
            if(m_date.isValid())
            {
                //qt4 defaults to 1900 for years. So "11" means "1911" instead of "2011".. what a pity
                if(m_date.year() < 1990)
                    m_date = m_date.addYears(100);
            }
        }
        break;
    case 0:
    default:
        m_date = QDate::fromString(szDate, "yyyy.MM.dd");
        break;
    }
    if(!m_date.isValid())
    {
        // probably the log has been created when the OutputDatetimeFormat option
        // was set to a different value. Try to guess its format
        m_date = QDate::fromString(szDate, "yyyy.MM.dd");
        if(!m_date.isValid())
        {
            m_date = QDate::fromString(szDate, Qt::ISODate);
            if(!m_date.isValid())
            {
                m_date = QDate::fromString(szDate, Qt::SystemLocaleShortDate);
                if(!m_date.isValid())
                {
                    // some locale date formats use '/' as a separator; we change them to '-'
                    // when creating log files. Try to reverse that change here
                    QString szUnescapedDate = szDate;
                    szUnescapedDate.replace('-', KVI_PATH_SEPARATOR_CHAR);
                    m_date = QDate::fromString(szUnescapedDate, Qt::SystemLocaleShortDate);
                    if(m_date.isValid())
                    {
                        //qt4 defaults to 1900 for years. So "11" means "1911" instead of "2011".. what a pity
                        if(m_date.year() < 1990)
                            m_date = m_date.addYears(100);
                    }
                }
                // if the date is still not valid, we give up
            }
        }
//.........这里部分代码省略.........
开发者ID:kartagis,项目名称:KVIrc,代码行数:101,代码来源:LogFile.cpp

示例3: processHeader

bool KviHttpRequest::processHeader(KviCString &szHeader)
{
	int idx = szHeader.findFirstIdx("\r\n");
	KviCString szResponse;
	if(idx != -1)
	{
		szResponse = szHeader.left(idx);
		szHeader.cutLeft(idx + 2);
	} else {
		szResponse = szHeader;
		szHeader = "";
	}

	szResponse.trim();

	bool bValid = false;

	unsigned int uStatus = 0;

	// check the response value
	if(kvi_strEqualCSN(szResponse.ptr(),"HTTP",4))
	{
		KviCString szR = szResponse;
		szR.cutToFirst(' ');
		szR.trim();
		int idx = szR.findFirstIdx(' ');
		KviCString szNumber;
		if(idx != -1)szNumber = szR.left(idx);
		else szNumber = szR;
		bool bOk;
		uStatus = szNumber.toUInt(&bOk);
		if(bOk)bValid = true;
	}

	QString szUniResponse = QString::fromUtf8(szResponse.ptr());

	if(!bValid)
	{
		// the response is invalid ?
		resetInternalStatus();
		m_szLastError = __tr2qs("Invalid HTTP response: %1").arg(szUniResponse);
		emit terminated(false);
		return false;
	}

	emit status(__tr2qs("Received HTTP response: %1").arg(szUniResponse));

	KviPointerList<KviCString> hlist;
	hlist.setAutoDelete(true);

	idx = szHeader.findFirstIdx("\r\n");
	while(idx != -1)
	{
		if(idx > 0)
		{
			hlist.append(new KviCString(szHeader.ptr(),idx));
			szHeader.cutLeft(idx + 2);
		}
		idx = szHeader.findFirstIdx("\r\n");
	}
	if(szHeader.hasData())hlist.append(new KviCString(szHeader));

	KviPointerHashTable<const char *,KviCString> hdr(11,false,true);
	hdr.setAutoDelete(true);

	for(KviCString * s = hlist.first();s;s = hlist.next())
	{
		idx = s->findFirstIdx(":");
		if(idx != -1)
		{
			KviCString szName = s->left(idx);
			s->cutLeft(idx + 1);
			s->trim();
			hdr.replace(szName.ptr(),new KviCString(*s));
			//qDebug("FOUND HEADER (%s)=(%s)",szName.ptr(),s->ptr());
		}
	}

	KviCString * size = hdr.find("Content-length");
	if(size)
	{
		bool bOk;
		m_uTotalSize = size->toUInt(&bOk);
		if(!bOk)m_uTotalSize = 0;
	}

	KviCString * contentEncoding = hdr.find("Content-encoding");
	if(contentEncoding)
	{
		m_bGzip = contentEncoding->equalsCI("gzip");
	}

	KviCString * transferEncoding = hdr.find("Transfer-Encoding");
	if(transferEncoding)
	{
		if(kvi_strEqualCI(transferEncoding->ptr(),"chunked"))
		{
			// be prepared to handle the chunked transfer encoding as required by HTTP/1.1
			m_bChunkedTransferEncoding = true;
			m_uRemainingChunkSize = 0;
//.........这里部分代码省略.........
开发者ID:kartagis,项目名称:KVIrc,代码行数:101,代码来源:KviHttpRequest.cpp


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