summaryrefslogtreecommitdiffabout
path: root/kabc/vcard/VCardEntity.cpp
Unidiff
Diffstat (limited to 'kabc/vcard/VCardEntity.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/VCardEntity.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/kabc/vcard/VCardEntity.cpp b/kabc/vcard/VCardEntity.cpp
index a2ff327..bae5385 100644
--- a/kabc/vcard/VCardEntity.cpp
+++ b/kabc/vcard/VCardEntity.cpp
@@ -10,101 +10,103 @@
10 sell copies of the Software, and to permit persons to whom the Software is 10 sell copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions: 11 furnished to do so, subject to the following conditions:
12 12
13 The above copyright notice and this permission notice shall be included in 13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software. 14 all copies or substantial portions of the Software.
15 15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 19 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22*/ 22*/
23 23
24#include <qregexp.h> 24#include <qregexp.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26//Added by qt3to4:
27#include <Q3CString>
26 28
27#include <VCardDefines.h> 29#include <VCardDefines.h>
28#include <VCardVCardEntity.h> 30#include <VCardVCardEntity.h>
29 31
30using namespace VCARD; 32using namespace VCARD;
31 33
32VCardEntity::VCardEntity() 34VCardEntity::VCardEntity()
33 :Entity() 35 :Entity()
34{ 36{
35 cardList_.setAutoDelete( TRUE ); 37 cardList_.setAutoDelete( TRUE );
36} 38}
37 39
38VCardEntity::VCardEntity(const VCardEntity & x) 40VCardEntity::VCardEntity(const VCardEntity & x)
39 :Entity(x) 41 :Entity(x)
40{ 42{
41 cardList_.setAutoDelete( TRUE ); 43 cardList_.setAutoDelete( TRUE );
42} 44}
43 45
44VCardEntity::VCardEntity(const QCString & s) 46VCardEntity::VCardEntity(const Q3CString & s)
45 :Entity(s) 47 :Entity(s)
46{ 48{
47 cardList_.setAutoDelete( TRUE ); 49 cardList_.setAutoDelete( TRUE );
48} 50}
49 51
50 VCardEntity & 52 VCardEntity &
51VCardEntity::operator = (VCardEntity & x) 53VCardEntity::operator = (VCardEntity & x)
52{ 54{
53 if (*this == x) return *this; 55 if (*this == x) return *this;
54 56
55 Entity::operator = (x); 57 Entity::operator = (x);
56 return *this; 58 return *this;
57} 59}
58 60
59 VCardEntity & 61 VCardEntity &
60VCardEntity::operator = (const QCString & s) 62VCardEntity::operator = (const Q3CString & s)
61{ 63{
62 Entity::operator = (s); 64 Entity::operator = (s);
63 return *this; 65 return *this;
64} 66}
65 67
66 bool 68 bool
67VCardEntity::operator == (VCardEntity & x) 69VCardEntity::operator == (VCardEntity & x)
68{ 70{
69 x.parse(); 71 x.parse();
70 return false; 72 return false;
71} 73}
72 74
73VCardEntity::~VCardEntity() 75VCardEntity::~VCardEntity()
74{ 76{
75} 77}
76 78
77 void 79 void
78VCardEntity::_parse() 80VCardEntity::_parse()
79{ 81{
80#if 0 82#if 0
81 QTime tim; 83 QTime tim;
82 tim.start(); 84 tim.start();
83 int num = 0; 85 int num = 0;
84 // old code 86 // old code
85 vDebug("parse"); 87 vDebug("parse");
86 QCString s(strRep_); 88 Q3CString s(strRep_);
87 89
88 int i = s.find(QRegExp("BEGIN:VCARD", false)); 90 int i = s.find(QRegExp("BEGIN:VCARD", false));
89 91
90 while (i != -1) { 92 while (i != -1) {
91 93
92 i = s.find(QRegExp("BEGIN:VCARD", false), 11); 94 i = s.find(QRegExp("BEGIN:VCARD", false), 11);
93 95
94 QCString cardStr(s.left(i)); 96 Q3CString cardStr(s.left(i));
95 97
96 VCard * v = new VCard(cardStr); 98 VCard * v = new VCard(cardStr);
97 99
98 cardList_.append(v); 100 cardList_.append(v);
99 101
100 v->parse(); 102 v->parse();
101 103
102 s.remove(0, i); 104 s.remove(0, i);
103 } 105 }
104 106
105#else 107#else
106 // this code is up to 17 (!) times faster 108 // this code is up to 17 (!) times faster
107 int start = 0; 109 int start = 0;
108 QTime tim; 110 QTime tim;
109 tim.start(); 111 tim.start();
110 int i = 11; 112 int i = 11;
@@ -119,33 +121,33 @@ VCardEntity::_parse()
119 if ( i+add < len && strRep_.at(i+add++) == 'I') 121 if ( i+add < len && strRep_.at(i+add++) == 'I')
120 if ( i+add < len && strRep_.at(i+add++) == 'N') 122 if ( i+add < len && strRep_.at(i+add++) == 'N')
121 if ( i+add < len && strRep_.at(i+add++) == ':') 123 if ( i+add < len && strRep_.at(i+add++) == ':')
122 if ( i+add < len && strRep_.at(i+add++) == 'V') 124 if ( i+add < len && strRep_.at(i+add++) == 'V')
123 if ( i+add < len && strRep_.at(i+add++) == 'C') 125 if ( i+add < len && strRep_.at(i+add++) == 'C')
124 if ( i+add < len && strRep_.at(i+add++) == 'A') 126 if ( i+add < len && strRep_.at(i+add++) == 'A')
125 if ( i+add < len && strRep_.at(i+add++) == 'R') 127 if ( i+add < len && strRep_.at(i+add++) == 'R')
126 if ( i+add < len && strRep_.at(i+add++) == 'D') 128 if ( i+add < len && strRep_.at(i+add++) == 'D')
127 if ( i+add < len && (strRep_.at(i+add) == '\r' || strRep_.at(i+add) == '\n' )) 129 if ( i+add < len && (strRep_.at(i+add) == '\r' || strRep_.at(i+add) == '\n' ))
128 break; 130 break;
129 } 131 }
130 ++i; 132 ++i;
131 } 133 }
132 if ( i <= len ) { 134 if ( i <= len ) {
133 ++num; 135 ++num;
134 char* dat = strRep_.data()+start; 136 char* dat = strRep_.data()+start;
135 VCard * v = new VCard( QCString ( dat,i-start ) ); 137 VCard * v = new VCard( Q3CString ( dat,i-start ) );
136 start = i; 138 start = i;
137 cardList_.append(v); 139 cardList_.append(v);
138 v->parse(); 140 v->parse();
139 } 141 }
140 i+= 11; 142 i+= 11;
141 } 143 }
142#endif 144#endif
143 //qDebug("***time %d found %d", tim.elapsed(), num); 145 //qDebug("***time %d found %d", tim.elapsed(), num);
144} 146}
145 147
146 void 148 void
147VCardEntity::_assemble() 149VCardEntity::_assemble()
148{ 150{
149 VCardListIterator it(cardList_); 151 VCardListIterator it(cardList_);
150 152
151 for (; it.current(); ++it) 153 for (; it.current(); ++it)