1 /* Copyright 2009 Thomas McGuire <mcguire@kde.org>
3 This library is free software; you can redistribute it and/or modify
4 it under the terms of the GNU Library General Public License as published
5 by the Free Software Foundation; either version 2 of the License or
6 ( at your option ) version 3 or, at the discretion of KDE e.V.
7 ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
19 #ifndef ICONNAMECACHE_H
20 #define ICONNAMECACHE_H
22 #include "messageviewer_export.h"
26 namespace MessageViewer
{
29 * This class is a replacement for KIconLoader::iconPath(), because the iconPath()
30 * function can be slow for non-existing icons or icons that fall back to a generic icon.
31 * Reason is that KIconLoader does slow system calls for finding the icons.
33 * The IconNameCache caches the result of iconPath() in a map and solves the slowness.
35 class MESSAGEVIEWER_EXPORT IconNameCache
39 static IconNameCache
*instance();
40 QString
iconPath( const QString
&name
, int size
) const;
50 bool operator < ( const Entry
&other
) const;
53 mutable QMap
<Entry
,QString
> mCachedEntries
;