author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /kabc/picture.cpp | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
-rw-r--r-- | kabc/picture.cpp | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/kabc/picture.cpp b/kabc/picture.cpp new file mode 100644 index 0000000..6a34b98 --- a/dev/null +++ b/kabc/picture.cpp | |||
@@ -0,0 +1,141 @@ | |||
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 | #include "picture.h" | ||
29 | |||
30 | using namespace KABC; | ||
31 | |||
32 | Picture::Picture() | ||
33 | : mIntern( false ) | ||
34 | { | ||
35 | mUndefined = true; | ||
36 | } | ||
37 | |||
38 | Picture::Picture( const QString &url ) | ||
39 | : mUrl( url ), mIntern( false ) | ||
40 | { | ||
41 | mUndefined = false; | ||
42 | } | ||
43 | |||
44 | Picture::Picture( const QImage &data ) | ||
45 | : mData( data ), mIntern( true ) | ||
46 | { | ||
47 | mUndefined = false; | ||
48 | } | ||
49 | |||
50 | Picture::~Picture() | ||
51 | { | ||
52 | } | ||
53 | |||
54 | bool Picture::operator==( const Picture &p ) const | ||
55 | { | ||
56 | if ( mIntern != p.mIntern ) return false; | ||
57 | |||
58 | if ( mIntern ) { | ||
59 | if ( mData != p.mData ) | ||
60 | return false; | ||
61 | } else { | ||
62 | if ( mUrl != p.mUrl ) | ||
63 | return false; | ||
64 | } | ||
65 | |||
66 | return true; | ||
67 | } | ||
68 | |||
69 | bool Picture::operator!=( const Picture &p ) const | ||
70 | { | ||
71 | return !( p == *this ); | ||
72 | } | ||
73 | |||
74 | void Picture::setUrl( const QString &url ) | ||
75 | { | ||
76 | mUrl = url; | ||
77 | mIntern = false; | ||
78 | mUndefined = false; | ||
79 | } | ||
80 | |||
81 | void Picture::setData( const QImage &data ) | ||
82 | { | ||
83 | mData = data; | ||
84 | mIntern = true; | ||
85 | mUndefined = false; | ||
86 | } | ||
87 | |||
88 | void Picture::setType( const QString &type ) | ||
89 | { | ||
90 | mType = type; | ||
91 | } | ||
92 | |||
93 | bool Picture::isIntern() const | ||
94 | { | ||
95 | return mIntern; | ||
96 | } | ||
97 | |||
98 | QString Picture::url() const | ||
99 | { | ||
100 | return mUrl; | ||
101 | } | ||
102 | |||
103 | QImage Picture::data() const | ||
104 | { | ||
105 | return mData; | ||
106 | } | ||
107 | QPixmap Picture::pixmap() const | ||
108 | { | ||
109 | QPixmap p; | ||
110 | p.convertFromImage ( mData ); | ||
111 | return p; | ||
112 | } | ||
113 | |||
114 | QString Picture::type() const | ||
115 | { | ||
116 | return mType; | ||
117 | } | ||
118 | bool Picture::undefined() const | ||
119 | { | ||
120 | return mUndefined; | ||
121 | } | ||
122 | |||
123 | |||
124 | QString Picture::asString() const | ||
125 | { | ||
126 | if ( mIntern ) | ||
127 | return "intern picture"; | ||
128 | else | ||
129 | return mUrl; | ||
130 | } | ||
131 | |||
132 | QDataStream &KABC::operator<<( QDataStream &s, const Picture &picture ) | ||
133 | { | ||
134 | return s << picture.mIntern << picture.mUrl << picture.mType << picture.mData; | ||
135 | } | ||
136 | |||
137 | QDataStream &KABC::operator>>( QDataStream &s, Picture &picture ) | ||
138 | { | ||
139 | s >> picture.mIntern >> picture.mUrl >> picture.mType >> picture.mData; | ||
140 | return s; | ||
141 | } | ||