MCPcopy Create free account
hub / github.com/aiekick/ImGuiFileDialog / m_SortFields

Method m_SortFields

ImGuiFileDialog.cpp:1881–2007  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1879}
1880
1881void IGFD::FileManager::m_SortFields(const FileDialogInternal& vFileDialogInternal, std::vector<std::shared_ptr<FileInfos> >& vFileInfosList, std::vector<std::shared_ptr<FileInfos> >& vFileInfosFilteredList) {
1882 if (sortingField != SortingFieldEnum::FIELD_NONE) {
1883 headerFileName = tableHeaderFileNameString;
1884 headerFileType = tableHeaderFileTypeString;
1885 headerFileSize = tableHeaderFileSizeString;
1886 headerFileDate = tableHeaderFileDateString;
1887#ifdef USE_THUMBNAILS
1888 headerFileThumbnails = tableHeaderFileThumbnailsString;
1889#endif // #ifdef USE_THUMBNAILS
1890 }
1891 if (sortingField == SortingFieldEnum::FIELD_FILENAME) {
1892 if (sortingDirection[0]) {
1893#ifdef USE_CUSTOM_SORTING_ICON
1894 headerFileName = tableHeaderAscendingIcon + headerFileName;
1895#endif // USE_CUSTOM_SORTING_ICON
1896 std::sort(vFileInfosList.begin(), vFileInfosList.end(), //
1897 [&vFileDialogInternal](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool {
1898 if (!a.use_count() || !b.use_count()) return false;
1899 if (a->fileType != b->fileType) return (a->fileType < b->fileType); // directories first
1900 return M_SortStrings(vFileDialogInternal, true, false, a->fileNameExt, b->fileNameExt); // sort in insensitive case
1901 });
1902 } else {
1903#ifdef USE_CUSTOM_SORTING_ICON
1904 headerFileName = tableHeaderDescendingIcon + headerFileName;
1905#endif // USE_CUSTOM_SORTING_ICON
1906 std::sort(vFileInfosList.begin(), vFileInfosList.end(), //
1907 [&vFileDialogInternal](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool {
1908 if (!a.use_count() || !b.use_count()) return false;
1909 if (a->fileType != b->fileType) return (a->fileType > b->fileType); // directories last
1910 return M_SortStrings(vFileDialogInternal, true, true, a->fileNameExt, b->fileNameExt); // sort in insensitive case
1911 });
1912 }
1913 } else if (sortingField == SortingFieldEnum::FIELD_TYPE) {
1914 if (sortingDirection[1]) {
1915#ifdef USE_CUSTOM_SORTING_ICON
1916 headerFileType = tableHeaderAscendingIcon + headerFileType;
1917#endif // USE_CUSTOM_SORTING_ICON
1918 std::sort(vFileInfosList.begin(), vFileInfosList.end(), [&vFileDialogInternal](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool {
1919 if (!a.use_count() || !b.use_count()) return false;
1920 if (a->fileType != b->fileType) return (a->fileType < b->fileType); // directory in first
1921 return M_SortStrings(vFileDialogInternal, true, false, a->fileExtLevels[0], b->fileExtLevels[0]); // sort in sensitive case
1922 });
1923 } else {
1924#ifdef USE_CUSTOM_SORTING_ICON
1925 headerFileType = tableHeaderDescendingIcon + headerFileType;
1926#endif // USE_CUSTOM_SORTING_ICON
1927 std::sort(vFileInfosList.begin(), vFileInfosList.end(), [&vFileDialogInternal](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool {
1928 if (!a.use_count() || !b.use_count()) return false;
1929 if (a->fileType != b->fileType) return (a->fileType > b->fileType); // directory in last
1930 return M_SortStrings(vFileDialogInternal, true, true, a->fileExtLevels[0], b->fileExtLevels[0]); // sort in sensitive case
1931 });
1932 }
1933 } else if (sortingField == SortingFieldEnum::FIELD_SIZE) {
1934 if (sortingDirection[2]) {
1935#ifdef USE_CUSTOM_SORTING_ICON
1936 headerFileSize = tableHeaderAscendingIcon + headerFileSize;
1937#endif // USE_CUSTOM_SORTING_ICON
1938 std::sort(vFileInfosList.begin(), vFileInfosList.end(), [](const std::shared_ptr<FileInfos>& a, const std::shared_ptr<FileInfos>& b) -> bool {

Callers

nothing calls this directly

Calls 3

beginMethod · 0.80
endMethod · 0.80
isDirMethod · 0.80

Tested by

no test coverage detected