QMap深度解析

话不多说,直接上代码
QMap之列表List两种遍历

载具列表

void CUnitTmplMgr::removeUnitTmpl(int           utid)
{
    if(m_unitTmplList.find(utid) != m_unitTmplList.end())
    {
        UnitTmplInfo info;
        info = m_unitTmplList[utid];
        m_unitTmplList.remove(utid);
        emit unitTmplRemoved (info);
    }
}

任务信息

void    CTaskInfoDock::computTmplInfo(UnitTmplInfo & info)
{
    UnitTmplList tmplList = m_unitTmplMgr->unitTmplList();
    QString str;
    str = QString("%1").arg(tmplList.size());
    m_tmplRootItem->setText(1,str);

    int fwPlane = 0;
    int vehicle = 0;
    int warShip = 0;
    int chopper = 0;
    int station = 0;
    int missile = 0;

    UnitTmplList::iterator it = tmplList.begin();
    for(;it != tmplList.end();it++)
    {
        switch(it->unitTmplType)
        {
        case UnitTmplInfo::UNITTMPL_FWPLANE:
            fwPlane++;
            break;
        case UnitTmplInfo::UNITTMPL_VEHICLE:
            vehicle++;
            break;
        case UnitTmplInfo::UNITTMPL_WARSHIP:
            warShip++;
            break;
        case UnitTmplInfo::UNITTMPL_CHOPPER:
            chopper++;
            break;
        case UnitTmplInfo::UNITTMPL_STATION:
            station++;
            break;
        case UnitTmplInfo::UNITTMPL_MISSILE:
            missile++;
            break;
        default:
            break;
        }
    }
    str = QString("%1").arg(fwPlane);
    m_tmplRootItem->child(0)->setText(1,str);
    str = QString("%1").arg(vehicle);
    m_tmplRootItem->child(1)->setText(1,str);
    str = QString("%1").arg(warShip);
    m_tmplRootItem->child(2)->setText(1,str);
    str = QString("%1").arg(chopper);
    m_tmplRootItem->child(3)->setText(1,str);
    str = QString("%1").arg(station);
    m_tmplRootItem->child(4)->setText(1,str);
    str = QString("%1").arg(missile);
    m_tmplRootItem->child(5)->setText(1,str);
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,972评论 25 709
  • 浩浩妈总是对新鲜事物充满好奇的,并且愿意去尝试,也许一个尝试,就能给自己一个有期待的未来。 最近圈里的姐妹们悄悄地...
    暗自芳香阅读 313评论 0 0
  • 258123阅读 193评论 0 0
  • 1 \\\\t ASCII水平制表符(TAB) 2from sys import argvscript,firs...
    胡三少阅读 486评论 0 1