2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
12 #include "loader/theme.h"
13 #include "pixmaploader.h"
15 class PixmapLoader::ThemeLoader
: public Loader::Theme
{
19 ThemeLoader(const QString
& s
)
26 PixmapLoader::ThemeLoadersCache
PixmapLoader::s_loaders
;
29 PixmapLoader::PixmapLoader()
35 PixmapLoader::~PixmapLoader() {
39 void PixmapLoader::flush() {
43 m_loader
->unrefSize(m_size
);
44 m_loader
->unrefSize(0);
46 /* unref the loader, and possibly destroy it */
47 if(!--m_loader
->m_ref_count
) {
49 s_loaders
.erase(m_base
);
55 void PixmapLoader::setBasePath(const QString
& base
) {
56 //QString base = PixmapLoader::ThemeLoader::resolveBasePath(__base);
65 void PixmapLoader::setSize(int s
) {
73 m_loader
->unrefSize(m_size
);
78 void PixmapLoader::initialize() {
82 /* try to get a loader */
83 ThemeLoadersCache::iterator it
= s_loaders
.find(m_base
);
84 if(it
!= s_loaders
.end())
85 m_loader
= it
->second
;
87 m_loader
= new ThemeLoader(m_base
);
88 s_loaders
[m_base
] = m_loader
;
91 m_loader
->m_ref_count
++;
93 m_loader
->refSize(m_size
);
98 T
PixmapLoader::getValue(const QString
& id
) {
99 if(!m_size
|| m_base
.isEmpty())
105 return m_loader
->getValue
<T
>(id
, m_size
);
108 template QPixmap
PixmapLoader::getValue
<QPixmap
>(const QString
& /*id*/);
109 template Loader::PixmapOrMap
PixmapLoader::getValue
<Loader::PixmapOrMap
>(const QString
& /*id*/);
110 template Loader::Glyph
PixmapLoader::getValue
<Loader::Glyph
>(const QString
& /*id*/);
111 template double PixmapLoader::getValue
<double>(const QString
& /*id*/);
112 template QPointF
PixmapLoader::getValue
<QPointF
>(const QString
& /*id*/);
113 template QRectF
PixmapLoader::getValue
<QRectF
>(const QString
& /*id*/);
114 template QBrush
PixmapLoader::getValue
<QBrush
>(const QString
& /*id*/);
115 template QColor
PixmapLoader::getValue
<QColor
>(const QString
& /*id*/);
119 T
PixmapLoader::getStaticValue(const QString
& id
) {
126 return m_loader
->getValue
<T
>(id
, 0);
129 template QPixmap
PixmapLoader::getStaticValue
<QPixmap
>(const QString
& /*id*/);
130 template Loader::PixmapOrMap
PixmapLoader::getStaticValue
<Loader::PixmapOrMap
>(const QString
& /*id*/);
131 template Loader::Glyph
PixmapLoader::getStaticValue
<Loader::Glyph
>(const QString
& /*id*/);
132 template double PixmapLoader::getStaticValue
<double>(const QString
& /*id*/);
133 template QPointF
PixmapLoader::getStaticValue
<QPointF
>(const QString
& /*id*/);
134 template QRectF
PixmapLoader::getStaticValue
<QRectF
>(const QString
& /*id*/);
135 template QBrush
PixmapLoader::getStaticValue
<QBrush
>(const QString
& /*id*/);
136 template QColor
PixmapLoader::getStaticValue
<QColor
>(const QString
& /*id*/);