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