summaryrefslogtreecommitdiffabout
path: root/kabc/picture.cpp
Unidiff
Diffstat (limited to 'kabc/picture.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/picture.cpp38
1 files changed, 32 insertions, 6 deletions
diff --git a/kabc/picture.cpp b/kabc/picture.cpp
index 6a34b98..57aa297 100644
--- a/kabc/picture.cpp
+++ b/kabc/picture.cpp
@@ -1,141 +1,167 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 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 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, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include "picture.h" 28#include "picture.h"
29 29
30using namespace KABC; 30using namespace KABC;
31 31
32Picture::Picture() 32Picture::Picture()
33 : mIntern( false ) 33 : mIntern( false )
34{ 34{
35 mUndefined = true; 35 mUndefined = true;
36} 36}
37 37
38Picture::Picture( const QString &url ) 38Picture::Picture( const QString &url )
39 : mUrl( url ), mIntern( false ) 39 : mUrl( url ), mIntern( false )
40{ 40{
41 mUndefined = false; 41 mUndefined = false;
42} 42}
43 43
44Picture::Picture( const QImage &data ) 44Picture::Picture( const QImage &data )
45 : mData( data ), mIntern( true ) 45 : mData( data ), mIntern( true )
46{ 46{
47 mUndefined = false; 47 mUndefined = false;
48} 48}
49 49
50Picture::~Picture() 50Picture::~Picture()
51{ 51{
52} 52}
53 53
54bool Picture::operator==( const Picture &p ) const 54bool Picture::operator==( const Picture &p ) const
55{ 55{
56 if ( mIntern != p.mIntern ) return false; 56 //qDebug("compare PIC ");
57 57 if ( mUndefined && p.mUndefined ) {
58 //qDebug("compare PIC true 1 ");
59 return true;
60 }
61 if ( mUndefined || p.mUndefined ) {
62 //qDebug("compare PIC false 1");
63 return false;
64 }
65 // now we should deal with two defined pics!
66 if ( mIntern != p.mIntern ) {
67 //qDebug("compare PIC false 2");
68 return false;
69 }
58 if ( mIntern ) { 70 if ( mIntern ) {
59 if ( mData != p.mData ) 71 //qDebug("mIntern ");
72 if ( mData.isNull() && p.mData.isNull() ) {
73 //qDebug("compare PIC true 2 ");
74 return true;
75 }
76 if ( mData.isNull() || p.mData.isNull() ){
77 //qDebug("compare PIC false 3-1");
78
79 return false;
80 }
81 if ( mData != p.mData ) {
82 //qDebug("compare PIC false 3");
60 return false; 83 return false;
84 }
61 } else { 85 } else {
62 if ( mUrl != p.mUrl ) 86 if ( mUrl != p.mUrl ) {
63 return false; 87 //qDebug("compare PIC false 4");
88 return false;
89 }
64 } 90 }
65 91 //qDebug("compare PIC true ");
66 return true; 92 return true;
67} 93}
68 94
69bool Picture::operator!=( const Picture &p ) const 95bool Picture::operator!=( const Picture &p ) const
70{ 96{
71 return !( p == *this ); 97 return !( p == *this );
72} 98}
73 99
74void Picture::setUrl( const QString &url ) 100void Picture::setUrl( const QString &url )
75{ 101{
76 mUrl = url; 102 mUrl = url;
77 mIntern = false; 103 mIntern = false;
78 mUndefined = false; 104 mUndefined = false;
79} 105}
80 106
81void Picture::setData( const QImage &data ) 107void Picture::setData( const QImage &data )
82{ 108{
83 mData = data; 109 mData = data;
84 mIntern = true; 110 mIntern = true;
85 mUndefined = false; 111 mUndefined = false;
86} 112}
87 113
88void Picture::setType( const QString &type ) 114void Picture::setType( const QString &type )
89{ 115{
90 mType = type; 116 mType = type;
91} 117}
92 118
93bool Picture::isIntern() const 119bool Picture::isIntern() const
94{ 120{
95 return mIntern; 121 return mIntern;
96} 122}
97 123
98QString Picture::url() const 124QString Picture::url() const
99{ 125{
100 return mUrl; 126 return mUrl;
101} 127}
102 128
103QImage Picture::data() const 129QImage Picture::data() const
104{ 130{
105 return mData; 131 return mData;
106} 132}
107QPixmap Picture::pixmap() const 133QPixmap Picture::pixmap() const
108{ 134{
109 QPixmap p; 135 QPixmap p;
110 p.convertFromImage ( mData ); 136 p.convertFromImage ( mData );
111 return p; 137 return p;
112} 138}
113 139
114QString Picture::type() const 140QString Picture::type() const
115{ 141{
116 return mType; 142 return mType;
117} 143}
118bool Picture::undefined() const 144bool Picture::undefined() const
119{ 145{
120 return mUndefined; 146 return mUndefined;
121} 147}
122 148
123 149
124QString Picture::asString() const 150QString Picture::asString() const
125{ 151{
126 if ( mIntern ) 152 if ( mIntern )
127 return "intern picture"; 153 return "intern picture";
128 else 154 else
129 return mUrl; 155 return mUrl;
130} 156}
131 157
132QDataStream &KABC::operator<<( QDataStream &s, const Picture &picture ) 158QDataStream &KABC::operator<<( QDataStream &s, const Picture &picture )
133{ 159{
134 return s << picture.mIntern << picture.mUrl << picture.mType << picture.mData; 160 return s << picture.mIntern << picture.mUrl << picture.mType << picture.mData;
135} 161}
136 162
137QDataStream &KABC::operator>>( QDataStream &s, Picture &picture ) 163QDataStream &KABC::operator>>( QDataStream &s, Picture &picture )
138{ 164{
139 s >> picture.mIntern >> picture.mUrl >> picture.mType >> picture.mData; 165 s >> picture.mIntern >> picture.mUrl >> picture.mType >> picture.mData;
140 return s; 166 return s;
141} 167}