BOOL CFailingRulesDialog::OnItemChanged(UINT, LPNMLISTVIEW pnmv, LRESULT* pResult) { bool bWasSelected=(pnmv->uOldState & LVIS_SELECTED); bool bIsSelected =(pnmv->uNewState & LVIS_SELECTED); if(bWasSelected != bIsSelected) { CdlConflict conflict=(CdlConflict) m_RulesList.GetItemData(pnmv->iItem); if(bIsSelected){ if(1==m_List.GetSelectedCount()){ GetDlgItem(IDC_STATIC1)->ShowWindow(SW_HIDE); m_List.ShowWindow(SW_SHOW); } AddConflictSolutions(conflict); } else { RemoveConflictSolutions(conflict); } } *pResult = 0; return false; }
void ecResolveConflictsDialog::OnConflictDeselected(wxListEvent& event) { CdlConflict conflict=(CdlConflict) m_conflictsCtrl->GetItemData(event.GetIndex()); RemoveConflictSolutions(conflict); }
void ecResolveConflictsDialog::OnContinue(wxCommandEvent& event) { // Ensure we have the current conflict check array int i; for (i = 0; i < m_conflictsCtrl->GetItemCount(); i++) { if (m_conflictsCtrl->GetItemState(i, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED) RemoveConflictSolutions((CdlConflict) m_conflictsCtrl->GetItemData(i)); } // Dismiss the window EndModal(wxID_OK); std::list<CdlConflict>::const_iterator conf_i; for (conf_i= m_conflicts.begin (); conf_i != m_conflicts.end (); conf_i++) // for each conflict { CdlConflict conflict=*conf_i; //int nSolutions=conflict->get_solution().size(); SolutionInfo &info=Info(conflict); int nIndex=0; const std::vector<std::pair<CdlValuable, CdlValue> >&Solution=conflict->get_solution(); for (std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator soln_i = Solution.begin();soln_i != Solution.end(); soln_i++) { if(SolutionInfo::CHECKED==info.arItem[nIndex++]){ CdlValuable valuable = soln_i->first; CdlValue value=soln_i->second; CdlValueFlavor flavor = valuable->get_flavor(); const wxString strName(valuable->get_name().c_str()); const wxString strValue(value.get_value().c_str()); bool rc = TRUE; wxString str; try { switch(flavor) { case CdlValueFlavor_None : str = wxT("set CdlValueFlavor_None"); rc = FALSE; break; case CdlValueFlavor_Bool : str.Printf(_("%s %s\n"), (const wxChar*) (value.is_enabled()?_("disable"):_("enable")), (const wxChar*) strName); valuable->set_enabled (m_Transaction, value.is_enabled(), CdlValueSource_User); break; case CdlValueFlavor_BoolData : { bool bEnabled=value.is_enabled(); str.Printf(_("%s %s and set value to %s\n"), (const wxChar*) (bEnabled? _("disable"):_("enable")), (const wxChar*) strName, (const wxChar*) strValue); // Surely this is wrong - we don't want to set the same value, we want to // set a NEW value. // CdlSimpleValue simple_value = valuable->get_simple_value (); //valuable->set_enabled_and_value (m_Transaction, bEnabled, simple_value, CdlValueSource_User); valuable->set_enabled_and_value (m_Transaction, bEnabled, ecUtils::UnicodeToStdStr (strValue), CdlValueSource_User); } break; case CdlValueFlavor_Data : str.Printf(_("set %s to %s\n"), (const wxChar*) strName, (const wxChar*) strValue); valuable->set_value (m_Transaction, ecUtils::UnicodeToStdStr (strValue), CdlValueSource_User); break; } } catch(...) { rc = FALSE; } if(rc) { wxGetApp().GetConfigToolDoc()->Modify(TRUE); } else { wxString msg; msg.Printf(_("Failed to %s\n"), (const wxChar*) str); wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK); } } } } }
void CFailingRulesDialog::OnOK() { // Ensure we have the current conflict check array for(POSITION pos = m_RulesList.GetFirstSelectedItemPosition();pos;){ int nItem = m_RulesList.GetNextSelectedItem(pos); RemoveConflictSolutions((CdlConflict)m_RulesList.GetItemData(nItem)); } // Dismiss the window CeCosDialog::OnOK(); for (std::list<CdlConflict>::const_iterator conf_i= m_conflicts.begin (); conf_i != m_conflicts.end (); conf_i++) { // for each conflict CdlConflict conflict=*conf_i; //int nSolutions=conflict->get_solution().size(); SolutionInfo &info=Info(conflict); int nIndex=0; const std::vector<std::pair<CdlValuable, CdlValue> >&Solution=conflict->get_solution(); for (std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator soln_i = Solution.begin();soln_i != Solution.end(); soln_i++) { if(SolutionInfo::CHECKED==info.arItem[nIndex++]){ CdlValuable valuable = soln_i->first; CdlValue value=soln_i->second; CdlValueFlavor flavor = valuable->get_flavor(); const CString strName(valuable->get_name().c_str()); const CString strValue(value.get_value().c_str()); bool rc=true; CString str; try { switch(flavor) { case CdlValueFlavor_None : str=_T("set CdlValueFlavor_None"); rc=false; break; case CdlValueFlavor_Bool : str.Format(_T("%s %s\n"),value.is_enabled()?_T("disable"):_T("enable"),strName); valuable->set_enabled (m_Transaction, value.is_enabled(), CdlValueSource_User); break; case CdlValueFlavor_BoolData : { bool bEnabled=value.is_enabled(); str.Format(_T("%s %s and set value to %s\n"),bEnabled?_T("disable"):_T("enable"),strName,strValue); // This is wrong: it should set the NEW value. This is the cause of a long-standing bug... // CdlSimpleValue simple_value = valuable->get_simple_value (); //valuable->set_enabled_and_value (m_Transaction, bEnabled, simple_value, CdlValueSource_User); valuable->set_enabled_and_value (m_Transaction, bEnabled, CUtils::UnicodeToStdStr (strValue), CdlValueSource_User); } break; case CdlValueFlavor_Data : str.Format(_T("set %s to %s\n"),strName,strValue); valuable->set_value (m_Transaction, CUtils::UnicodeToStdStr (strValue), CdlValueSource_User); break; } } catch(...){ rc=false; } if(rc){ CConfigTool::GetConfigToolDoc()->SetModifiedFlag(); } else { CUtils::MessageBoxF(_T("Failed to %s\n"),str); } } } } }