int CompareNoDesc(CShadowTree* pLeft, CShadowTree* pRight) { switch(m_col) { case CBrowseRefsDlg::eCol_Name: return SortStrCmp(pLeft->GetRefName(), pRight->GetRefName()); case CBrowseRefsDlg::eCol_Date: return pLeft->m_csDate_Iso8601.CompareNoCase(pRight->m_csDate_Iso8601); case CBrowseRefsDlg::eCol_Msg: return SortStrCmp(pLeft->m_csSubject, pRight->m_csSubject); case CBrowseRefsDlg::eCol_LastAuthor: return SortStrCmp(pLeft->m_csAuthor, pRight->m_csAuthor); case CBrowseRefsDlg::eCol_Hash: return pLeft->m_csRefHash.CompareNoCase(pRight->m_csRefHash); case CBrowseRefsDlg::eCol_Description: return SortStrCmp(pLeft->m_csDescription, pRight->m_csDescription); } return 0; }
int CompareNoDesc(const CShadowTree* pLeft, const CShadowTree* pRight) { switch(m_col) { case CBrowseRefsDlg::eCol_Name: return SortStrCmp(pLeft->GetRefName(), pRight->GetRefName()); case CBrowseRefsDlg::eCol_Upstream: return SortStrCmp(pLeft->m_csUpstream, pRight->m_csUpstream); case CBrowseRefsDlg::eCol_Date: return ((pLeft->m_csDate == pRight->m_csDate) ? 0 : ((pLeft->m_csDate > pRight->m_csDate) ? 1 : -1)); case CBrowseRefsDlg::eCol_Msg: return SortStrCmp(pLeft->m_csSubject, pRight->m_csSubject); case CBrowseRefsDlg::eCol_LastAuthor: return SortStrCmp(pLeft->m_csAuthor, pRight->m_csAuthor); case CBrowseRefsDlg::eCol_Hash: return pLeft->m_csRefHash.CompareNoCase(pRight->m_csRefHash); case CBrowseRefsDlg::eCol_Description: return SortStrCmp(pLeft->m_csDescription, pRight->m_csDescription); } return 0; }
int Compare(LPARAM lParam1, LPARAM lParam2) { CShadowFilesTree * pLeft = (CShadowFilesTree *)m_pList->GetItemData((int)lParam1); CShadowFilesTree * pRight = (CShadowFilesTree *)m_pList->GetItemData((int)lParam2); int result = 0; switch(m_col) { case CRepositoryBrowser::eCol_Name: result = SortStrCmp(pLeft->m_sName, pRight->m_sName); if (result != 0) break; case CRepositoryBrowser::eCol_Extension: result = m_pList->GetItemText(static_cast<int>(lParam1), 1).CompareNoCase(m_pList->GetItemText(static_cast<int>(lParam2), 1)); if (result == 0) // if extensions are the same, use the filename to sort result = SortStrCmp(pRight->m_sName, pRight->m_sName); if (result != 0) break; case CRepositoryBrowser::eCol_FileSize: if (pLeft->m_iSize > pRight->m_iSize) result = 1; else if (pLeft->m_iSize < pRight->m_iSize) result = -1; else // fallback result = SortStrCmp(pLeft->m_sName, pRight->m_sName); } if (m_desc) result = -result; if (pLeft->m_bFolder != pRight->m_bFolder) { if (pRight->m_bFolder) result = 1; else result = -1; } return result; }