From f570e2f2685aa43aa518c2f8578391c1847cddbe Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:04:59 +0200 Subject: 3.3 --- ui/sorting.h | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'ui/sorting.h') diff --git a/ui/sorting.h b/ui/sorting.h index 04ecc171..5771d7db 100644 --- a/ui/sorting.h +++ b/ui/sorting.h @@ -60,16 +60,16 @@ bool sortByFileName(const FileSystemObject& a, const FileSystemObject& b) return true; //empty rows always last - if (dynamic_cast(&a)) //sort directories by relative name + if (isDirectoryMapping(a)) //sort directories by relative name { - if (dynamic_cast(&b)) + if (isDirectoryMapping(b)) return stringSmallerThan(a.getRelativeName(), b.getRelativeName()); else return false; } else { - if (dynamic_cast(&b)) + if (isDirectoryMapping(b)) return true; else return Compare().isSmallerThan( @@ -86,15 +86,16 @@ bool sortByRelativeName(const FileSystemObject& a, const FileSystemObject& b) else if (b.isEmpty()) return true; //empty rows always last - const FileMapping* fileObjA = dynamic_cast(&a); - const Zstring relDirNameA = fileObjA != NULL ? - a.getParentRelativeName() : //file - a.getRelativeName(); //directory + const bool isDirectoryA = isDirectoryMapping(a); + const Zstring relDirNameA = isDirectoryA ? + a.getRelativeName() : //directory + a.getParentRelativeName(); //file + + const bool isDirectoryB = isDirectoryMapping(b); + const Zstring relDirNameB = isDirectoryB ? + b.getRelativeName() : //directory + b.getParentRelativeName(); //file - const FileMapping* fileObjB = dynamic_cast(&b); - const Zstring relDirNameB = fileObjB != NULL ? - b.getParentRelativeName() : //file - b.getRelativeName(); //directory //compare relative names without filenames first const int rv = compareString(relDirNameA, relDirNameB); @@ -102,9 +103,9 @@ bool sortByRelativeName(const FileSystemObject& a, const FileSystemObject& b) return Compare().isSmallerThan(rv, 0); else //compare the filenames { - if (fileObjB == NULL) //directories shall appear before files + if (isDirectoryB) //directories shall appear before files return false; - else if (fileObjA == NULL) + else if (isDirectoryA) return true; return stringSmallerThan(a.getShortName(), b.getShortName()); -- cgit