summaryrefslogtreecommitdiffabout
path: root/kabc/vcard/GeoValue.cpp
Unidiff
Diffstat (limited to 'kabc/vcard/GeoValue.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kabc/vcard/GeoValue.cpp100
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
27using namespace VCARD;
28
29GeoValue::GeoValue()
30 :Value()
31{
32}
33
34GeoValue::GeoValue(const GeoValue & x)
35 :Value(x), latitude_(x.latitude_), longitude_(x.longitude_)
36{
37}
38
39GeoValue::GeoValue(const QCString & s)
40 :Value(s)
41{
42}
43
44 GeoValue &
45GeoValue::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 &
57GeoValue::operator = (const QCString & s)
58{
59 Value::operator = (s);
60 return *this;
61}
62
63 bool
64GeoValue::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
74GeoValue::~GeoValue()
75{
76}
77
78 GeoValue *
79GeoValue::clone()
80{
81 return new GeoValue( *this );
82}
83
84 void
85GeoValue::_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
97GeoValue::_assemble()
98{
99 strRep_.sprintf( "%.6f;%.6f", latitude_, longitude_ );
100}