From 671d96383b2668ef773a49ba943328ddf0c98420 Mon Sep 17 00:00:00 2001 From: Tannin Date: Wed, 25 Feb 2015 17:48:37 +0100 Subject: icon delegates now use a pixmap cache to improve rendering performance --- src/modinfo.cpp | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'src/modinfo.cpp') diff --git a/src/modinfo.cpp b/src/modinfo.cpp index 3b8d6b92..cf8fa5c5 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -859,28 +859,38 @@ std::vector ModInfoRegular::getFlags() const std::vector ModInfoRegular::getContents() const { - std::vector result; - QDir dir(absolutePath()); - if (dir.entryList(QStringList() << "*.esp" << "*.esm").size() > 0) { - result.push_back(CONTENT_PLUGIN); - } + QTime now = QTime::currentTime(); + if (m_LastContentCheck.isNull() || (m_LastContentCheck.secsTo(now) > 60)) { + m_CachedContent.clear(); + QDir dir(absolutePath()); + if (dir.entryList(QStringList() << "*.esp" << "*.esm").size() > 0) { + m_CachedContent.push_back(CONTENT_PLUGIN); + } + if (dir.entryList(QStringList() << "*.bsa").size() > 0) { + m_CachedContent.push_back(CONTENT_BSA); + } - ScriptExtender *extender = qApp->property("managed_game").value()->feature(); + ScriptExtender *extender = qApp->property("managed_game").value()->feature(); - if (extender != nullptr) { - QString sePluginPath = extender->name() + "/plugins"; - if (dir.exists(sePluginPath)) result.push_back(CONTENT_SKSE); + if (extender != nullptr) { + QString sePluginPath = extender->name() + "/plugins"; + if (dir.exists(sePluginPath)) m_CachedContent.push_back(CONTENT_SKSE); + } + if (dir.exists("textures")) m_CachedContent.push_back(CONTENT_TEXTURE); + if (dir.exists("meshes")) m_CachedContent.push_back(CONTENT_MESH); + if (dir.exists("interface") + || dir.exists("menus")) m_CachedContent.push_back(CONTENT_INTERFACE); + if (dir.exists("music")) m_CachedContent.push_back(CONTENT_MUSIC); + if (dir.exists("sound")) m_CachedContent.push_back(CONTENT_SOUND); + if (dir.exists("scripts")) m_CachedContent.push_back(CONTENT_SCRIPT); + if (dir.exists("strings")) m_CachedContent.push_back(CONTENT_STRING); + if (dir.exists("SkyProc Patchers")) m_CachedContent.push_back(CONTENT_SKYPROC); + + m_LastContentCheck = QTime::currentTime(); } - if (dir.exists("textures")) result.push_back(CONTENT_TEXTURE); - if (dir.exists("meshes")) result.push_back(CONTENT_MESH); - if (dir.exists("interface") - || dir.exists("menus")) result.push_back(CONTENT_INTERFACE); - if (dir.exists("music")) result.push_back(CONTENT_MUSIC); - if (dir.exists("sound")) result.push_back(CONTENT_SOUND); - if (dir.exists("scripts")) result.push_back(CONTENT_SCRIPT); - if (dir.exists("strings")) result.push_back(CONTENT_STRING); - if (dir.exists("SkyProc Patchers")) result.push_back(CONTENT_SKYPROC); - return result; + + return m_CachedContent; + } -- cgit v1.3.1