summaryrefslogtreecommitdiff
path: root/ui/sorting.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:04:59 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:04:59 +0200
commitf570e2f2685aa43aa518c2f8578391c1847cddbe (patch)
treeb9376b3a7e807c5e0c4cf3d5615c14034d9675d6 /ui/sorting.h
parent3.2 (diff)
downloadFreeFileSync-f570e2f2685aa43aa518c2f8578391c1847cddbe.tar.gz
FreeFileSync-f570e2f2685aa43aa518c2f8578391c1847cddbe.tar.bz2
FreeFileSync-f570e2f2685aa43aa518c2f8578391c1847cddbe.zip
3.3
Diffstat (limited to 'ui/sorting.h')
-rw-r--r--ui/sorting.h27
1 files changed, 14 insertions, 13 deletions
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<const DirMapping*>(&a)) //sort directories by relative name
+ if (isDirectoryMapping(a)) //sort directories by relative name
{
- if (dynamic_cast<const DirMapping*>(&b))
+ if (isDirectoryMapping(b))
return stringSmallerThan(a.getRelativeName<side>(), b.getRelativeName<side>());
else
return false;
}
else
{
- if (dynamic_cast<const DirMapping*>(&b))
+ if (isDirectoryMapping(b))
return true;
else
return Compare<ascending>().isSmallerThan(
@@ -86,15 +86,16 @@ bool sortByRelativeName(const FileSystemObject& a, const FileSystemObject& b)
else if (b.isEmpty<side>())
return true; //empty rows always last
- const FileMapping* fileObjA = dynamic_cast<const FileMapping*>(&a);
- const Zstring relDirNameA = fileObjA != NULL ?
- a.getParentRelativeName() : //file
- a.getRelativeName<side>(); //directory
+ const bool isDirectoryA = isDirectoryMapping(a);
+ const Zstring relDirNameA = isDirectoryA ?
+ a.getRelativeName<side>() : //directory
+ a.getParentRelativeName(); //file
+
+ const bool isDirectoryB = isDirectoryMapping(b);
+ const Zstring relDirNameB = isDirectoryB ?
+ b.getRelativeName<side>() : //directory
+ b.getParentRelativeName(); //file
- const FileMapping* fileObjB = dynamic_cast<const FileMapping*>(&b);
- const Zstring relDirNameB = fileObjB != NULL ?
- b.getParentRelativeName() : //file
- b.getRelativeName<side>(); //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<ascending>().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<side>(), b.getShortName<side>());
bgstack15