KDEUI
kpixmapcache.h
Go to the documentation of this file.
00001 /* 00002 * 00003 * This file is part of the KDE project. 00004 * Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License version 2 as published by the Free Software Foundation. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef KPIXMAPCACHE_H 00022 #define KPIXMAPCACHE_H 00023 00024 #include <kdeui_export.h> 00025 00026 #include <QtCore/QList> 00027 #include <QtCore/QSet> 00028 #include <QtCore/QSize> 00029 00030 class QString; 00031 class QPixmap; 00032 00033 00085 class KDEUI_EXPORT KPixmapCache 00086 { 00087 public: 00092 explicit KPixmapCache(const QString& name); 00093 virtual ~KPixmapCache(); 00094 00101 virtual bool find(const QString& key, QPixmap& pix); 00102 00108 virtual void insert(const QString& key, const QPixmap& pix); 00109 00128 QPixmap loadFromFile(const QString& filename); 00129 00144 QPixmap loadFromSvg(const QString& filename, const QSize& size = QSize()); 00145 00151 unsigned int timestamp() const; 00152 00158 void setTimestamp(unsigned int time); 00159 00173 // KDE5 Get rid of QPixmapCache and use a sane cache instead. 00174 void setUseQPixmapCache(bool use); 00175 00186 bool useQPixmapCache() const; 00187 00191 int size() const; 00192 00197 int cacheLimit() const; 00198 00210 void setCacheLimit(int kbytes); 00211 00216 enum RemoveStrategy { 00217 RemoveOldest, 00219 RemoveSeldomUsed, 00221 RemoveLeastRecentlyUsed 00222 }; 00227 RemoveStrategy removeEntryStrategy() const; 00228 00232 void setRemoveEntryStrategy(RemoveStrategy strategy); 00233 00240 bool isEnabled() const; 00241 00247 bool isValid() const; 00248 00253 // KDE5: Static function oh how I hate you, this makes it very difficult to perform 00254 // appropriate locking and synchronization to actually remove the cache. 00255 static void deleteCache(const QString& name); 00256 00266 void discard(); 00267 00279 void removeEntries(int newsize = 0); 00280 00281 protected: 00291 // KDE5: rename to ensureInitialized() 00292 // KDE5: Make private or move to Private 00293 void ensureInited() const; 00294 00308 virtual bool loadCustomData(QDataStream& stream); 00309 00320 virtual bool writeCustomData(QDataStream& stream); 00321 00335 virtual bool loadCustomIndexHeader(QDataStream& stream); 00336 00347 virtual void writeCustomIndexHeader(QDataStream& stream); 00348 00361 void setValid(bool valid); 00362 00375 bool recreateCacheFiles(); 00376 00377 private: 00379 class Private; 00380 friend class Private; 00381 Private * const d; 00382 }; 00383 00384 #endif // KPIXMAPCACHE_H
KDE 4.6 API Reference