| 1941 | } |
| 1942 | |
| 1943 | void IGFD::FileManager::m_SortFields(const FileDialogInternal& vFileDialogInternal, std::vector<std::shared_ptr<FileInfos> >& vFileInfosList, std::vector<std::shared_ptr<FileInfos> >& vFileInfosFilteredList) { |
| 1944 | if (sortingField != SortingFieldEnum::FIELD_NONE) { |
| 1945 | headerFileName = tableHeaderFileNameString; |
| 1946 | headerFileType = tableHeaderFileTypeString; |
| 1947 | headerFileSize = tableHeaderFileSizeString; |
| 1948 | headerFileDate = tableHeaderFileDateString; |
| 1949 | #ifdef USE_THUMBNAILS |
| 1950 | headerFileThumbnails = tableHeaderFileThumbnailsString; |
| 1951 | #endif // #ifdef USE_THUMBNAILS |
| 1952 | } |
| 1953 | if (sortingField == SortingFieldEnum::FIELD_FILENAME) { |
| 1954 | if (sortingDirection[0]) { |
| 1955 | #ifdef USE_CUSTOM_SORTING_ICON |
| 1956 | headerFileName = tableHeaderAscendingIcon + headerFileName; |
| 1957 | #endif // USE_CUSTOM_SORTING_ICON |
| 1958 | std::sort(vFileInfosList.begin(), vFileInfosList.end(), // |
| 1959 | [&vFileDialogInternal](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool { |
| 1960 | if (!a.use_count() || !b.use_count()) return false; |
| 1961 | if (a->fileType != b->fileType) return (a->fileType < b->fileType); // directories first |
| 1962 | return M_SortStrings(vFileDialogInternal, true, false, a->fileNameExt, b->fileNameExt); // sort in insensitive case |
| 1963 | }); |
| 1964 | } else { |
| 1965 | #ifdef USE_CUSTOM_SORTING_ICON |
| 1966 | headerFileName = tableHeaderDescendingIcon + headerFileName; |
| 1967 | #endif // USE_CUSTOM_SORTING_ICON |
| 1968 | std::sort(vFileInfosList.begin(), vFileInfosList.end(), // |
| 1969 | [&vFileDialogInternal](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool { |
| 1970 | if (!a.use_count() || !b.use_count()) return false; |
| 1971 | if (a->fileType != b->fileType) return (a->fileType > b->fileType); // directories last |
| 1972 | return M_SortStrings(vFileDialogInternal, true, true, a->fileNameExt, b->fileNameExt); // sort in insensitive case |
| 1973 | }); |
| 1974 | } |
| 1975 | } else if (sortingField == SortingFieldEnum::FIELD_TYPE) { |
| 1976 | if (sortingDirection[1]) { |
| 1977 | #ifdef USE_CUSTOM_SORTING_ICON |
| 1978 | headerFileType = tableHeaderAscendingIcon + headerFileType; |
| 1979 | #endif // USE_CUSTOM_SORTING_ICON |
| 1980 | std::sort(vFileInfosList.begin(), vFileInfosList.end(), [&vFileDialogInternal](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool { |
| 1981 | if (!a.use_count() || !b.use_count()) return false; |
| 1982 | if (a->fileType != b->fileType) return (a->fileType < b->fileType); // directory in first |
| 1983 | return M_SortStrings(vFileDialogInternal, true, false, a->fileExtLevels[0], b->fileExtLevels[0]); // sort in sensitive case |
| 1984 | }); |
| 1985 | } else { |
| 1986 | #ifdef USE_CUSTOM_SORTING_ICON |
| 1987 | headerFileType = tableHeaderDescendingIcon + headerFileType; |
| 1988 | #endif // USE_CUSTOM_SORTING_ICON |
| 1989 | std::sort(vFileInfosList.begin(), vFileInfosList.end(), [&vFileDialogInternal](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool { |
| 1990 | if (!a.use_count() || !b.use_count()) return false; |
| 1991 | if (a->fileType != b->fileType) return (a->fileType > b->fileType); // directory in last |
| 1992 | return M_SortStrings(vFileDialogInternal, true, true, a->fileExtLevels[0], b->fileExtLevels[0]); // sort in sensitive case |
| 1993 | }); |
| 1994 | } |
| 1995 | } else if (sortingField == SortingFieldEnum::FIELD_SIZE) { |
| 1996 | if (sortingDirection[2]) { |
| 1997 | #ifdef USE_CUSTOM_SORTING_ICON |
| 1998 | headerFileSize = tableHeaderAscendingIcon + headerFileSize; |
| 1999 | #endif // USE_CUSTOM_SORTING_ICON |
| 2000 | std::sort(vFileInfosList.begin(), vFileInfosList.end(), [](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool { |