summaryrefslogtreecommitdiffabout
path: root/kabc/picture.cpp
authorzautrix <zautrix>2004-06-26 19:01:18 (UTC)
committer zautrix <zautrix>2004-06-26 19:01:18 (UTC)
commitb9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff)
tree2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /kabc/picture.cpp
downloadkdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2
Initial revision
Diffstat (limited to 'kabc/picture.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/picture.cpp141
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/*
22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk
24
25$Id$
26*/
27
28#include "picture.h"
29
30using namespace KABC;
31
32Picture::Picture()
33 : mIntern( false )
34{
35 mUndefined = true;
36}
37
38Picture::Picture( const QString &url )
39 : mUrl( url ), mIntern( false )
40{
41 mUndefined = false;
42}
43
44Picture::Picture( const QImage &data )
45 : mData( data ), mIntern( true )
46{
47 mUndefined = false;
48}
49
50Picture::~Picture()
51{
52}
53
54bool 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
69bool Picture::operator!=( const Picture &p ) const
70{
71 return !( p == *this );
72}
73
74void Picture::setUrl( const QString &url )
75{
76 mUrl = url;
77 mIntern = false;
78 mUndefined = false;
79}
80
81void Picture::setData( const QImage &data )
82{
83 mData = data;
84 mIntern = true;
85 mUndefined = false;
86}
87
88void Picture::setType( const QString &type )
89{
90 mType = type;
91}
92
93bool Picture::isIntern() const
94{
95 return mIntern;
96}
97
98QString Picture::url() const
99{
100 return mUrl;
101}
102
103QImage Picture::data() const
104{
105 return mData;
106}
107QPixmap Picture::pixmap() const
108{
109 QPixmap p;
110 p.convertFromImage ( mData );
111 return p;
112}
113
114QString Picture::type() const
115{
116 return mType;
117}
118bool Picture::undefined() const
119{
120 return mUndefined;
121}
122
123
124QString Picture::asString() const
125{
126 if ( mIntern )
127 return "intern picture";
128 else
129 return mUrl;
130}
131
132QDataStream &KABC::operator<<( QDataStream &s, const Picture &picture )
133{
134 return s << picture.mIntern << picture.mUrl << picture.mType << picture.mData;
135}
136
137QDataStream &KABC::operator>>( QDataStream &s, Picture &picture )
138{
139 s >> picture.mIntern >> picture.mUrl >> picture.mType >> picture.mData;
140 return s;
141}