Qt 4.8
Classes | Public Functions | Static Public Functions | Public Variables | List of all members
QDirModelPrivate Class Reference
Inheritance diagram for QDirModelPrivate:
QAbstractItemModelPrivate QObjectPrivate QObjectData

Classes

struct  QDirNode
 
struct  SavedPersistent
 

Public Functions

void _q_refresh ()
 
void appendChild (QDirModelPrivate::QDirNode *parent, const QString &path) const
 
QVector< QDirNodechildren (QDirNode *parent, bool stat) const
 
void clear (QDirNode *parent) const
 
QFileInfoList entryInfoList (const QString &path) const
 
QStringList entryList (const QString &path) const
 
void init ()
 
void invalidate ()
 
QString name (const QModelIndex &index) const
 
QDirNodenode (int row, QDirNode *parent) const
 
QDirNodenode (const QModelIndex &index) const
 
void populate (QDirNode *parent) const
 
 QDirModelPrivate ()
 
void restorePersistentIndexes ()
 
void savePersistentIndexes ()
 
QString size (const QModelIndex &index) const
 
QString time (const QModelIndex &index) const
 
QString type (const QModelIndex &index) const
 
- Public Functions inherited from QAbstractItemModelPrivate
bool allowMove (const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation orientation)
 Returns whether a move operation is valid. More...
 
void columnsAboutToBeInserted (const QModelIndex &parent, int first, int last)
 
void columnsAboutToBeRemoved (const QModelIndex &parent, int first, int last)
 
void columnsInserted (const QModelIndex &parent, int first, int last)
 
void columnsRemoved (const QModelIndex &parent, int first, int last)
 
QModelIndex createIndex (int row, int column, void *data=0) const
 
QModelIndex createIndex (int row, int column, int id) const
 
bool indexValid (const QModelIndex &index) const
 
void invalidatePersistentIndex (const QModelIndex &index)
 
void invalidatePersistentIndexes ()
 
void itemsAboutToBeMoved (const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation)
 
void itemsMoved (const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation orientation)
 
void movePersistentIndexes (QVector< QPersistentModelIndexData *> indexes, int change, const QModelIndex &parent, Qt::Orientation orientation)
 Moves persistent indexes indexes by amount change. More...
 
 QAbstractItemModelPrivate ()
 
void removePersistentIndexData (QPersistentModelIndexData *data)
 
void rowsAboutToBeInserted (const QModelIndex &parent, int first, int last)
 
void rowsAboutToBeRemoved (const QModelIndex &parent, int first, int last)
 
void rowsInserted (const QModelIndex &parent, int first, int last)
 
void rowsRemoved (const QModelIndex &parent, int first, int last)
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static QFileInfo resolvedInfo (QFileInfo info)
 
- Static Public Functions inherited from QAbstractItemModelPrivate
static const QHash< int, QByteArray > & defaultRoleNames ()
 
static QAbstractItemModelstaticEmptyModel ()
 
static bool variantLessThan (const QVariant &v1, const QVariant &v2)
 This function is used by our Q{Tree,Widget,Table}WidgetModel classes to sort. More...
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

bool allowAppendChild
 
QFileIconProvider defaultProvider
 
QDir::Filters filters
 
QFileIconProvidericonProvider
 
bool lazyChildCount
 
QStringList nameFilters
 
bool readOnly
 
bool resolveSymlinks
 
QDirNode root
 
QList< SavedPersistentsavedPersistent
 
bool shouldStat
 
QDir::SortFlags sort
 
QPersistentModelIndex toBeRefreshed
 
- Public Variables inherited from QAbstractItemModelPrivate
QStack< Changechanges
 
struct QAbstractItemModelPrivate::Persistent persistent
 
QHash< int, QByteArrayroleNames
 
Qt::DropActions supportedDragActions
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Detailed Description

Definition at line 69 of file qdirmodel.cpp.

Constructors and Destructors

◆ QDirModelPrivate()

QDirModelPrivate::QDirModelPrivate ( )
inline

Definition at line 86 of file qdirmodel.cpp.

