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/vcard/GeoValue.cpp | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
-rw-r--r-- | kabc/vcard/GeoValue.cpp | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/kabc/vcard/GeoValue.cpp b/kabc/vcard/GeoValue.cpp new file mode 100644 index 0000000..e02b402 --- a/dev/null +++ b/kabc/vcard/GeoValue.cpp | |||
@@ -0,0 +1,100 @@ | |||
1 | /* | ||
2 | This file is part of libvcard. | ||
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 | #include <VCardGeoValue.h> | ||
22 | |||
23 | #include <VCardValue.h> | ||
24 | |||
25 | #include <kdebug.h> | ||
26 | |||
27 | using namespace VCARD; | ||
28 | |||
29 | GeoValue::GeoValue() | ||
30 | :Value() | ||
31 | { | ||
32 | } | ||
33 | |||
34 | GeoValue::GeoValue(const GeoValue & x) | ||
35 | :Value(x), latitude_(x.latitude_), longitude_(x.longitude_) | ||
36 | { | ||
37 | } | ||
38 | |||
39 | GeoValue::GeoValue(const QCString & s) | ||
40 | :Value(s) | ||
41 | { | ||
42 | } | ||
43 | |||
44 | GeoValue & | ||
45 | GeoValue::operator = (GeoValue & x) | ||
46 | { | ||
47 | if (*this == x) return *this; | ||
48 | |||
49 | latitude_ = x.latitude_; | ||
50 | longitude_ = x.longitude_; | ||
51 | |||
52 | Value::operator = (x); | ||
53 | return *this; | ||
54 | } | ||
55 | |||
56 | GeoValue & | ||
57 | GeoValue::operator = (const QCString & s) | ||
58 | { | ||
59 | Value::operator = (s); | ||
60 | return *this; | ||
61 | } | ||
62 | |||
63 | bool | ||
64 | GeoValue::operator == (GeoValue & x) | ||
65 | { | ||
66 | x.parse(); | ||
67 | |||
68 | if ( latitude_ != x.latitude_ ) return false; | ||
69 | if ( longitude_ != x.longitude_ ) return false; | ||
70 | |||
71 | return true; | ||
72 | } | ||
73 | |||
74 | GeoValue::~GeoValue() | ||
75 | { | ||
76 | } | ||
77 | |||
78 | GeoValue * | ||
79 | GeoValue::clone() | ||
80 | { | ||
81 | return new GeoValue( *this ); | ||
82 | } | ||
83 | |||
84 | void | ||
85 | GeoValue::_parse() | ||
86 | { | ||
87 | int semiColon = strRep_.find( ";" ); | ||
88 | |||
89 | if ( semiColon == -1 ) // invalid | ||
90 | return; | ||
91 | |||
92 | latitude_ = strRep_.left( semiColon ).toFloat(); | ||
93 | longitude_ = strRep_.mid( semiColon + 1, strRep_.length() - semiColon ).toFloat(); | ||
94 | } | ||
95 | |||
96 | void | ||
97 | GeoValue::_assemble() | ||
98 | { | ||
99 | strRep_.sprintf( "%.6f;%.6f", latitude_, longitude_ ); | ||
100 | } | ||