will be called internally will not been exposed to IGFD API
| 1536 | // will be called internally |
| 1537 | // will not been exposed to IGFD API |
| 1538 | bool IGFD::FilterManager::FillFileStyle(std::shared_ptr<FileInfos> vFileInfos) const { |
| 1539 | // todo : better system to found regarding what style to priorize regarding other |
| 1540 | // maybe with a lambda fucntion for let the user use his style |
| 1541 | // according to his use case |
| 1542 | if (vFileInfos.use_count() && !m_FilesStyle.empty()) { |
| 1543 | for (const auto& _flag : m_FilesStyle) { |
| 1544 | for (const auto& _file : _flag.second) { |
| 1545 | if ((_flag.first & IGFD_FileStyleByTypeDir && _flag.first & IGFD_FileStyleByTypeLink && vFileInfos->fileType.isDir() && vFileInfos->fileType.isSymLink()) || |
| 1546 | (_flag.first & IGFD_FileStyleByTypeFile && _flag.first & IGFD_FileStyleByTypeLink && vFileInfos->fileType.isFile() && vFileInfos->fileType.isSymLink()) || |
| 1547 | (_flag.first & IGFD_FileStyleByTypeLink && vFileInfos->fileType.isSymLink()) || (_flag.first & IGFD_FileStyleByTypeDir && vFileInfos->fileType.isDir()) || |
| 1548 | (_flag.first & IGFD_FileStyleByTypeFile && vFileInfos->fileType.isFile())) { |
| 1549 | if (_file.first.empty()) { // for all links |
| 1550 | vFileInfos->fileStyle = _file.second; |
| 1551 | } else if (_file.first.find("((") != std::string::npos && std::regex_search(vFileInfos->fileNameExt, |
| 1552 | std::regex(_file.first))) { // for links who are equal to style criteria |
| 1553 | vFileInfos->fileStyle = _file.second; |
| 1554 | } else if (_file.first == vFileInfos->fileNameExt) { // for links who are equal to style criteria |
| 1555 | vFileInfos->fileStyle = _file.second; |
| 1556 | } |
| 1557 | } |
| 1558 | |
| 1559 | if (_flag.first & IGFD_FileStyleByExtention) { |
| 1560 | if (_file.first.find("((") != std::string::npos && std::regex_search(vFileInfos->fileExtLevels[0], std::regex(_file.first))) { |
| 1561 | vFileInfos->fileStyle = _file.second; |
| 1562 | } else if (vFileInfos->SearchForExt(_file.first, false)) { |
| 1563 | vFileInfos->fileStyle = _file.second; |
| 1564 | } |
| 1565 | } |
| 1566 | |
| 1567 | if (_flag.first & IGFD_FileStyleByFullName) { |
| 1568 | if (_file.first.find("((") != std::string::npos && std::regex_search(vFileInfos->fileNameExt, std::regex(_file.first))) { |
| 1569 | vFileInfos->fileStyle = _file.second; |
| 1570 | } else if (_file.first == vFileInfos->fileNameExt) { |
| 1571 | vFileInfos->fileStyle = _file.second; |
| 1572 | } |
| 1573 | } |
| 1574 | |
| 1575 | if (_flag.first & IGFD_FileStyleByContainedInFullName) { |
| 1576 | if (_file.first.find("((") != std::string::npos && std::regex_search(vFileInfos->fileNameExt, std::regex(_file.first))) { |
| 1577 | vFileInfos->fileStyle = _file.second; |
| 1578 | } else if (vFileInfos->fileNameExt.find(_file.first) != std::string::npos) { |
| 1579 | vFileInfos->fileStyle = _file.second; |
| 1580 | } |
| 1581 | } |
| 1582 | |
| 1583 | for (auto& functor : m_FilesStyleFunctors) { |
| 1584 | if (functor) { |
| 1585 | FileStyle result; |
| 1586 | if (functor(*(vFileInfos.get()), result)) { |
| 1587 | vFileInfos->fileStyle = std::make_shared<FileStyle>(std::move(result)); |
| 1588 | } |
| 1589 | } |
| 1590 | } |
| 1591 | |
| 1592 | if (vFileInfos->fileStyle.use_count()) { |
| 1593 | return true; |
| 1594 | } |
| 1595 | } |