Port QDir's implementation to use Q_D() and d_func()

It had the d_func()s it needed, but wasn't using them.
This prepares the way for QEDSP-ification.

Pick-to: 6.4
Task-number: QTBUG-105753
Change-Id: I8b7ba79818f27ae6a2281b276b95b94673f05648
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Edward Welbourne 2022-10-13 18:07:25 +02:00
parent 0de7e7a066
commit 62a4fe434d

View File

@ -602,7 +602,7 @@ void QDir::setPath(const QString &path)
*/
QString QDir::path() const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
return d->dirEntry.filePath();
}
@ -616,7 +616,7 @@ QString QDir::path() const
*/
QString QDir::absolutePath() const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
d->resolveAbsoluteEntry();
return d->absoluteDirEntry.filePath();
}
@ -639,7 +639,7 @@ QString QDir::absolutePath() const
*/
QString QDir::canonicalPath() const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
if (!d->fileEngine) {
QFileSystemEntry answer = QFileSystemEngine::canonicalName(d->dirEntry, d->metaData);
return answer.filePath();
@ -660,7 +660,7 @@ QString QDir::canonicalPath() const
*/
QString QDir::dirName() const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
return d->dirEntry.fileName();
}
@ -724,7 +724,7 @@ QString QDir::filePath(const QString &fileName) const
if (treatAsAbsolute(fileName))
return fileName;
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
QString ret = d->dirEntry.filePath();
if (fileName.isEmpty())
return ret;
@ -755,7 +755,7 @@ QString QDir::absoluteFilePath(const QString &fileName) const
if (treatAsAbsolute(fileName))
return fileName;
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
d->resolveAbsoluteEntry();
const QString absoluteDirPath = d->absoluteDirEntry.filePath();
if (fileName.isEmpty())
@ -991,7 +991,7 @@ bool QDir::cdUp()
*/
QStringList QDir::nameFilters() const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
return d->nameFilters;
}
@ -1012,7 +1012,7 @@ QStringList QDir::nameFilters() const
*/
void QDir::setNameFilters(const QStringList &nameFilters)
{
QDirPrivate* d = d_ptr.data();
Q_D(QDir);
d->initFileEngine();
d->clearFileLists();
@ -1114,7 +1114,7 @@ QStringList QDir::searchPaths(const QString &prefix)
*/
QDir::Filters QDir::filter() const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
return d->filters;
}
@ -1193,7 +1193,7 @@ QDir::Filters QDir::filter() const
*/
void QDir::setFilter(Filters filters)
{
QDirPrivate* d = d_ptr.data();
Q_D(QDir);
d->initFileEngine();
d->clearFileLists();
@ -1207,7 +1207,7 @@ void QDir::setFilter(Filters filters)
*/
QDir::SortFlags QDir::sorting() const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
return d->sort;
}
@ -1250,7 +1250,7 @@ QDir::SortFlags QDir::sorting() const
*/
void QDir::setSorting(SortFlags sort)
{
QDirPrivate* d = d_ptr.data();
Q_D(QDir);
d->initFileEngine();
d->clearFileLists();
@ -1269,7 +1269,7 @@ void QDir::setSorting(SortFlags sort)
*/
qsizetype QDir::count(QT6_IMPL_NEW_OVERLOAD) const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
d->initFileLists(*this);
return d->files.count();
}
@ -1285,7 +1285,7 @@ qsizetype QDir::count(QT6_IMPL_NEW_OVERLOAD) const
*/
QString QDir::operator[](qsizetype pos) const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
d->initFileLists(*this);
return d->files[pos];
}
@ -1311,7 +1311,7 @@ QString QDir::operator[](qsizetype pos) const
*/
QStringList QDir::entryList(Filters filters, SortFlags sort) const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
return entryList(d->nameFilters, filters, sort);
}
@ -1334,7 +1334,7 @@ QStringList QDir::entryList(Filters filters, SortFlags sort) const
*/
QFileInfoList QDir::entryInfoList(Filters filters, SortFlags sort) const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
return entryInfoList(d->nameFilters, filters, sort);
}
@ -1357,7 +1357,7 @@ QFileInfoList QDir::entryInfoList(Filters filters, SortFlags sort) const
QStringList QDir::entryList(const QStringList &nameFilters, Filters filters,
SortFlags sort) const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
if (filters == NoFilter)
filters = d->filters;
@ -1397,7 +1397,7 @@ QStringList QDir::entryList(const QStringList &nameFilters, Filters filters,
QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filters,
SortFlags sort) const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
if (filters == NoFilter)
filters = d->filters;
@ -1440,7 +1440,7 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter
*/
bool QDir::mkdir(const QString &dirName, QFile::Permissions permissions) const
{
const QDirPrivate *d = d_ptr.constData();
Q_D(const QDir);
if (dirName.isEmpty()) {
qWarning("QDir::mkdir: Empty or null file name");
@ -1462,7 +1462,7 @@ bool QDir::mkdir(const QString &dirName, QFile::Permissions permissions) const
*/
bool QDir::mkdir(const QString &dirName) const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
if (dirName.isEmpty()) {
qWarning("QDir::mkdir: Empty or null file name");
@ -1486,7 +1486,7 @@ bool QDir::mkdir(const QString &dirName) const
*/
bool QDir::rmdir(const QString &dirName) const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
if (dirName.isEmpty()) {
qWarning("QDir::rmdir: Empty or null file name");
@ -1514,7 +1514,7 @@ bool QDir::rmdir(const QString &dirName) const
*/
bool QDir::mkpath(const QString &dirPath) const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
if (dirPath.isEmpty()) {
qWarning("QDir::mkpath: Empty or null file name");
@ -1540,7 +1540,7 @@ bool QDir::mkpath(const QString &dirPath) const
*/
bool QDir::rmpath(const QString &dirPath) const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
if (dirPath.isEmpty()) {
qWarning("QDir::rmpath: Empty or null file name");
@ -1618,7 +1618,7 @@ bool QDir::removeRecursively()
*/
bool QDir::isReadable() const
{
const QDirPrivate* d = d_ptr.constData();
Q_D(const QDir);
if (!d->fileEngine) {
if (!d->metaData.hasFlags(QFileSystemMetaData::UserReadPermission))
@ -1721,7 +1721,7 @@ bool QDir::isRelative() const
*/
bool QDir::makeAbsolute()
{
const QDirPrivate *d = d_ptr.constData();
Q_D(const QDir);
std::unique_ptr<QDirPrivate> dir;
if (!!d->fileEngine) {
QString absolutePath = d->fileEngine->fileName(QAbstractFileEngine::AbsoluteName);
@ -1750,7 +1750,7 @@ bool QDir::makeAbsolute()
*/
bool QDir::operator==(const QDir &dir) const
{
const QDirPrivate *d = d_ptr.constData();
Q_D(const QDir);
const QDirPrivate *other = dir.d_ptr.constData();
if (d == other)
@ -1900,7 +1900,7 @@ bool QDir::exists(const QString &name) const
*/
bool QDir::isEmpty(Filters filters) const
{
const auto d = d_ptr.constData();
Q_D(const QDir);
QDirIterator it(d->dirEntry.filePath(), d->nameFilters, filters);
return !it.hasNext();
}
@ -2350,7 +2350,7 @@ bool QDir::isRelativePath(const QString &path)
*/
void QDir::refresh() const
{
QDirPrivate *d = const_cast<QDir*>(this)->d_ptr.data();
QDirPrivate *d = const_cast<QDir *>(this)->d_func();
d->metaData.clear();
d->initFileEngine();
d->clearFileLists();