todo : refactor this fucking function
| 1614 | |
| 1615 | // todo : refactor this fucking function |
| 1616 | bool IGFD::FilterManager::GetFileStyle(const IGFD_FileStyleFlags& vFlags, const std::string& vCriteria, ImVec4* vOutColor, std::string* vOutIcon, ImFont** vOutFont) { |
| 1617 | if (vOutColor) { |
| 1618 | if (!m_FilesStyle.empty()) { |
| 1619 | if (m_FilesStyle.find(vFlags) != m_FilesStyle.end()) { // found |
| 1620 | if (vFlags & IGFD_FileStyleByContainedInFullName) { |
| 1621 | // search for vCriteria who are containing the criteria |
| 1622 | for (const auto& _file : m_FilesStyle.at(vFlags)) { |
| 1623 | if (vCriteria.find(_file.first) != std::string::npos) { |
| 1624 | if (_file.second.use_count()) { |
| 1625 | *vOutColor = _file.second->color; |
| 1626 | if (vOutIcon) *vOutIcon = _file.second->icon; |
| 1627 | if (vOutFont) *vOutFont = _file.second->font; |
| 1628 | return true; |
| 1629 | } |
| 1630 | } |
| 1631 | } |
| 1632 | } else { |
| 1633 | if (m_FilesStyle.at(vFlags).find(vCriteria) != m_FilesStyle.at(vFlags).end()) { // found |
| 1634 | *vOutColor = m_FilesStyle[vFlags][vCriteria]->color; |
| 1635 | if (vOutIcon) *vOutIcon = m_FilesStyle[vFlags][vCriteria]->icon; |
| 1636 | if (vOutFont) *vOutFont = m_FilesStyle[vFlags][vCriteria]->font; |
| 1637 | return true; |
| 1638 | } |
| 1639 | } |
| 1640 | } else { |
| 1641 | // search for flag composition |
| 1642 | for (const auto& _flag : m_FilesStyle) { |
| 1643 | if (_flag.first & vFlags) { |
| 1644 | if (_flag.first & IGFD_FileStyleByContainedInFullName) { |
| 1645 | // search for vCriteria who are containing the criteria |
| 1646 | for (const auto& _file : m_FilesStyle.at(_flag.first)) { |
| 1647 | if (vCriteria.find(_file.first) != std::string::npos) { |
| 1648 | if (_file.second.use_count()) { |
| 1649 | *vOutColor = _file.second->color; |
| 1650 | if (vOutIcon) *vOutIcon = _file.second->icon; |
| 1651 | if (vOutFont) *vOutFont = _file.second->font; |
| 1652 | return true; |
| 1653 | } |
| 1654 | } |
| 1655 | } |
| 1656 | } else { |
| 1657 | if (m_FilesStyle.at(_flag.first).find(vCriteria) != m_FilesStyle.at(_flag.first).end()) { // found |
| 1658 | *vOutColor = m_FilesStyle[_flag.first][vCriteria]->color; |
| 1659 | if (vOutIcon) *vOutIcon = m_FilesStyle[_flag.first][vCriteria]->icon; |
| 1660 | if (vOutFont) *vOutFont = m_FilesStyle[_flag.first][vCriteria]->font; |
| 1661 | return true; |
| 1662 | } |
| 1663 | } |
| 1664 | } |
| 1665 | } |
| 1666 | } |
| 1667 | } |
| 1668 | } |
| 1669 | return false; |
| 1670 | } |
| 1671 | |
| 1672 | void IGFD::FilterManager::ClearFilesStyle() { |
| 1673 | m_FilesStyle.clear(); |
no test coverage detected