Qt 4.8
Public Functions | Properties | List of all members
QFileSystemModelSorter Class Reference

Public Functions

bool compareNodes (const QFileSystemModelPrivate::QFileSystemNode *l, const QFileSystemModelPrivate::QFileSystemNode *r) const
 
bool operator() (const QPair< QFileSystemModelPrivate::QFileSystemNode *, int > &l, const QPair< QFileSystemModelPrivate::QFileSystemNode *, int > &r) const
 
 QFileSystemModelSorter (int column)
 

Properties

int sortColumn
 

Detailed Description

Definition at line 1100 of file qfilesystemmodel.cpp.

Constructors and Destructors

◆ QFileSystemModelSorter()

QFileSystemModelSorter::QFileSystemModelSorter ( int  column)
inline

Definition at line 1103 of file qfilesystemmodel.cpp.

1103 : sortColumn(column) {}

Functions

◆ compareNodes()

bool QFileSystemModelSorter::compareNodes ( const QFileSystemModelPrivate::QFileSystemNode l,
const QFileSystemModelPrivate::QFileSystemNode r 
) const
inline

Definition at line 1105 of file qfilesystemmodel.cpp.

1107  {
1108  switch (sortColumn) {
1109  case 0: {
1110 #ifndef Q_OS_MAC
1111  // place directories before files
1112  bool left = l->isDir();
1113  bool right = r->isDir();
1114  if (left ^ right)
1115  return left;
1116 #endif
1118  r->fileName, Qt::CaseInsensitive) < 0;
1119  }
1120  case 1:
1121  // Directories go first
1122  if (l->isDir() && !r->isDir())
1123  return true;
1124  return l->size() < r->size();
1125  case 2:
1126  return l->type() < r->type();
1127  case 3:
1128  return l->lastModified() < r->lastModified();
1129  }
1130  Q_ASSERT(false);
1131  return false;
1132  }
static int naturalCompare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs)
Natural number sort, skips spaces.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)

◆ operator()()

bool QFileSystemModelSorter::operator() ( const QPair< QFileSystemModelPrivate::QFileSystemNode *, int > &  l,
const QPair< QFileSystemModelPrivate::QFileSystemNode *, int > &  r 
) const
inline

Definition at line 1134 of file qfilesystemmodel.cpp.

1136  {
1137  return compareNodes(l.first, r.first);
1138  }
T1 first
Definition: qpair.h:65
bool compareNodes(const QFileSystemModelPrivate::QFileSystemNode *l, const QFileSystemModelPrivate::QFileSystemNode *r) const

Properties

◆ sortColumn

int QFileSystemModelSorter::sortColumn
private

Definition at line 1142 of file qfilesystemmodel.cpp.


The documentation for this class was generated from the following file: