예제 #1
0
static void vPopulateMainSubList(CMainEntryList& DestList, const SFILTERAPPLIED_CAN* psFilterConfigured,
                                 const SFILTERAPPLIED_CAN* psFilterApplied)
{
    ASSERT(psFilterConfigured != NULL);
    DestList.RemoveAll();
    SMAINENTRY sMainEntry;
    sMainEntry.m_omMainEntryName = _T("CAN");

    if (psFilterApplied == NULL)
    {
        SMAINENTRY sMainEntry;
        sMainEntry.m_omMainEntryName = _T("FILTER_SELECTION_CAN");

        for (INT i = 0; i < psFilterConfigured->m_ushTotal; i++)
        {
            SSUBENTRY sSubEntry;
            sSubEntry.m_omSubEntryName.Format("%s",
                                              psFilterConfigured->m_psFilters[i].m_sFilterName.m_acFilterName);
            sMainEntry.m_odUnSelEntryList.AddTail(sSubEntry);
        }
    }
    else
    {
        for (INT i = 0; i < psFilterConfigured->m_ushTotal; i++)
        {
            SSUBENTRY sSubEntry;
            sSubEntry.m_omSubEntryName.Format("%s",
                                              psFilterConfigured->m_psFilters[i].m_sFilterName.m_acFilterName);

            if (SFILTERSET::psGetFilterSetPointer(psFilterApplied->m_psFilters,
                                                  psFilterApplied->m_ushTotal,
                                                  sSubEntry.m_omSubEntryName.GetBuffer(MAX_PATH)) != NULL)
            {
                sMainEntry.m_odSelEntryList.AddTail(sSubEntry);
            }
            else
            {
                sMainEntry.m_odUnSelEntryList.AddTail(sSubEntry);
            }
        }
    }

    DestList.AddTail(sMainEntry);
}
void CMsgFilterConfigPage::populateFilterConfiguration(CMainEntryList& DestList)
{

    DestList.RemoveAll();

    SMAINENTRY sMainEntry;
    sMainEntry.m_omMainEntryName = mCaption.c_str();

for (auto filter : mFilterDetails->mFiltersConfigured)
    {
        SSUBENTRY sSubEntry;
        sSubEntry.m_omSubEntryName.Format("%s", filter.c_str());

        if (mFilterDetails->mFitersApplied.find(filter) != mFilterDetails->mFitersApplied.end())
        {
            sMainEntry.m_odSelEntryList.AddTail(sSubEntry);
        }
        else
        {
            sMainEntry.m_odUnSelEntryList.AddTail(sSubEntry);
        }
    }
    DestList.AddTail(sMainEntry);
}
static void vPopulateFilterApplied(const SFILTERAPPLIED_CAN* psFilterConfigured, SFILTERAPPLIED_CAN& sFilterApplied, CMainEntryList& SrcList)
{
    if ( psFilterConfigured == nullptr )
    {
        return;
    }

    const SMAINENTRY& sMainEntry = SrcList.GetHead();
    int nCount  = sMainEntry.m_odSelEntryList.GetCount();

    SFILTERAPPLIED_CAN    sTempAppliedFilter;
    sTempAppliedFilter.bClone(sFilterApplied);
    sFilterApplied.vClear();
    sFilterApplied.m_psFilters = new SFILTERSET[nCount];

    POSITION pos = sMainEntry.m_odSelEntryList.GetHeadPosition();
    while (pos)
    {
        SSUBENTRY sSubEntry = sMainEntry.m_odSelEntryList.GetNext(pos);
        const PSFILTERSET psTemp = SFILTERSET::psGetFilterSetPointer(psFilterConfigured->m_psFilters,
                                   psFilterConfigured->m_ushTotal, sSubEntry.m_omSubEntryName.GetBuffer(MAX_PATH));
        if (psTemp != nullptr)
        {
            sFilterApplied.m_psFilters[sFilterApplied.m_ushTotal].bClone(*psTemp);
            sFilterApplied.m_ushTotal++;
        }
    }

    //restore the enable flag for all filters
    for(int nAppFilterCnt = 0; nAppFilterCnt < sFilterApplied.m_ushTotal; nAppFilterCnt++)
    {
        for(int nTempFilCnt = 0; nTempFilCnt < sTempAppliedFilter.m_ushTotal; nTempFilCnt++ )
        {
            if((&sTempAppliedFilter.m_psFilters[nTempFilCnt]) != nullptr)
            {
                if(sFilterApplied.m_psFilters[nAppFilterCnt].m_sFilterName.m_acFilterName ==
                        sTempAppliedFilter.m_psFilters[nTempFilCnt].m_sFilterName.m_acFilterName)
                {
                    ((sFilterApplied.m_psFilters)+ nAppFilterCnt) ->m_bEnabled
                        =  ((sTempAppliedFilter.m_psFilters)+ nTempFilCnt) ->m_bEnabled;
                }
            }
        }
    }
}
static void vPopulateFilterApplied(const SFILTERAPPLIED_CAN* psFilterConfigured, SFILTERAPPLIED_CAN& sFilterApplied, CMainEntryList& SrcList)
{
    const SMAINENTRY& sMainEntry = SrcList.GetHead();
    int nCount  = (int)sMainEntry.m_odSelEntryList.GetCount();
    sFilterApplied.vClear();
    sFilterApplied.m_psFilters = new SFILTERSET[nCount];

    POSITION pos = sMainEntry.m_odSelEntryList.GetHeadPosition();
    while (pos)
    {
        SSUBENTRY sSubEntry = sMainEntry.m_odSelEntryList.GetNext(pos);
        const PSFILTERSET psTemp = SFILTERSET::psGetFilterSetPointer(psFilterConfigured->m_psFilters,
                                   psFilterConfigured->m_ushTotal, sSubEntry.m_omSubEntryName.GetBuffer(MAX_PATH));
        ASSERT (psTemp != NULL);
        sFilterApplied.m_psFilters[sFilterApplied.m_ushTotal].bClone(*psTemp);
        sFilterApplied.m_ushTotal++;
    }
}
void CMsgFilterConfigPage::updateFilterConfiguration(CMainEntryList& SrcList)
{
    mUpdatedFilters.clear();

    const SMAINENTRY& sMainEntry = SrcList.GetHead();
    POSITION pos = sMainEntry.m_odSelEntryList.GetHeadPosition();
    while (pos)
    {
        SSUBENTRY sSubEntry = sMainEntry.m_odSelEntryList.GetNext(pos);
        auto filter = mFilterDetails->mFitersApplied.find(sSubEntry.m_omSubEntryName.GetBuffer(0));
        if (filter != mFilterDetails->mFitersApplied.end())
        {
            mUpdatedFilters[sSubEntry.m_omSubEntryName.GetBuffer(0)] = filter->second;
        }
        else
        {
            mUpdatedFilters[sSubEntry.m_omSubEntryName.GetBuffer(0)] = true;
        }
    }
    mFilterDetails->mFitersApplied = mUpdatedFilters;
}