De-inline QFileSystemModel::fileInfo() and implement it efficiently
De-inline the method, and return the file info that's already being cached by the model. This is ok to do in a minor release, as apps compiled against an older version of Qt will simply continue to use the less efficient implementation. Change-Id: I164c7961a8cf97447638af316512326442767dd8 Task-number: QTBUG-30902 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>bb10
parent
678a4273a3
commit
61cefb2f7a
|
|
@ -154,6 +154,11 @@ QT_BEGIN_NAMESPACE
|
|||
Returns the QFileInfo for the item stored in the model under the given
|
||||
\a index.
|
||||
*/
|
||||
QFileInfo QFileSystemModel::fileInfo(const QModelIndex &index) const
|
||||
{
|
||||
Q_D(const QFileSystemModel);
|
||||
return d->node(index)->fileInfo();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QFileSystemModel::rootPathChanged(const QString &newPath);
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ public:
|
|||
inline QString fileName(const QModelIndex &index) const;
|
||||
inline QIcon fileIcon(const QModelIndex &index) const;
|
||||
QFile::Permissions permissions(const QModelIndex &index) const;
|
||||
inline QFileInfo fileInfo(const QModelIndex &index) const;
|
||||
QFileInfo fileInfo(const QModelIndex &index) const;
|
||||
bool remove(const QModelIndex &index);
|
||||
|
||||
protected:
|
||||
|
|
@ -156,8 +156,6 @@ inline QString QFileSystemModel::fileName(const QModelIndex &aindex) const
|
|||
{ return aindex.data(Qt::DisplayRole).toString(); }
|
||||
inline QIcon QFileSystemModel::fileIcon(const QModelIndex &aindex) const
|
||||
{ return qvariant_cast<QIcon>(aindex.data(Qt::DecorationRole)); }
|
||||
inline QFileInfo QFileSystemModel::fileInfo(const QModelIndex &aindex) const
|
||||
{ return QFileInfo(filePath(aindex)); }
|
||||
|
||||
#endif // QT_NO_FILESYSTEMMODEL
|
||||
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ public:
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
inline QFileInfo fileInfo() const { if (info) return info->fileInfo(); return QFileInfo(); }
|
||||
inline bool isFile() const { if (info) return info->isFile(); return true; }
|
||||
inline bool isSystem() const { if (info) return info->isSystem(); return true; }
|
||||
inline bool isHidden() const { if (info) return info->isHidden(); return false; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue