• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.12
  • kdepim
  • messageviewer
  • utils
iconnamecache.cpp
Go to the documentation of this file.
1 /* Copyright 2009 Thomas McGuire <mcguire@kde.org>
2 
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.
8 
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.
13 
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.
18 */
19 
20 #include "iconnamecache.h"
21 
22 #include <KGlobal>
23 #include <KIconLoader>
24 
25 namespace MessageViewer {
26 K_GLOBAL_STATIC( IconNameCache, s_iconNameCache )
27 
28 IconNameCache* IconNameCache::instance()
29 {
30  return s_iconNameCache;
31 }
32 
33 bool IconNameCache::Entry::operator < ( const Entry &other ) const
34 {
35  const int fileNameCompare = fileName.compare( other.fileName );
36  if ( fileNameCompare != 0 )
37  return fileNameCompare < 0;
38  else
39  return size < other.size;
40 }
41 
42 QString IconNameCache::iconPath( const QString &name, int size ) const
43 {
44  Entry entry;
45  entry.fileName = name;
46  entry.size = size;
47 
48  if ( mCachedEntries.contains( entry ) )
49  return mCachedEntries.value( entry );
50 
51  const QString fileName = KIconLoader::global()->iconPath( name, size );
52  mCachedEntries.insert( entry, fileName );
53  return fileName;
54 }
55 }
iconnamecache.h
MessageViewer::IconNameCache
This class is a replacement for KIconLoader::iconPath(), because the iconPath() function can be slow ...
Definition: iconnamecache.h:35
MessageViewer::IconNameCache::iconPath
QString iconPath(const QString &name, int size) const
Definition: iconnamecache.cpp:42
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal