diff options
author | Sérgio Martins <sergio.martins@kdab.com> | 2013-03-25 14:37:44 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-26 21:05:39 +0100 |
commit | b611da0d97408e1d3c9fabed3ef9e7e1b8c5f7da (patch) | |
tree | aea59b047ed0667bfc0e66711e2a387967f995d7 /src/widgets/itemviews/qfileiconprovider.cpp | |
parent | 36cb3f3f655a9090c82de609010cbfb88651a0f3 (diff) |
Windows: Fix one of the two file dialog bottlenecks.
This patch reduces the number of calls to GetFileAttributesEx()
when icon lookup is being done.
The second bottleneck is a couple of isSymLink() calls. Will fix
that next.
Task-number: QTBUG-13182
Change-Id: Ife3ff6cfb49d2294c501253ccc55d8c26036be94
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/widgets/itemviews/qfileiconprovider.cpp')
-rw-r--r-- | src/widgets/itemviews/qfileiconprovider.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp index 8a0736ec70..b435639390 100644 --- a/src/widgets/itemviews/qfileiconprovider.cpp +++ b/src/widgets/itemviews/qfileiconprovider.cpp @@ -220,6 +220,22 @@ QIcon QFileIconProvider::icon(IconType type) const return QIcon(); } +static bool isCacheable(const QFileInfo &fi) +{ + if (!fi.isFile()) + return false; + +#ifdef Q_OS_WIN + // On windows it's faster to just look at the file extensions. QTBUG-13182 + const QString fileExtension = fi.suffix(); + return fileExtension.compare(QLatin1String("exe"), Qt::CaseInsensitive) && + fileExtension.compare(QLatin1String("lnk"), Qt::CaseInsensitive) && + fileExtension.compare(QLatin1String("ico"), Qt::CaseInsensitive); +#else + return !fi.isExecutable() && !fi.isSymLink(); +#endif +} + QIcon QFileIconProviderPrivate::getIcon(const QFileInfo &fi) const { QIcon retIcon; @@ -234,7 +250,7 @@ QIcon QFileIconProviderPrivate::getIcon(const QFileInfo &fi) const const QString fileExtension = fi.suffix().toUpper(); const QString keyBase = QLatin1String("qt_.") + fi.suffix().toUpper(); - bool cacheable = fi.isFile() && !fi.isExecutable() && !fi.isSymLink() && fileExtension != QLatin1String("ICO"); + bool cacheable = isCacheable(fi); if (cacheable) { QPixmap pixmap; QPixmapCache::find(keyBase + QString::number(sizes.at(0)), pixmap); |