2 kopetepicture.h - Kopete Picture
4 Copyright (c) 2005 by Michaël Larouche <larouche@kde.org>
6 Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
8 *************************************************************************
10 * This library is free software; you can redistribute it and/or *
11 * modify it under the terms of the GNU Lesser General Public *
12 * License as published by the Free Software Foundation; either *
13 * version 2 of the License, or (at your option) any later version. *
15 *************************************************************************
17 #ifndef KOPETEPICTURE_H
18 #define KOPETEPICTURE_H
20 #include <kdemacros.h>
21 #include <ksharedptr.h>
22 #include "kopete_export.h"
24 #include <QtGui/QImage>
34 * @brief Represent a picture in Kopete context
36 * It kept a cache of a QImage object, a base64 string and
37 * a path to a image file. It ensure that all source are synced.
38 * Interally, the image is stored in PNG format when possible.
39 * It can happen that the image path do not return a PNG file.
41 * You can only use an QImage and a image path to create/update
43 * If the picture doesn't exist as a file, it generate a local
44 * copy into ~/.kde/share/apps/kopete/metacontactpicturecache
46 * This class is implicitly shared, so don't use it as a pointer.
48 * How to use this class:
50 * Kopete::Picture picture;
51 * picture.setPicture(QImage());
52 * picture.setPicture(QString("/tmp/image.png"));
54 * QString base64 = picture.base64();
55 * QString path = picture.path();
56 * QImage image = picture.image();
59 * @author Michaël Larouche <larouche@kde.org>
61 class KOPETE_EXPORT Picture
65 * Create a empty Kopete::Picture
69 * Create a picture from a local path.
71 explicit Picture(const QString
&path
);
73 * Create a picture from a QImage.
75 explicit Picture(const QImage
&image
);
77 * Create a picture from a KABC::Picture.
79 explicit Picture(const KABC::Picture
&picture
);
81 * Copy a picture. It doesn't create a full copy, it just make a reference.
83 Picture(const Picture
&other
);
85 * Delete the Kopete::Picture
89 * Assignment operator.
90 * Like the copy constructor, it just make a reference.
92 Picture
&operator=(const Picture
&other
);
95 * Return the current picture as QImage.
96 * QImage can used to draw the image on a context.
98 * @return the QImage cache of current picture.
102 * Return the current picture as a base64 string.
103 * The base64 is used to include the picture into a XML/XHTML context.
107 * Return the local path of the current picture.
112 * Check if the picture is null.
121 * Set the picture content.
122 * @param image the picture as a QImage.
124 void setPicture(const QImage
&image
);
126 * Set the picture content.
127 * @param path the path to the picture.
129 void setPicture(const QString
&path
);
131 * Set the picture content.
132 * @param picture a KABC Picture.
134 void setPicture(const KABC::Picture
&picture
);
138 * Kopete::Picture is implicitly shared.
139 * Detach the instance when modifying data.
144 KSharedPtr
<Private
> d
;
147 }//END namespace Kopete