/* static */ int XSLT_Sort::Compare (unsigned index1, unsigned index2, const OpString *textkeys, double *numberkeys, XSLT_SortState* sortstate) { int result; if (textkeys) // (datatype == DATATYPE_TEXT) result = CompareText (textkeys[index1], textkeys[index2], sortstate->caseorder ); else result = CompareNumber (numberkeys[index1], numberkeys[index2]); if (result == 0) sortstate->has_equal = TRUE; if (sortstate->order == ORDER_ASCENDING) return result; else return -result; }
//--------------------------------------------------------------------------- void __fastcall TSynchronizeChecklistDialog::ListViewCompare( TObject * /*Sender*/, TListItem * Item1, TListItem * Item2, int /*Data*/, int & Compare) { const TSynchronizeChecklist::TItem * ChecklistItem1 = static_cast<const TSynchronizeChecklist::TItem *>(Item1->Data); const TSynchronizeChecklist::TItem * ChecklistItem2 = static_cast<const TSynchronizeChecklist::TItem *>(Item2->Data); TIEListViewColProperties * ColProperties = dynamic_cast<TIEListViewColProperties *>(ListView->ColProperties); switch (ColProperties->SortColumn) { case 0: // name Compare = AnsiCompareText(ChecklistItem1->GetFileName(), ChecklistItem2->GetFileName()); break; // sorting by local and remote dir is the same case 1: // local dir case 5: // remote dir Compare = 0; // default sorting break; case 2: // local size Compare = CompareNumber(ChecklistItem1->Local.Size, ChecklistItem2->Local.Size); break; case 3: // local changed Compare = CompareFileTime(ChecklistItem1->Local.Modification, ChecklistItem2->Local.Modification); break; case 4: // action Compare = CompareNumber(ChecklistItem1->Action, ChecklistItem2->Action); break; case 6: // remote size Compare = CompareNumber(ChecklistItem1->Remote.Size, ChecklistItem2->Remote.Size); break; case 7: // remote changed Compare = CompareFileTime(ChecklistItem1->Remote.Modification, ChecklistItem2->Remote.Modification); break; } if (Compare == 0) { if (!ChecklistItem1->Local.Directory.IsEmpty()) { Compare = AnsiCompareText(ChecklistItem1->Local.Directory, ChecklistItem2->Local.Directory); } else { assert(!ChecklistItem1->Remote.Directory.IsEmpty()); Compare = AnsiCompareText(ChecklistItem1->Remote.Directory, ChecklistItem2->Remote.Directory); } if (Compare == 0) { Compare = AnsiCompareText(ChecklistItem1->GetFileName(), ChecklistItem2->GetFileName()); } } if (!ColProperties->SortAscending) { Compare = -Compare; } }