Changeset 1027 for trunk/src/gui/dialogs


Ignore:
Timestamp:
Aug 25, 2011, 9:35:37 PM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

Make QFileSystemModel put "." and ".." entries first.

There are consumers of QFileSystemModel that do not exclude these
pseudo directories from the listing (e.g. the File System view in Qt Creator)
and having ".." coming after directory names that start with e.g. an exclamation
mark ("!") there looks weird.

Suggested by Rudi Ihle.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/dialogs/qfilesystemmodel.cpp

    r1022 r1027  
    10791079            if (left ^ right)
    10801080                return left;
     1081
     1082            // place "." and ".." pseudo dirs on top
     1083            if (left) {
     1084                int lw = l->fileName == QLatin1String(".") ? 2 :
     1085                         l->fileName == QLatin1String("..") ? 1 : 0;
     1086                int rw = r->fileName == QLatin1String(".") ? 2 :
     1087                         r->fileName == QLatin1String("..") ? 1 : 0;
     1088                if (lw || rw)
     1089                    return lw > rw;
     1090            }
    10811091#endif
    10821092            return QFileSystemModelPrivate::naturalCompare(l->fileName,
Note: See TracChangeset for help on using the changeset viewer.