87  : resolveSymlinks(true),
88  readOnly(true),
89  lazyChildCount(false),
90  allowAppendChild(true),
92  shouldStat(true) // ### This is set to false by QFileDialog
93  { }
QFileIconProvider * iconProvider
Definition: qdirmodel.cpp:131
QFileIconProvider defaultProvider
Definition: qdirmodel.cpp:132

Functions

◆ _q_refresh()

void QDirModelPrivate::_q_refresh ( )

Definition at line 1250 of file qdirmodel.cpp.

Referenced by QDirModelPrivate().

1251 {
1252  Q_Q(QDirModel);
1253  q->refresh(toBeRefreshed);
1255 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QModelIndex class is used to locate data in a data model.
QPersistentModelIndex toBeRefreshed
Definition: qdirmodel.cpp:141
The QDirModel class provides a data model for the local filesystem.
Definition: qdirmodel.h:59

◆ appendChild()

void QDirModelPrivate::appendChild ( QDirModelPrivate::QDirNode parent,
const QString path 
) const

Definition at line 1374 of file qdirmodel.cpp.

Referenced by QDirModelPrivate().

1375 {
1377  node.populated = false;
1378  node.stat = shouldStat;
1379  node.parent = (parent == &root ? 0 : parent);
1380  node.info = QFileInfo(path);
1381  node.info.setCaching(true);
1382 
1383  // The following append(node) may reallocate the vector, thus
1384  // we need to update the pointers to the childnodes parent.
1385  QDirModelPrivate *that = const_cast<QDirModelPrivate *>(this);
1386  that->savePersistentIndexes();
1387  parent->children.append(node);
1388  for (int i = 0; i < parent->children.count(); ++i) {
1389  QDirNode *childNode = &parent->children[i];
1390  for (int j = 0; j < childNode->children.count(); ++j)
1391  childNode->children[j].parent = childNode;
1392  }
1393  that->restorePersistentIndexes();
1394 }
void setCaching(bool on)
If enable is true, enables caching of file information.
Definition: qfileinfo.cpp:1364
QVector< QDirNode > children
Definition: qdirmodel.cpp:81
void restorePersistentIndexes()
Definition: qdirmodel.cpp:1272
QDirNode * node(int row, QDirNode *parent) const
Definition: qdirmodel.cpp:1195
void savePersistentIndexes()
Definition: qdirmodel.cpp:1257
QObject * parent
Definition: qobject.h:92
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ children()

QVector< QDirModelPrivate::QDirNode > QDirModelPrivate::children ( QDirNode parent,
bool  stat 
) const

Definition at line 1213 of file qdirmodel.cpp.

1214 {
1215  Q_ASSERT(parent);
1216  QFileInfoList infoList;
1217  if (parent == &root) {
1218  parent = 0;
1219  infoList = QDir::drives();
1220  } else if (parent->info.isDir()) {
1221  //resolve directory links only if requested.
1222  if (parent->info.isSymLink() && resolveSymlinks) {
1223  QString link = parent->info.symLinkTarget();
1224  if (link.size() > 1 && link.at(link.size() - 1) == QDir::separator())
1225  link.chop(1);
1226  if (stat)
1227  infoList = entryInfoList(link);
1228  else
1230  } else {
1231  if (stat)
1232  infoList = entryInfoList(parent->info.absoluteFilePath());
1233  else
1234  infoList = QDir(parent->info.absoluteFilePath()).entryInfoList(nameFilters, QDir::AllEntries | QDir::System);
1235  }
1236  }
1237 
1238  QVector<QDirNode> nodes(infoList.count());
1239  for (int i = 0; i < infoList.count(); ++i) {
1240  QDirNode &node = nodes[i];
1241  node.parent = parent;
1242  node.info = infoList.at(i);
1243  node.populated = false;
1244  node.stat = shouldStat;
1245  }
1246 
1247  return nodes;
1248 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
void chop(int n)
Removes n characters from the end of the string.
Definition: qstring.cpp:4623
QFileInfoList entryInfoList(const QString &path) const
Definition: qdirmodel.cpp:1295
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
static QChar separator()
Returns the native directory separator: "/" under Unix (including Mac OS X) and "\\" under Windows...
Definition: qdir.cpp:1831
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QFileInfoList entryInfoList(Filters filters=NoFilter, SortFlags sort=NoSort) const
Returns a list of QFileInfo objects for all the files and directories in the directory, ordered according to the name and attribute filters previously set with setNameFilters() and setFilter(), and sorted according to the flags set with setSorting().
Definition: qdir.cpp:1316
static QFileInfoList drives()
Returns a list of the root directories on this system.
Definition: qdir.cpp:1812
QDirNode * node(int row, QDirNode *parent) const
Definition: qdirmodel.cpp:1195
QObject * parent
Definition: qobject.h:92
QStringList nameFilters
Definition: qdirmodel.cpp:129

◆ clear()

void QDirModelPrivate::clear ( QDirNode parent) const
inline

Definition at line 166 of file qdirmodel.cpp.

Referenced by QDirModelPrivate().

167 {
168  Q_ASSERT(parent);
169  parent->children.clear();
170  parent->populated = false;
171 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void clear()
Removes all items from the list.
Definition: qlist.h:764
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
QObject * parent
Definition: qobject.h:92

◆ entryInfoList()

QFileInfoList QDirModelPrivate::entryInfoList ( const QString path) const

Definition at line 1295 of file qdirmodel.cpp.

Referenced by QDirModelPrivate().

1296 {
1297  const QDir dir(path);
1298  return dir.entryInfoList(nameFilters, filters, sort);
1299 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
QDir::SortFlags sort
Definition: qdirmodel.cpp:128
QDir::Filters filters
Definition: qdirmodel.cpp:127
QStringList nameFilters
Definition: qdirmodel.cpp:129

◆ entryList()

QStringList QDirModelPrivate::entryList ( const QString path) const

Definition at line 1301 of file qdirmodel.cpp.

Referenced by QDirModelPrivate().

1302 {
1303  const QDir dir(path);
1304  return dir.entryList(nameFilters, filters, sort);
1305 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
QDir::SortFlags sort
Definition: qdirmodel.cpp:128
QDir::Filters filters
Definition: qdirmodel.cpp:127
QStringList nameFilters
Definition: qdirmodel.cpp:129

◆ init()

void QDirModelPrivate::init ( )

Definition at line 1179 of file qdirmodel.cpp.

Referenced by QDirModelPrivate().

1180 {
1181  Q_Q(QDirModel);
1183  sort = QDir::Name;
1184  nameFilters << QLatin1String("*");
1185  root.parent = 0;
1186  root.info = QFileInfo();
1187  clear(&root);
1188  QHash<int, QByteArray> roles = q->roleNames();
1189  roles.insertMulti(QDirModel::FileIconRole, "fileIcon"); // == Qt::decoration
1190  roles.insert(QDirModel::FilePathRole, "filePath");
1191  roles.insert(QDirModel::FileNameRole, "fileName");
1192  q->setRoleNames(roles);
1193 }
void clear(QDirNode *parent) const
Definition: qdirmodel.cpp:166
QDir::SortFlags sort
Definition: qdirmodel.cpp:128
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
#define Q_Q(Class)
Definition: qglobal.h:2483
QDir::Filters filters
Definition: qdirmodel.cpp:127
iterator insertMulti(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:772
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
The QDirModel class provides a data model for the local filesystem.
Definition: qdirmodel.h:59
QStringList nameFilters
Definition: qdirmodel.cpp:129

◆ invalidate()

void QDirModelPrivate::invalidate ( )

Definition at line 173 of file qdirmodel.cpp.

Referenced by QDirModelPrivate().

174 {
176  nodes.push(&root);
177  while (!nodes.empty()) {
178  const QDirNode *current = nodes.pop();
179  current->stat = false;
180  const QVector<QDirNode> children = current->children;
181  for (int i = 0; i < children.count(); ++i)
182  nodes.push(&children.at(i));
183  }
184 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
The QStack class is a template class that provides a stack.
Definition: qcontainerfwd.h:63
QVector< QDirNode > children(QDirNode *parent, bool stat) const
Definition: qdirmodel.cpp:1213
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
bool empty() const
This function is provided for STL compatibility.
Definition: qvector.h:285
T pop()
Removes the top item from the stack and returns it.
Definition: qstack.h:67
void push(const T &t)
Adds element t to the top of the stack.
Definition: qstack.h:60
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350

◆ name()

QString QDirModelPrivate::name ( const QModelIndex index) const

Definition at line 1307 of file qdirmodel.cpp.

Referenced by QDirModelPrivate().

1308 {
1309  const QDirNode *n = node(index);
1310  const QFileInfo info = n->info;
1311  if (info.isRoot()) {
1312  QString name = info.absoluteFilePath();
1313 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
1314  if (name.startsWith(QLatin1Char('/'))) // UNC host
1315  return info.fileName();
1316 #endif
1317 #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
1318  if (name.endsWith(QLatin1Char('/')))
1319  name.chop(1);
1320 #endif
1321  return name;
1322  }
1323  return info.fileName();
1324 }
static mach_timebase_info_data_t info
void chop(int n)
Removes n characters from the end of the string.
Definition: qstring.cpp:4623
QString fileName() const
Returns the name of the file, excluding the path.
Definition: qfileinfo.cpp:726
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QString absoluteFilePath() const
Returns an absolute path including the file name.
Definition: qfileinfo.cpp:534
The QString class provides a Unicode character string.
Definition: qstring.h:83
QDirNode * node(int row, QDirNode *parent) const
Definition: qdirmodel.cpp:1195
bool isRoot() const
Returns true if the object points to a directory or to a symbolic link to a directory, and that directory is the root directory; otherwise returns false.
Definition: qfileinfo.cpp:1062
QString name(const QModelIndex &index) const
Definition: qdirmodel.cpp:1307
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ node() [1/2]

QDirModelPrivate::QDirNode * QDirModelPrivate::node ( int  row,
QDirNode parent 
) const

Definition at line 1195 of file qdirmodel.cpp.

Referenced by QDirModelPrivate().

1196 {
1197  if (row < 0)
1198  return 0;
1199 
1200  bool isDir = !parent || parent->info.isDir();
1201  QDirNode *p = (parent ? parent : &root);
1202  if (isDir && !p->populated)
1203  populate(p); // will also resolve symlinks
1204 
1205  if (row >= p->children.count()) {
1206  qWarning("node: the row does not exist");
1207  return 0;
1208  }
1209 
1210  return const_cast<QDirNode*>(&p->children.at(row));
1211 }
Q_CORE_EXPORT void qWarning(const char *,...)
QObject * parent
Definition: qobject.h:92
void populate(QDirNode *parent) const
Definition: qdirmodel.cpp:159

◆ node() [2/2]

QDirModelPrivate::QDirNode * QDirModelPrivate::node ( const QModelIndex index) const
inline

Definition at line 151 of file qdirmodel.cpp.

152 {
154  static_cast<QDirModelPrivate::QDirNode*>(index.internalPointer());
155  Q_ASSERT(n);
156  return n;
157 }
void * internalPointer() const
Returns a void * pointer used by the model to associate the index with the internal data structure...
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ populate()

void QDirModelPrivate::populate ( QDirNode parent) const
inline

Definition at line 159 of file qdirmodel.cpp.

Referenced by QDirModelPrivate().

160 {
161  Q_ASSERT(parent);
162  parent->children = children(parent, parent->stat);
163  parent->populated = true;
164 }
QVector< QDirNode > children(QDirNode *parent, bool stat) const
Definition: qdirmodel.cpp:1213
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
QObject * parent
Definition: qobject.h:92

◆ resolvedInfo()

QFileInfo QDirModelPrivate::resolvedInfo ( QFileInfo  info)
static

Definition at line 1396 of file qdirmodel.cpp.

Referenced by QDirModelPrivate().

1397 {
1398 #ifdef Q_OS_WIN
1399  // On windows, we cannot create a shortcut to a shortcut.
1400  return QFileInfo(info.symLinkTarget());
1401 #else
1402  QStringList paths;
1403  do {
1404  QFileInfo link(info.symLinkTarget());
1405  if (link.isRelative())
1406  info.setFile(info.absolutePath(), link.filePath());
1407  else
1408  info = link;
1409  if (paths.contains(info.absoluteFilePath()))
1410  return QFileInfo();
1411  paths.append(info.absoluteFilePath());
1412  } while (info.isSymLink());
1413  return info;
1414 #endif
1415 }
static mach_timebase_info_data_t info
QString absoluteFilePath() const
Returns an absolute path including the file name.
Definition: qfileinfo.cpp:534
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
void setFile(const QString &file)
Sets the file that the QFileInfo provides information about to file.
Definition: qfileinfo.cpp:468
QString symLinkTarget() const
Returns the absolute path to the file or directory a symlink (or shortcut on Windows) points to...
Definition: qfileinfo.h:121
bool isSymLink() const
Returns true if this object points to a symbolic link (or to a shortcut on Windows); otherwise return...
Definition: qfileinfo.cpp:1044
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
QString absolutePath() const
Returns a file&#39;s path absolute path.
Definition: qfileinfo.cpp:577

◆ restorePersistentIndexes()

void QDirModelPrivate::restorePersistentIndexes ( )

Definition at line 1272 of file qdirmodel.cpp.

Referenced by appendChild(), and QDirModelPrivate().

1273 {
1274  Q_Q(QDirModel);
1275  bool allow = allowAppendChild;
1276  allowAppendChild = false;
1277  for (int i = 0; i < savedPersistent.count(); ++i) {
1279  QString path = savedPersistent.at(i).path;
1280  int column = savedPersistent.at(i).column;
1281  QModelIndex idx = q->index(path, column);
1282  if (idx != data->index || data->model == 0) {
1283  //data->model may be equal to 0 if the model is getting destroyed
1284  persistent.indexes.remove(data->index);
1285  data->index = idx;
1286  data->model = q;
1287  if (idx.isValid())
1288  persistent.indexes.insert(idx, data);
1289  }
1290  }
1291  savedPersistent.clear();
1292  allowAppendChild = allow;
1293 }
int remove(const Key &key)
Removes all the items that have the key from the hash.
Definition: qhash.h:784
QHash< QModelIndex, QPersistentModelIndexData * > indexes
The QString class provides a Unicode character string.
Definition: qstring.h:83
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
#define Q_Q(Class)
Definition: qglobal.h:2483
const QAbstractItemModel * model
static const char * data(const QByteArray &arr)
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
struct QAbstractItemModelPrivate::Persistent persistent
The QModelIndex class is used to locate data in a data model.
The QDirModel class provides a data model for the local filesystem.
Definition: qdirmodel.h:59
QList< SavedPersistent > savedPersistent
Definition: qdirmodel.cpp:140

◆ savePersistentIndexes()

void QDirModelPrivate::savePersistentIndexes ( )

Definition at line 1257 of file qdirmodel.cpp.

Referenced by appendChild(), and QDirModelPrivate().

1258 {
1259  Q_Q(QDirModel);
1260  savedPersistent.clear();
1262  SavedPersistent saved;
1263  QModelIndex index = data->index;
1264  saved.path = q->filePath(index);
1265  saved.column = index.column();
1266  saved.data = data;
1267  saved.index = index;
1268  savedPersistent.append(saved);
1269  }
1270 }
QHash< QModelIndex, QPersistentModelIndexData * > indexes
#define Q_Q(Class)
Definition: qglobal.h:2483
static const char * data(const QByteArray &arr)
struct QAbstractItemModelPrivate::Persistent persistent
The QModelIndex class is used to locate data in a data model.
quint16 index
The QDirModel class provides a data model for the local filesystem.
Definition: qdirmodel.h:59
QList< SavedPersistent > savedPersistent
Definition: qdirmodel.cpp:140
int column() const
Returns the column this model index refers to.

◆ size()

QString QDirModelPrivate::size ( const QModelIndex index) const

Definition at line 1326 of file qdirmodel.cpp.

Referenced by QDirModelPrivate().

1327 {
1328  const QDirNode *n = node(index);
1329  if (n->info.isDir()) {
1330 #ifdef Q_OS_MAC
1331  return QLatin1String("--");
1332 #else
1333  return QLatin1String("");
1334 #endif
1335  // Windows - ""
1336  // OS X - "--"
1337  // Konqueror - "4 KB"
1338  // Nautilus - "9 items" (the number of children)
1339  }
1340 
1341  // According to the Si standard KB is 1000 bytes, KiB is 1024
1342  // but on windows sizes are calulated by dividing by 1024 so we do what they do.
1343  const quint64 kb = 1024;
1344  const quint64 mb = 1024 * kb;
1345  const quint64 gb = 1024 * mb;
1346  const quint64 tb = 1024 * gb;
1347  quint64 bytes = n->info.size();
1348  if (bytes >= tb)
1349  return QFileSystemModel::tr("%1 TB").arg(QLocale().toString(qreal(bytes) / tb, 'f', 3));
1350  if (bytes >= gb)
1351  return QFileSystemModel::tr("%1 GB").arg(QLocale().toString(qreal(bytes) / gb, 'f', 2));
1352  if (bytes >= mb)
1353  return QFileSystemModel::tr("%1 MB").arg(QLocale().toString(qreal(bytes) / mb, 'f', 1));
1354  if (bytes >= kb)
1355  return QFileSystemModel::tr("%1 KB").arg(QLocale().toString(bytes / kb));
1356  return QFileSystemModel::tr("%1 byte(s)").arg(QLocale().toString(bytes));
1357 }
double qreal
Definition: qglobal.h:1193
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QString toString(Register *reg, int type, bool *ok=0)
unsigned __int64 quint64
Definition: qglobal.h:943
QDirNode * node(int row, QDirNode *parent) const
Definition: qdirmodel.cpp:1195
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186

◆ time()

QString QDirModelPrivate::time ( const QModelIndex index) const

Definition at line 1364 of file qdirmodel.cpp.

Referenced by QDirModelPrivate().

1365 {
1366 #ifndef QT_NO_DATESTRING
1367  return node(index)->info.lastModified().toString(Qt::LocalDate);
1368 #else
1369  Q_UNUSED(index);
1370  return QString();
1371 #endif
1372 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the datetime as a string in the format given.
Definition: qdatetime.cpp:2628
QDirNode * node(int row, QDirNode *parent) const
Definition: qdirmodel.cpp:1195
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QDateTime lastModified() const
Returns the date and time when the file was last modified.
Definition: qfileinfo.cpp:1296

◆ type()

QString QDirModelPrivate::type ( const QModelIndex index) const

Definition at line 1359 of file qdirmodel.cpp.

Referenced by QDirModelPrivate().

1360 {
1361  return iconProvider->type(node(index)->info);
1362 }
static mach_timebase_info_data_t info
virtual QString type(const QFileInfo &info) const
Returns the type of the file described by info.
QFileIconProvider * iconProvider
Definition: qdirmodel.cpp:131
QDirNode * node(int row, QDirNode *parent) const
Definition: qdirmodel.cpp:1195

Properties

◆ allowAppendChild

bool QDirModelPrivate::allowAppendChild

Definition at line 125 of file qdirmodel.cpp.

◆ defaultProvider

QFileIconProvider QDirModelPrivate::defaultProvider

Definition at line 132 of file qdirmodel.cpp.

◆ filters

QDir::Filters QDirModelPrivate::filters

Definition at line 127 of file qdirmodel.cpp.

◆ iconProvider

QFileIconProvider* QDirModelPrivate::iconProvider

Definition at line 131 of file qdirmodel.cpp.

◆ lazyChildCount

bool QDirModelPrivate::lazyChildCount

Definition at line 124 of file qdirmodel.cpp.

◆ nameFilters

QStringList QDirModelPrivate::nameFilters

Definition at line 129 of file qdirmodel.cpp.

◆ readOnly

bool QDirModelPrivate::readOnly

Definition at line 123 of file qdirmodel.cpp.

◆ resolveSymlinks

bool QDirModelPrivate::resolveSymlinks

Definition at line 122 of file qdirmodel.cpp.

◆ root

QDirNode QDirModelPrivate::root
mutable

Definition at line 121 of file qdirmodel.cpp.

Referenced by invalidate().

◆ savedPersistent

QList<SavedPersistent> QDirModelPrivate::savedPersistent

Definition at line 140 of file qdirmodel.cpp.

◆ shouldStat

bool QDirModelPrivate::shouldStat

Definition at line 143 of file qdirmodel.cpp.

Referenced by qt_setDirModelShouldNotStat().

◆ sort

QDir::SortFlags QDirModelPrivate::sort

Definition at line 128 of file qdirmodel.cpp.

◆ toBeRefreshed

QPersistentModelIndex QDirModelPrivate::toBeRefreshed

Definition at line 141 of file qdirmodel.cpp.


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