From 9bc57f3037cd7ffc2ce5bd1f2ba1a52d60bd6118 Mon Sep 17 00:00:00 2001 From: Maurizio Monge Date: Thu, 12 Jul 2007 01:18:44 +0200 Subject: [PATCH] Use better names for inner caches in the theme class. --- src/common.h | 9 +++++++-- src/loader/theme.cpp | 20 ++++++++++---------- src/loader/theme.h | 8 ++++---- src/pixmaploader.h | 4 ++-- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/common.h b/src/common.h index f25e0a4..6ae7f81 100644 --- a/src/common.h +++ b/src/common.h @@ -1,7 +1,7 @@ /* Copyright (c) 2006 Paolo Capriotti (c) 2006 Maurizio Monge - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -49,7 +49,12 @@ inline void TRAP() { } #ifndef M_PI - #define M_PI 3.14159 + #define M_PI 3.1415926 #endif +#define ERROR(x) (std::cout << "Error: " << x << std::endl \ + << " in " << __PRETTY_FUNCTION__ << ", line " << __LINE__ << " of " << __FILE__ <second.m_cache.clear(); + it->second.m_pixmaps_cache.clear(); } } @@ -81,21 +81,21 @@ PixmapOrMap Theme::getPixmapMap(const QString& key, int size) { Cache::iterator it = m_cache.find(size); if(it == m_cache.end()) { - std::cout << " --> Error in Theme::getPixmap, size not referenced " << size << std::endl; + ERROR("Size " << size << "not referenced."); return PixmapOrMap(); } - SizeCache::Cache::iterator pix = it->second.m_cache.find(key); - if(pix != it->second.m_cache.end()) + SizeCache::PixmapsCache::iterator pix = it->second.m_pixmaps_cache.find(key); + if(pix != it->second.m_pixmaps_cache.end()) return pix->second; PixmapOrMap retv = to_pixmap_map(m_lua_loader.getImageMap(key, size)); if(m_lua_loader.error()) { - std::cout << "SCRIPT RUN ERROR:" << std::endl << m_lua_loader.errorString() << std::endl; + ERROR("Script error: " << std::endl << m_lua_loader.errorString()); m_lua_loader.clearError(); } - it->second.m_cache[key] = retv; + it->second.m_pixmaps_cache[key] = retv; return retv; } @@ -112,12 +112,12 @@ Glyph Theme::getGlyph(const QString& key, int size) { Cache::iterator it = m_cache.find(size); if(it == m_cache.end()) { - std::cout << " --> Error in Theme::getGlyph, size not referenced " << size << std::endl; + ERROR("Size " << size << "not referenced."); return Glyph(); } - SizeCache::Cache2::iterator pix = it->second.m_cache2.find(key); - if(pix != it->second.m_cache2.end()) + SizeCache::GlyphsCache::iterator pix = it->second.m_glyphs_cache.find(key); + if(pix != it->second.m_glyphs_cache.end()) return pix->second; Glyph retv = m_lua_loader.getGlyph(key); @@ -128,7 +128,7 @@ Glyph Theme::getGlyph(const QString& key, int size) { m_lua_loader.clearError(); } - it->second.m_cache2[key] = retv; + it->second.m_glyphs_cache[key] = retv; return retv; } diff --git a/src/loader/theme.h b/src/loader/theme.h index 8537466..6766fff 100644 --- a/src/loader/theme.h +++ b/src/loader/theme.h @@ -28,11 +28,11 @@ Q_OBJECT public: class SizeCache { public: - typedef std::map Cache; - typedef std::map Cache2; + typedef std::map PixmapsCache; + typedef std::map GlyphsCache; int m_ref_count; - Cache m_cache; - Cache2 m_cache2; + PixmapsCache m_pixmaps_cache; + GlyphsCache m_glyphs_cache; SizeCache() : m_ref_count(0) {} diff --git a/src/pixmaploader.h b/src/pixmaploader.h index 1f0d17a..1da61e6 100644 --- a/src/pixmaploader.h +++ b/src/pixmaploader.h @@ -67,10 +67,10 @@ public: QPixmap operator()(const QString& id); /** looks up a string id (for instance a predefined id, like "background" or "highlighting") */ - ::ThemeLoader::PixmapOrMap getPixmapMap(const QString& id); + Loader::PixmapOrMap getPixmapMap(const QString& id); /** looks up a font + char */ - ::ThemeLoader::Glyph getGlyph(const QString& id); + Loader::Glyph getGlyph(const QString& id); }; #endif // PIXMAPLOADER_H -- 2.11.4.GIT