-rw-r--r-- | kabc/picture.h | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/kabc/picture.h b/kabc/picture.h new file mode 100644 index 0000000..714d1e2 --- a/dev/null +++ b/kabc/picture.h | |||
@@ -0,0 +1,134 @@ | |||
1 | /* | ||
2 | This file is part of libkabc. | ||
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Library General Public License | ||
16 | along with this library; see the file COPYING.LIB. If not, write to | ||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /* | ||
22 | Enhanced Version of the file for platform independent KDE tools. | ||
23 | Copyright (c) 2004 Ulf Schenk | ||
24 | |||
25 | $Id$ | ||
26 | */ | ||
27 | |||
28 | #ifndef KABC_PICTURE_H | ||
29 | #define KABC_PICTURE_H | ||
30 | |||
31 | #include <qimage.h> | ||
32 | |||
33 | namespace KABC { | ||
34 | |||
35 | class Picture | ||
36 | { | ||
37 | friend QDataStream &operator<<( QDataStream &, const Picture & ); | ||
38 | friend QDataStream &operator>>( QDataStream &, Picture & ); | ||
39 | |||
40 | public: | ||
41 | |||
42 | /** | ||
43 | * Consturctor. Creates an empty object. | ||
44 | */ | ||
45 | Picture(); | ||
46 | |||
47 | /** | ||
48 | * Consturctor. | ||
49 | * | ||
50 | * @param url A URL that describes the position of the picture file. | ||
51 | */ | ||
52 | Picture( const QString &url ); | ||
53 | |||
54 | /** | ||
55 | * Consturctor. | ||
56 | * | ||
57 | * @param data The raw data of the picture. | ||
58 | */ | ||
59 | Picture( const QImage &data ); | ||
60 | |||
61 | /** | ||
62 | * Destructor. | ||
63 | */ | ||
64 | ~Picture(); | ||
65 | |||
66 | bool undefined() const; | ||
67 | bool operator==( const Picture & ) const; | ||
68 | bool operator!=( const Picture & ) const; | ||
69 | |||
70 | /** | ||
71 | * Sets a URL for the location of the picture file. When using this | ||
72 | * function, @ref isIntern() will return 'false' until you use | ||
73 | * @ref setData(). | ||
74 | * | ||
75 | * @param url The location URL of the picture file. | ||
76 | */ | ||
77 | void setUrl( const QString &url ); | ||
78 | |||
79 | /** | ||
80 | * Sets the raw data of the picture. When using this function, | ||
81 | * @ref isIntern() will return 'true' until you use @ref setUrl(). | ||
82 | * | ||
83 | * @param data The raw data of the picture. | ||
84 | */ | ||
85 | void setData( const QImage &data ); | ||
86 | |||
87 | /** | ||
88 | * Sets the type of the picture. | ||
89 | */ | ||
90 | void setType( const QString &type ); | ||
91 | |||
92 | /** | ||
93 | * Returns whether the picture is described by a URL (extern) or | ||
94 | * by the raw data (intern). | ||
95 | * When this method returns 'true' you can use @ref data() to | ||
96 | * get the raw data. Otherwise you can request the URL of this | ||
97 | * picture by @ref url() and load the raw data from that location. | ||
98 | */ | ||
99 | bool isIntern() const; | ||
100 | |||
101 | /** | ||
102 | * Returns the location URL of this picture. | ||
103 | */ | ||
104 | QString url() const; | ||
105 | |||
106 | /** | ||
107 | * Returns the raw data of this picture. | ||
108 | */ | ||
109 | QImage data() const; | ||
110 | QPixmap pixmap() const; | ||
111 | /** | ||
112 | * Returns the type of this picture. | ||
113 | */ | ||
114 | QString type() const; | ||
115 | |||
116 | /** | ||
117 | * Returns string representation of the picture. | ||
118 | */ | ||
119 | QString asString() const; | ||
120 | |||
121 | private: | ||
122 | QString mUrl; | ||
123 | QString mType; | ||
124 | QImage mData; | ||
125 | bool mUndefined; | ||
126 | |||
127 | int mIntern; | ||
128 | }; | ||
129 | |||
130 | QDataStream &operator<<( QDataStream &, const Picture & ); | ||
131 | QDataStream &operator>>( QDataStream &, Picture & ); | ||
132 | |||
133 | } | ||
134 | #endif | ||