| | |
| | | m_listPPID.SetItemText(index, 1, std::to_string(item.first).c_str()); |
| | | m_listPPID.SetItemText(index, 2, std::to_string(item.second).c_str()); |
| | | |
| | | std::string strRecipeName = mgr.getDeviceRecipeName(pEq->getName(), item.second); |
| | | std::string strRecipeName = mgr.getDeviceRecipeName(SanitizeName(pEq->getName()), item.second); |
| | | m_listPPID.SetItemText(index, 3, strRecipeName.c_str()); |
| | | |
| | | std::string strDescription; |
| | |
| | | |
| | | if (strRecipeName.empty()) { |
| | | strRecipeName = std::to_string(item.second); |
| | | mgr.addDeviceRecipe(pEq->getName(), item.second, strRecipeName, strDescription); |
| | | mgr.addDeviceRecipe(SanitizeName(pEq->getName()), item.second, strRecipeName, strDescription); |
| | | } |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | if (RecipeManager::getInstance().updateDeviceRecipeName(pEq->getName(), _ttoi(strID), std::string(CT2A(strText)))) { |
| | | if (RecipeManager::getInstance().updateDeviceRecipeName(SanitizeName(pEq->getName()), _ttoi(strID), std::string(CT2A(strText)))) { |
| | | m_listPPID.SetItemText(nLine, 3, strText); |
| | | } |
| | | } |
| | |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | std::string CPageRecipe::SanitizeName(const std::string& name) |
| | | { |
| | | std::string result; |
| | | result.reserve(name.size()); |
| | | |
| | | for (char c : name) { |
| | | if (c == '(' || c == '(') { |
| | | break; |
| | | } |
| | | |
| | | unsigned char uc = static_cast<unsigned char>(c); |
| | | if (std::isalnum(uc) || c == '_') { |
| | | result.push_back(c); |
| | | } |
| | | else if (std::isspace(uc)) { |
| | | continue; |
| | | } |
| | | else { |
| | | result.push_back('_'); |
| | | } |
| | | } |
| | | return result; |
| | | } |