Functions | Variables
qdir.cpp File Reference
#include "qglobal.h"
#include "qdir.h"
#include "qfileinfo.h"
#include "qfiledefs_p.h"
#include "qregexp.h"
#include "qstringlist.h"
#include <stdlib.h>
#include <ctype.h>

Go to the source code of this file.

Functions

QStringList qt_makeFilterList (const QString &filter)
 
int qt_cmp_si (const void *n1, const void *n2)
 

Variables

int qt_cmp_si_sortSpec
 

Function Documentation

int qt_cmp_si ( const void *  n1,
const void *  n2 
)

Definition at line 1145 of file qdir.cpp.

1146 {
1147  if ( !n1 || !n2 )
1148  return 0;
1149 
1150  QDirSortItem* f1 = (QDirSortItem*)n1;
1151  QDirSortItem* f2 = (QDirSortItem*)n2;
1152 
1154  if ( f1->item->isDir() != f2->item->isDir() )
1155  return f1->item->isDir() ? -1 : 1;
1156 
1157  int r = 0;
1158  int sortBy = qt_cmp_si_sortSpec & QDir::SortByMask;
1159 
1160  switch ( sortBy ) {
1161  case QDir::Time:
1162  r = f1->item->lastModified().secsTo(f2->item->lastModified());
1163  break;
1164  case QDir::Size:
1165  r = f2->item->size() - f1->item->size();
1166  break;
1167  default:
1168  ;
1169  }
1170 
1171  if ( r == 0 && sortBy != QDir::Unsorted ) {
1172  // Still not sorted - sort by name
1174 
1175  if ( f1->filename_cache.isNull() )
1176  f1->filename_cache = ic ? f1->item->fileName().lower()
1177  : f1->item->fileName();
1178  if ( f2->filename_cache.isNull() )
1179  f2->filename_cache = ic ? f2->item->fileName().lower()
1180  : f2->item->fileName();
1181 
1182  r = f1->filename_cache.compare(f2->filename_cache);
1183  }
1184 
1185  if ( r == 0 ) {
1186  // Enforce an order - the order the items appear in the array
1187  r = (int)((char*)n1 - (char*)n2);
1188  }
1189 
1191  return -r;
1192  else
1193  return r;
1194 }
QString lower() const
Definition: qstring.cpp:13375
int compare(const QString &s) const
Definition: qstring.cpp:14838
int secsTo(const QDateTime &) const
Definition: qdatetime.cpp:1260
QString filename_cache
Definition: qdir.h:230
uint size() const
QFileInfo * item
Definition: qdir.h:231
QDateTime lastModified() const
QString fileName() const
bool isNull() const
Definition: qstring.h:379
bool isDir() const
int qt_cmp_si_sortSpec
Definition: qdir.cpp:1139
QStringList qt_makeFilterList ( const QString filter)

Definition at line 1010 of file qdir.cpp.

1011 {
1012  if ( filter.isEmpty() )
1013  return QStringList();
1014 
1015  QChar sep( ';' );
1016  int i = filter.find( sep, 0 );
1017  if ( i == -1 && filter.find( ' ', 0 ) != -1 )
1018  sep = QChar( ' ' );
1019 
1020  QStringList lst = QStringList::split( sep, filter );
1021  QStringList lst2;
1022  QStringList::Iterator it = lst.begin();
1023 
1024  for ( ; it != lst.end(); ++it ) {
1025  QString s = *it;
1026  lst2 << s.stripWhiteSpace();
1027  }
1028  return lst2;
1029 }
bool isEmpty() const
Definition: qstring.h:682
Iterator end()
Definition: qvaluelist.h:363
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
The QChar class provides a light-weight Unicode character.
Definition: qstring.h:56
A list of strings.
Definition: qstringlist.h:51
QString stripWhiteSpace() const
Definition: qstring.cpp:13438
int find(QChar c, int index=0, bool cs=TRUE) const
Definition: qstring.cpp:12902
Iterator begin()
Definition: qvaluelist.h:361
static QStringList split(const QString &sep, const QString &str, bool allowEmptyEntries=FALSE)
static QCString * s
Definition: config.cpp:1042

Variable Documentation

int qt_cmp_si_sortSpec

Definition at line 1139 of file qdir.cpp.