Commit f65f7509 authored by Eike Ziller's avatar Eike Ziller

FileIconProvider: Do some more caching ourselves

QFileIconProvider already does some pixmap caching, but only in some
cases (non-executable, non-link). Since QFileIconProvider is expensive,
we want as much caching as possible.
It still should be investigated why it seems to be even more expensive
on OS X 10.9 in some cases though.

Task-number: QTCREATORBUG-10491
Change-Id: I5a0f995eafdced47dc6da869c72a1ca016b25f63
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 601951a4
......@@ -75,7 +75,7 @@ public:
: m_unknownFileIcon(qApp->style()->standardIcon(QStyle::SP_FileIcon))
{}
QIcon icon(const QFileInfo &info) const;
QIcon icon(const QFileInfo &info);
using QFileIconProvider::icon;
void registerIconOverlayForSuffix(const QIcon &icon, const QString &suffix)
......@@ -113,23 +113,26 @@ QFileIconProvider *iconProvider()
return instance();
}
QIcon FileIconProviderImplementation::icon(const QFileInfo &fileInfo) const
QIcon FileIconProviderImplementation::icon(const QFileInfo &fileInfo)
{
if (debug)
qDebug() << "FileIconProvider::icon" << fileInfo.absoluteFilePath();
// Check for cached overlay icons by file suffix.
if (!m_cache.isEmpty() && !fileInfo.isDir()) {
const QString suffix = fileInfo.suffix();
if (!suffix.isEmpty() && m_cache.contains(suffix)) {
bool isDir = fileInfo.isDir();
QString suffix = !isDir ? fileInfo.suffix() : QString();
if (!m_cache.isEmpty() && !isDir && !suffix.isEmpty()) {
if (m_cache.contains(suffix))
return m_cache.value(suffix);
}
}
// Get icon from OS.
QIcon icon;
if (HostOsInfo::isWindowsHost() || HostOsInfo::isMacHost())
return QFileIconProvider::icon(fileInfo);
// File icons are unknown on linux systems.
return fileInfo.isDir() ? QFileIconProvider::icon(fileInfo) : m_unknownFileIcon;
icon = QFileIconProvider::icon(fileInfo);
else // File icons are unknown on linux systems.
icon = isDir ? QFileIconProvider::icon(fileInfo) : m_unknownFileIcon;
if (!isDir && !suffix.isEmpty())
m_cache.insert(suffix, icon);
return icon;
}
/*!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment