コード例 #1
0
bool CSVSortList::checkDisplayIndex()
{
    irow it;
    map<int, string, less<int> > lsDis;
    map<int, string, less<int> >::iterator lsDisItem;
    for(it = m_svList.begin(); it != m_svList.end(); it++)
    {
        SVTableCell *pCell = (*it).second.Cell(1);
        if(pCell && pCell->Type() == adLineEdit)
        {
            if(pCell->Value())
            {                
                string szIndex = ((WLineEdit*)pCell->Value())->text();
                int nIndex = 0;
                if(!szIndex.empty())
                    nIndex = atoi(szIndex.c_str());
                lsDisItem = lsDis.find(nIndex);
                while(lsDisItem != lsDis.end())
                {
                    nIndex ++;
                    lsDisItem = lsDis.find(nIndex);
                }
                lsDis[nIndex] = pCell->Property();
            }
        }
    } 
    switch(m_nType)
    {
    case Tree_GROUP:
        saveGroup(lsDis);
        break;
    case Tree_DEVICE:
        saveDevice(lsDis);
        break;
    case Tree_MONITOR:
        saveMonitor(lsDis);
        break;
    }
    return true;
}
コード例 #2
0
ファイル: frmlog.cpp プロジェクト: hominlinx/cppbed
/* 收到串口数据 */
void frmLog::onReadData()
{
	QByteArray data = mSerial.readAll();
	QString str = data, ss, stime, smsg;
	int pos, len;
	static bool new_line = true;

	if ((str == "") || (str == "\n")) return;
	/* 符合熔断条件,向主窗体请求停止所有报文发送 */
	if ((ui.chkStopAll->isChecked()) && (ui.ctlStopPattern->text().trimmed().length() > 0))
	{
		if (str.indexOf(ui.ctlStopPattern->text()) >= 0)
		{
			stopRun();
			emit stopAllActions();
		}
	}
	str.replace("\r\n", "\n");
	str.remove("\r");
	// 出现\n的时候打印时间
find_next_line:
	//qDebug() << "str:" << str << new_line;
	pos = str.indexOf("\n");
	if (pos >= 0)
	{
		ss = str.mid(0, pos+1);
	}
	else 
		ss = str;
	if (new_line)
	{
		qDebug() << "Line:" << sMonitorLine;
		sLastLine = sMonitorLine;
		QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间
		stime = time.toString("hh:mm:ss.zzz"); //设置显示格式
		smsg = "[" + stime + "]    " + ss;
		sMonitorLine = ss;
	}
	else
	{
		smsg += ss;
		sMonitorLine += ss;
	}

	// 如果有监控指定字符串
	if (sMonitorPattern != "")
	{
		if (sMonitorLine.indexOf(sMonitorPattern) >= 0)
			sMonitorResult = true;
	}

	// 读取指定内容开头的行
    if ((sReadLinePattern != "") && (sReadLineResult == false))
	{
		if (sLastLine.indexOf(sReadLinePattern) == 0)
        {
            sReadLine = sLastLine;
			sReadLineResult = true;
        }
	}

	// 检测看有没有版本信息
	checkVersionPattern(sMonitorLine);

	if (pos >= 0)
		new_line = true;
	else
		new_line = false;

	qDebug() << "MSG:" << sMonitorLine;
	//smsg = sMonitorLine;
	smsg.remove("[1;32m");
	smsg.remove("[1;33m");
	smsg.remove("[1;34m");
	smsg.remove("[1;35m");
	smsg.remove("[1;36m");
	smsg.remove("[0;0m");
	smsg.remove("[0m");

	//if (pos>=0)
	{
		ui.txtComInfo->insertPlainText(smsg);
		ui.txtComInfo->moveCursor(QTextCursor::End);
	}
	len = str.length();
	if ((pos >= 0) &&(pos < len - 1)) 
	{
		str = str.mid(pos + 1);
		goto find_next_line;
	}

	// 太多内容了,程序会变慢,保存后清除
	if (ui.txtComInfo->document()->lineCount() > mMaxMonitor)
	{
		saveMonitor();
		ui.txtComInfo->clear();
	}
	ui.ctlMonitorLineNum->setText(QString::number(ui.txtComInfo->document()->lineCount()));
}