make webinterface translatable. there are around 20 short strings, all with context...
[kdenetwork.git] / kopete / libkopete / kopetepicture.h
blob7a3be54d7139dfe9304d92786500e525657b43e7
1 /*
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 *************************************************************************
9 * *
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. *
14 * *
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>
26 namespace KABC
28 class Picture;
31 namespace Kopete
33 /**
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
42 * the picture.
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:
49 * @code
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();
57 * @endcode
59 * @author Michaël Larouche <larouche@kde.org>
61 class KOPETE_EXPORT Picture
63 public:
64 /**
65 * Create a empty Kopete::Picture
67 Picture();
68 /**
69 * Create a picture from a local path.
71 explicit Picture(const QString &path);
72 /**
73 * Create a picture from a QImage.
75 explicit Picture(const QImage &image);
76 /**
77 * Create a picture from a KABC::Picture.
79 explicit Picture(const KABC::Picture &picture);
80 /**
81 * Copy a picture. It doesn't create a full copy, it just make a reference.
83 Picture(const Picture &other);
84 /**
85 * Delete the Kopete::Picture
87 ~Picture();
88 /**
89 * Assignment operator.
90 * Like the copy constructor, it just make a reference.
92 Picture &operator=(const Picture &other);
94 /**
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.
100 QImage image();
102 * Return the current picture as a base64 string.
103 * The base64 is used to include the picture into a XML/XHTML context.
105 QString base64();
107 * Return the local path of the current picture.
109 QString path();
112 * Check if the picture is null.
114 bool isNull();
116 * Reset the picture.
118 void clear();
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);
136 private:
138 * Kopete::Picture is implicitly shared.
139 * Detach the instance when modifying data.
141 void detach();
143 class Private;
144 KSharedPtr<Private> d;
147 }//END namespace Kopete
149 #endif