todo : refactor this fucking function
| 1552 | |
| 1553 | // todo : refactor this fucking function |
| 1554 | bool IGFD::FilterManager::GetFileStyle(const IGFD_FileStyleFlags& vFlags, const std::string& vCriteria, ImVec4* vOutColor, std::string* vOutIcon, ImFont** vOutFont) { |
| 1555 | if (vOutColor) { |
| 1556 | if (!m_FilesStyle.empty()) { |
| 1557 | if (m_FilesStyle.find(vFlags) != m_FilesStyle.end()) { // found |
| 1558 | if (vFlags & IGFD_FileStyleByContainedInFullName) { |
| 1559 | // search for vCriteria who are containing the criteria |
| 1560 | for (const auto& _file : m_FilesStyle.at(vFlags)) { |
| 1561 | if (vCriteria.find(_file.first) != std::string::npos) { |
| 1562 | if (_file.second.use_count()) { |
| 1563 | *vOutColor = _file.second->color; |
| 1564 | if (vOutIcon) *vOutIcon = _file.second->icon; |
| 1565 | if (vOutFont) *vOutFont = _file.second->font; |
| 1566 | return true; |
| 1567 | } |
| 1568 | } |
| 1569 | } |
| 1570 | } else { |
| 1571 | if (m_FilesStyle.at(vFlags).find(vCriteria) != m_FilesStyle.at(vFlags).end()) { // found |
| 1572 | *vOutColor = m_FilesStyle[vFlags][vCriteria]->color; |
| 1573 | if (vOutIcon) *vOutIcon = m_FilesStyle[vFlags][vCriteria]->icon; |
| 1574 | if (vOutFont) *vOutFont = m_FilesStyle[vFlags][vCriteria]->font; |
| 1575 | return true; |
| 1576 | } |
| 1577 | } |
| 1578 | } else { |
| 1579 | // search for flag composition |
| 1580 | for (const auto& _flag : m_FilesStyle) { |
| 1581 | if (_flag.first & vFlags) { |
| 1582 | if (_flag.first & IGFD_FileStyleByContainedInFullName) { |
| 1583 | // search for vCriteria who are containing the criteria |
| 1584 | for (const auto& _file : m_FilesStyle.at(_flag.first)) { |
| 1585 | if (vCriteria.find(_file.first) != std::string::npos) { |
| 1586 | if (_file.second.use_count()) { |
| 1587 | *vOutColor = _file.second->color; |
| 1588 | if (vOutIcon) *vOutIcon = _file.second->icon; |
| 1589 | if (vOutFont) *vOutFont = _file.second->font; |
| 1590 | return true; |
| 1591 | } |
| 1592 | } |
| 1593 | } |
| 1594 | } else { |
| 1595 | if (m_FilesStyle.at(_flag.first).find(vCriteria) != m_FilesStyle.at(_flag.first).end()) { // found |
| 1596 | *vOutColor = m_FilesStyle[_flag.first][vCriteria]->color; |
| 1597 | if (vOutIcon) *vOutIcon = m_FilesStyle[_flag.first][vCriteria]->icon; |
| 1598 | if (vOutFont) *vOutFont = m_FilesStyle[_flag.first][vCriteria]->font; |
| 1599 | return true; |
| 1600 | } |
| 1601 | } |
| 1602 | } |
| 1603 | } |
| 1604 | } |
| 1605 | } |
| 1606 | } |
| 1607 | return false; |
| 1608 | } |
| 1609 | |
| 1610 | void IGFD::FilterManager::ClearFilesStyle() { |
| 1611 | m_FilesStyle.clear(); |
no test coverage detected