| 1174 | } |
| 1175 | |
| 1176 | int CGenericClientListCtrl::Compare( |
| 1177 | const CClientRef& client1, const CClientRef& client2, long lParamSort) |
| 1178 | { |
| 1179 | switch (lParamSort) { |
| 1180 | // Sort by name |
| 1181 | case ColumnUserName: |
| 1182 | return CmpAny( client1.GetUserName(), client2.GetUserName() ); |
| 1183 | |
| 1184 | // Sort by transferred in the following fields |
| 1185 | case ColumnUserDownloaded: |
| 1186 | return CmpAny( client1.GetTransferredDown(), client2.GetTransferredDown() ); |
| 1187 | |
| 1188 | // Sort by transferred in the following fields |
| 1189 | case ColumnUserUploaded: |
| 1190 | return CmpAny( client1.GetTransferredUp(), client2.GetTransferredUp() ); |
| 1191 | |
| 1192 | // Sort by speed |
| 1193 | case ColumnUserSpeedDown: |
| 1194 | return CmpAny( client1.GetKBpsDown(), client2.GetKBpsDown() ); |
| 1195 | |
| 1196 | // Sort by speed |
| 1197 | case ColumnUserSpeedUp: |
| 1198 | return CmpAny( client1.GetUploadDatarate(), client2.GetUploadDatarate() ); |
| 1199 | |
| 1200 | // Sort by parts offered |
| 1201 | case ColumnUserProgress: |
| 1202 | return CmpAny( |
| 1203 | client1.GetAvailablePartCount(), |
| 1204 | client2.GetAvailablePartCount() ); |
| 1205 | |
| 1206 | // Sort by client version |
| 1207 | case ColumnUserVersion: { |
| 1208 | int cmp = client1.GetSoftStr().Cmp(client2.GetSoftStr()); |
| 1209 | |
| 1210 | if (cmp == 0) { |
| 1211 | cmp = CmpAny(client1.GetVersion(), client2.GetVersion()); |
| 1212 | } |
| 1213 | if (cmp == 0) { |
| 1214 | cmp = client1.GetClientModString().Cmp(client2.GetClientModString()); |
| 1215 | } |
| 1216 | return cmp; |
| 1217 | } |
| 1218 | |
| 1219 | // Sort by Queue-Rank |
| 1220 | case ColumnUserQueueRankRemote: { |
| 1221 | // This will sort by download state: Downloading, OnQueue, Connecting ... |
| 1222 | // However, Asked For Another will always be placed last, due to |
| 1223 | // sorting in SortProc |
| 1224 | if ( client1.GetDownloadState() != client2.GetDownloadState() ) { |
| 1225 | return client1.GetDownloadState() - client2.GetDownloadState(); |
| 1226 | } |
| 1227 | |
| 1228 | // Placing items on queue before items on full queues |
| 1229 | if ( client1.IsRemoteQueueFull() ) { |
| 1230 | if ( client2.IsRemoteQueueFull() ) { |
| 1231 | return 0; |
| 1232 | } else { |
| 1233 | return 1; |
nothing calls this directly
no test coverage detected