KVIrc  4.9.2
DeveloperAPIs
KviAvatar.h
Go to the documentation of this file.
1 #ifndef _KVI_AVATAR_H_
2 #define _KVI_AVATAR_H_
3 
4 //=============================================================================
5 //
6 // File : KviAvatar.h
7 // Creation date : Fri Dec 01 2000 13:54:04 CEST by Szymon Stefanek
8 //
9 // This file is part of the KVIrc IRC client distribution
10 // Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
11 //
12 // This program is FREE software. You can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the HOPE that it will be USEFUL,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 // See the GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program. If not, write to the Free Software Foundation,
24 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 //
26 //=============================================================================
27 
34 #include "KviHeapObject.h"
35 #include "kvi_settings.h"
36 #include "KviAnimatedPixmap.h"
37 
38 #include <QPixmap>
39 #include <QHash>
40 
46 inline uint qHash(const QSize & s) { return uint(s.width() | s.height()); }
47 
53 {
54 public:
62  KviAvatar(const QString & szLocalPath,
63  const QString & szName,
64  const QSize & scaleOnLoad = QSize());
65 
69  ~KviAvatar();
70 
71 private:
72  QString m_szLocalPath;
73  QString m_szName;
74  bool m_bRemote;
75 
77  QHash<QSize, KviAnimatedPixmap *> m_scaledPixmapsCache;
78 
79 public:
84  inline bool isRemote() { return m_bRemote; }
85 
90  inline const QString & localPath() { return m_szLocalPath; }
91 
98  inline const QString & name() { return m_szName; }
99 
104  inline bool isAnimated() { return (m_pPixmap->framesCount() > 1); }
105 
110  inline const QSize & size() { return m_pPixmap->size(); }
111 
116  inline QPixmap * pixmap() { return m_pPixmap->pixmap(); }
117 
124  inline bool isValid() { return m_pPixmap->isValid(); }
125 
131 
146  KviAnimatedPixmap * forSize(const QSize & size);
147 
163  inline KviAnimatedPixmap * forSize(unsigned int uWidth, unsigned int uHeight) { return forSize(QSize(uWidth, uHeight)); }
164 
172  const QString & identificationString() { return m_bRemote ? m_szName : m_szLocalPath; };
173 };
174 
175 #endif //_KVI_AVATAR_H_
bool m_bRemote
Definition: KviAvatar.h:74
Definition: KviAnimatedPixmap.h:67
Definition: KviHeapObject.h:124
QString m_szLocalPath
Definition: KviAvatar.h:72
bool isRemote()
Returns true, if avatar is remote.
Definition: KviAvatar.h:84
m_pPixmap
Definition: KvsObject_pixmap.cpp:112
KviAnimatedPixmap * forSize(unsigned int uWidth, unsigned int uHeight)
Returns animated pixmap, scaled to the requisted size.
Definition: KviAvatar.h:163
QHash< QSize, KviAnimatedPixmap * > m_scaledPixmapsCache
Definition: KviAvatar.h:77
bool isValid()
Returns true if pixmap has at least one loaded frame.
Definition: KviAvatar.h:124
uint qHash(const QSize &s)
Returns an hash based on avatar dimensions.
Definition: KviAvatar.h:46
Avatar class.
Definition: KviAvatar.h:52
char s char s s
Definition: KviIrcNumericCodes.h:391
KviAnimatedPixmap * animatedPixmap()
Returns original animated pixmap.
Definition: KviAvatar.h:130
const QSize & size()
Returns original pixmap's size.
Definition: KviAvatar.h:110
bool isAnimated()
Returns true, if underlying pixmap contains more then one frame.
Definition: KviAvatar.h:104
const QString & name()
Returns fiename.
Definition: KviAvatar.h:98
QPixmap * pixmap()
Returns unscaled original frame.
Definition: KviAvatar.h:116
const QString & identificationString()
Returns the string that uniquely identifies this avatar.
Definition: KviAvatar.h:172
QString m_szName
Definition: KviAvatar.h:73
Heap Object.
This file contains compile time settings.
#define KVILIB_API
Definition: kvi_settings.h:125
KviAnimatedPixmap * m_pPixmap
Definition: KviAvatar.h:76
const QString & localPath()
Returns filepath.
Definition: KviAvatar.h:90