summaryrefslogtreecommitdiffabout
path: root/kabc/picture.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kabc/picture.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'kabc/picture.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/picture.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/kabc/picture.cpp b/kabc/picture.cpp
index 57aa297..0c59937 100644
--- a/kabc/picture.cpp
+++ b/kabc/picture.cpp
@@ -1,167 +1,169 @@
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//Added by qt3to4:
30#include <QPixmap>
29 31
30using namespace KABC; 32using namespace KABC;
31 33
32Picture::Picture() 34Picture::Picture()
33 : mIntern( false ) 35 : mIntern( false )
34{ 36{
35 mUndefined = true; 37 mUndefined = true;
36} 38}
37 39
38Picture::Picture( const QString &url ) 40Picture::Picture( const QString &url )
39 : mUrl( url ), mIntern( false ) 41 : mUrl( url ), mIntern( false )
40{ 42{
41 mUndefined = false; 43 mUndefined = false;
42} 44}
43 45
44Picture::Picture( const QImage &data ) 46Picture::Picture( const QImage &data )
45 : mData( data ), mIntern( true ) 47 : mData( data ), mIntern( true )
46{ 48{
47 mUndefined = false; 49 mUndefined = false;
48} 50}
49 51
50Picture::~Picture() 52Picture::~Picture()
51{ 53{
52} 54}
53 55
54bool Picture::operator==( const Picture &p ) const 56bool Picture::operator==( const Picture &p ) const
55{ 57{
56 //qDebug("compare PIC "); 58 //qDebug("compare PIC ");
57 if ( mUndefined && p.mUndefined ) { 59 if ( mUndefined && p.mUndefined ) {
58 //qDebug("compare PIC true 1 "); 60 //qDebug("compare PIC true 1 ");
59 return true; 61 return true;
60 } 62 }
61 if ( mUndefined || p.mUndefined ) { 63 if ( mUndefined || p.mUndefined ) {
62 //qDebug("compare PIC false 1"); 64 //qDebug("compare PIC false 1");
63 return false; 65 return false;
64 } 66 }
65 // now we should deal with two defined pics! 67 // now we should deal with two defined pics!
66 if ( mIntern != p.mIntern ) { 68 if ( mIntern != p.mIntern ) {
67 //qDebug("compare PIC false 2"); 69 //qDebug("compare PIC false 2");
68 return false; 70 return false;
69 } 71 }
70 if ( mIntern ) { 72 if ( mIntern ) {
71 //qDebug("mIntern "); 73 //qDebug("mIntern ");
72 if ( mData.isNull() && p.mData.isNull() ) { 74 if ( mData.isNull() && p.mData.isNull() ) {
73 //qDebug("compare PIC true 2 "); 75 //qDebug("compare PIC true 2 ");
74 return true; 76 return true;
75 } 77 }
76 if ( mData.isNull() || p.mData.isNull() ){ 78 if ( mData.isNull() || p.mData.isNull() ){
77 //qDebug("compare PIC false 3-1"); 79 //qDebug("compare PIC false 3-1");
78 80
79 return false; 81 return false;
80 } 82 }
81 if ( mData != p.mData ) { 83 if ( mData != p.mData ) {
82 //qDebug("compare PIC false 3"); 84 //qDebug("compare PIC false 3");
83 return false; 85 return false;
84 } 86 }
85 } else { 87 } else {
86 if ( mUrl != p.mUrl ) { 88 if ( mUrl != p.mUrl ) {
87 //qDebug("compare PIC false 4"); 89 //qDebug("compare PIC false 4");
88 return false; 90 return false;
89 } 91 }
90 } 92 }
91 //qDebug("compare PIC true "); 93 //qDebug("compare PIC true ");
92 return true; 94 return true;
93} 95}
94 96
95bool Picture::operator!=( const Picture &p ) const 97bool Picture::operator!=( const Picture &p ) const
96{ 98{
97 return !( p == *this ); 99 return !( p == *this );
98} 100}
99 101
100void Picture::setUrl( const QString &url ) 102void Picture::setUrl( const QString &url )
101{ 103{
102 mUrl = url; 104 mUrl = url;
103 mIntern = false; 105 mIntern = false;
104 mUndefined = false; 106 mUndefined = false;
105} 107}
106 108
107void Picture::setData( const QImage &data ) 109void Picture::setData( const QImage &data )
108{ 110{
109 mData = data; 111 mData = data;
110 mIntern = true; 112 mIntern = true;
111 mUndefined = false; 113 mUndefined = false;
112} 114}
113 115
114void Picture::setType( const QString &type ) 116void Picture::setType( const QString &type )
115{ 117{
116 mType = type; 118 mType = type;
117} 119}
118 120
119bool Picture::isIntern() const 121bool Picture::isIntern() const
120{ 122{
121 return mIntern; 123 return mIntern;
122} 124}
123 125
124QString Picture::url() const 126QString Picture::url() const
125{ 127{
126 return mUrl; 128 return mUrl;
127} 129}
128 130
129QImage Picture::data() const 131QImage Picture::data() const
130{ 132{
131 return mData; 133 return mData;
132} 134}
133QPixmap Picture::pixmap() const 135QPixmap Picture::pixmap() const
134{ 136{
135 QPixmap p; 137 QPixmap p;
136 p.convertFromImage ( mData ); 138 p.convertFromImage ( mData );
137 return p; 139 return p;
138} 140}
139 141
140QString Picture::type() const 142QString Picture::type() const
141{ 143{
142 return mType; 144 return mType;
143} 145}
144bool Picture::undefined() const 146bool Picture::undefined() const
145{ 147{
146 return mUndefined; 148 return mUndefined;
147} 149}
148 150
149 151
150QString Picture::asString() const 152QString Picture::asString() const
151{ 153{
152 if ( mIntern ) 154 if ( mIntern )
153 return "intern picture"; 155 return "intern picture";
154 else 156 else
155 return mUrl; 157 return mUrl;
156} 158}
157 159
158QDataStream &KABC::operator<<( QDataStream &s, const Picture &picture ) 160QDataStream &KABC::operator<<( QDataStream &s, const Picture &picture )
159{ 161{
160 return s << picture.mIntern << picture.mUrl << picture.mType << picture.mData; 162 return s << picture.mIntern << picture.mUrl << picture.mType << picture.mData;
161} 163}
162 164
163QDataStream &KABC::operator>>( QDataStream &s, Picture &picture ) 165QDataStream &KABC::operator>>( QDataStream &s, Picture &picture )
164{ 166{
165 s >> picture.mIntern >> picture.mUrl >> picture.mType >> picture.mData; 167 s >> picture.mIntern >> picture.mUrl >> picture.mType >> picture.mData;
166 return s; 168 return s;
167} 169}