Also see NBookmarkHelper::Sort. */
| 44 | |
| 45 | /* Also see NBookmarkHelper::Sort. */ |
| 46 | int CALLBACK ShellBrowser::Sort(int InternalIndex1, int InternalIndex2) const |
| 47 | { |
| 48 | int comparisonResult = 0; |
| 49 | |
| 50 | BasicItemInfo_t basicItemInfo1 = getBasicItemInfo(InternalIndex1); |
| 51 | BasicItemInfo_t basicItemInfo2 = getBasicItemInfo(InternalIndex2); |
| 52 | |
| 53 | bool isFolder1 = ((basicItemInfo1.wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) |
| 54 | == FILE_ATTRIBUTE_DIRECTORY) |
| 55 | ? true |
| 56 | : false; |
| 57 | bool isFolder2 = ((basicItemInfo2.wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) |
| 58 | == FILE_ATTRIBUTE_DIRECTORY) |
| 59 | ? true |
| 60 | : false; |
| 61 | |
| 62 | /* Folders will always be sorted separately from files, |
| 63 | except in the recycle bin. */ |
| 64 | if (isFolder1 && !isFolder2 && !CompareVirtualFolders(CSIDL_BITBUCKET)) |
| 65 | { |
| 66 | comparisonResult = -1; |
| 67 | } |
| 68 | else if (!isFolder1 && isFolder2 && !CompareVirtualFolders(CSIDL_BITBUCKET)) |
| 69 | { |
| 70 | comparisonResult = 1; |
| 71 | } |
| 72 | else |
| 73 | { |
| 74 | switch (m_folderSettings.sortMode) |
| 75 | { |
| 76 | case SortMode::Name: |
| 77 | comparisonResult = |
| 78 | SortByName(basicItemInfo1, basicItemInfo2, m_config->globalFolderSettings); |
| 79 | break; |
| 80 | |
| 81 | case SortMode::Type: |
| 82 | comparisonResult = SortByType(basicItemInfo1, basicItemInfo2); |
| 83 | break; |
| 84 | |
| 85 | case SortMode::Size: |
| 86 | comparisonResult = SortBySize(basicItemInfo1, basicItemInfo2); |
| 87 | break; |
| 88 | |
| 89 | case SortMode::DateModified: |
| 90 | comparisonResult = SortByDate(basicItemInfo1, basicItemInfo2, DateType::Modified); |
| 91 | break; |
| 92 | |
| 93 | case SortMode::TotalSize: |
| 94 | comparisonResult = SortByTotalSize(basicItemInfo1, basicItemInfo2, TRUE); |
| 95 | break; |
| 96 | |
| 97 | case SortMode::FreeSpace: |
| 98 | comparisonResult = SortByTotalSize(basicItemInfo1, basicItemInfo2, FALSE); |
| 99 | break; |
| 100 | |
| 101 | case SortMode::DateDeleted: |
| 102 | comparisonResult = |
| 103 | SortByItemDetails(basicItemInfo1, basicItemInfo2, &SCID_DATE_DELETED); |
no test coverage detected