QFileInfo: inline the file-time methods

As instructed in a // ### Qt6 comment
Added missing #include for QDateTime.

Change-Id: Ic1f9e6ec42ecae07d037b84943444785847bdf98
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Edward Welbourne 2020-07-16 14:25:05 +02:00
parent fe6a1d34dc
commit 8b7bde6c49
2 changed files with 11 additions and 22 deletions

View File

@ -1377,6 +1377,7 @@ qint64 QFileInfo::size() const
}
/*!
\fn QDateTime QFileInfo::birthTime() const
\since 5.10
Returns the date and time when the file was created / born.
@ -1388,12 +1389,9 @@ qint64 QFileInfo::size() const
\sa lastModified(), lastRead(), metadataChangeTime()
*/
QDateTime QFileInfo::birthTime() const
{
return fileTime(QFile::FileBirthTime);
}
/*!
\fn QDateTime QFileInfo::metadataChangeTime() const
\since 5.10
Returns the date and time when the file metadata was changed. A metadata
change occurs when the file is created, but it also occurs whenever the
@ -1405,12 +1403,10 @@ QDateTime QFileInfo::birthTime() const
\sa lastModified(), lastRead()
*/
QDateTime QFileInfo::metadataChangeTime() const
{
return fileTime(QFile::FileMetadataChangeTime);
}
/*!
\fn QDateTime QFileInfo::lastModified() const
Returns the date and local time when the file was last modified.
If the file is a symlink, the time of the target file is returned
@ -1418,12 +1414,10 @@ QDateTime QFileInfo::metadataChangeTime() const
\sa birthTime(), lastRead(), metadataChangeTime(), fileTime()
*/
QDateTime QFileInfo::lastModified() const
{
return fileTime(QFile::FileModificationTime);
}
/*!
\fn QDateTime QFileInfo::lastRead() const
Returns the date and local time when the file was last read (accessed).
On platforms where this information is not available, returns the
@ -1434,10 +1428,6 @@ QDateTime QFileInfo::lastModified() const
\sa birthTime(), lastModified(), metadataChangeTime(), fileTime()
*/
QDateTime QFileInfo::lastRead() const
{
return fileTime(QFile::FileAccessTime);
}
/*!
\since 5.10

View File

@ -44,13 +44,13 @@
#include <QtCore/qlist.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qmetatype.h>
#include <QtCore/qdatetime.h>
QT_BEGIN_NAMESPACE
class QDir;
class QDirIteratorPrivate;
class QDateTime;
class QFileInfoPrivate;
class Q_CORE_EXPORT QFileInfo
@ -167,11 +167,10 @@ public:
qint64 size() const;
// ### Qt6: inline these functions
QDateTime birthTime() const;
QDateTime metadataChangeTime() const;
QDateTime lastModified() const;
QDateTime lastRead() const;
QDateTime birthTime() const { return fileTime(QFile::FileBirthTime); }
QDateTime metadataChangeTime() const { return fileTime(QFile::FileMetadataChangeTime); }
QDateTime lastModified() const { return fileTime(QFile::FileModificationTime); }
QDateTime lastRead() const { return fileTime(QFile::FileAccessTime); }
QDateTime fileTime(QFile::FileTime time) const;
bool caching() const;