summaryrefslogtreecommitdiff
path: root/libopie/pim
Unidiff
Diffstat (limited to 'libopie/pim') (more/less context) (show whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp1
-rw-r--r--libopie/pim/ocontact.h4
-rw-r--r--libopie/pim/opimrecord.cpp8
-rw-r--r--libopie/pim/opimrecord.h13
4 files changed, 21 insertions, 5 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index aeb69ee..a7ca975 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -944,24 +944,25 @@ void OContact::setEmails( const QString &str )
944void OContact::setChildren( const QString &str ) 944void OContact::setChildren( const QString &str )
945{ 945{
946 replace( Qtopia::Children, str ); 946 replace( Qtopia::Children, str );
947} 947}
948 948
949/*! 949/*!
950 \overload 950 \overload
951 Returns TRUE if the contact matches the regular expression \a regexp. 951 Returns TRUE if the contact matches the regular expression \a regexp.
952 Otherwise returns FALSE. 952 Otherwise returns FALSE.
953*/ 953*/
954bool OContact::match( const QRegExp &r ) const 954bool OContact::match( const QRegExp &r ) const
955{ 955{
956 setLastHitField( -1 );
956 bool match; 957 bool match;
957 match = false; 958 match = false;
958 QMap<int, QString>::ConstIterator it; 959 QMap<int, QString>::ConstIterator it;
959 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 960 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
960 if ( (*it).find( r ) > -1 ) { 961 if ( (*it).find( r ) > -1 ) {
961 setLastHitField( it.key() ); 962 setLastHitField( it.key() );
962 match = true; 963 match = true;
963 break; 964 break;
964 } 965 }
965 } 966 }
966 return match; 967 return match;
967} 968}
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h
index f79f0f3..dd2de17 100644
--- a/libopie/pim/ocontact.h
+++ b/libopie/pim/ocontact.h
@@ -205,28 +205,24 @@ public:
205 205
206 QString toShortText()const; 206 QString toShortText()const;
207 QString OContact::type()const; 207 QString OContact::type()const;
208 QMap<QString,QString> OContact::toExtraMap() const; 208 QMap<QString,QString> OContact::toExtraMap() const;
209 class QString OContact::recordField(int) const; 209 class QString OContact::recordField(int) const;
210 210
211 // Why private ? (eilers,se) 211 // Why private ? (eilers,se)
212 QString emailSeparator() const { return " "; } 212 QString emailSeparator() const { return " "; }
213 // the emails should be seperated by a comma 213 // the emails should be seperated by a comma
214 void setEmails( const QString &v ); 214 void setEmails( const QString &v );
215 QString emails() const { return find( Qtopia::Emails ); } 215 QString emails() const { return find( Qtopia::Emails ); }
216 static int rtti(); 216 static int rtti();
217 int lastHitField() const {return m_lastHitField;};
218protected:
219 mutable int m_lastHitField;
220 void setLastHitField(int i) const { m_lastHitField = i; };
221 217
222private: 218private:
223 // The XML-Backend needs some access to the private functions 219 // The XML-Backend needs some access to the private functions
224 friend class OContactAccessBackend_XML; 220 friend class OContactAccessBackend_XML;
225 221
226 void insert( int key, const QString &value ); 222 void insert( int key, const QString &value );
227 void replace( int key, const QString &value ); 223 void replace( int key, const QString &value );
228 QString find( int key ) const; 224 QString find( int key ) const;
229 static QStringList fields(); 225 static QStringList fields();
230 226
231 void save( QString &buf ) const; 227 void save( QString &buf ) const;
232 228
diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp
index d45417a..9510357 100644
--- a/libopie/pim/opimrecord.cpp
+++ b/libopie/pim/opimrecord.cpp
@@ -2,37 +2,39 @@
2 2
3#include <qpe/categories.h> 3#include <qpe/categories.h>
4#include <qpe/categoryselect.h> 4#include <qpe/categoryselect.h>
5 5
6#include "opimrecord.h" 6#include "opimrecord.h"
7 7
8Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); 8Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia );
9 9
10 10
11OPimRecord::OPimRecord( int uid ) 11OPimRecord::OPimRecord( int uid )
12 : Qtopia::Record() { 12 : Qtopia::Record() {
13 13
14 m_lastHit = -1;
14 setUid( uid ); 15 setUid( uid );
15} 16}
16OPimRecord::~OPimRecord() { 17OPimRecord::~OPimRecord() {
17} 18}
18OPimRecord::OPimRecord( const OPimRecord& rec ) 19OPimRecord::OPimRecord( const OPimRecord& rec )
19 : Qtopia::Record( rec ) 20 : Qtopia::Record( rec )
20{ 21{
21 (*this) = rec; 22 (*this) = rec;
22} 23}
23 24
24OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { 25OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
25 Qtopia::Record::operator=( rec ); 26 Qtopia::Record::operator=( rec );
26 m_xrefman = rec.m_xrefman; 27 m_xrefman = rec.m_xrefman;
28 m_lastHit = rec.m_lastHit;
27 29
28 return *this; 30 return *this;
29} 31}
30/* 32/*
31 * category names 33 * category names
32 */ 34 */
33QStringList OPimRecord::categoryNames( const QString& appname ) const { 35QStringList OPimRecord::categoryNames( const QString& appname ) const {
34 QStringList list; 36 QStringList list;
35 QArray<int> cats = categories(); 37 QArray<int> cats = categories();
36 Categories catDB; 38 Categories catDB;
37 catDB.load( categoryFileName() ); 39 catDB.load( categoryFileName() );
38 40
@@ -155,12 +157,18 @@ OPimXRefPartner OPimRecord::partner( QDataStream& stream ) {
155 157
156 stream >> str; 158 stream >> str;
157 par.setService( str ); 159 par.setService( str );
158 160
159 stream >> i; 161 stream >> i;
160 par.setUid( i ); 162 par.setUid( i );
161 163
162 stream >> i ; 164 stream >> i ;
163 par.setField( i ); 165 par.setField( i );
164 166
165 return par; 167 return par;
166} 168}
169void OPimRecord::setLastHitField( int lastHit )const {
170 m_lastHit = lastHit;
171}
172int OPimRecord::lastHitField()const{
173 return m_lastHit;
174}
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h
index 6e7c0da..494c78e 100644
--- a/libopie/pim/opimrecord.h
+++ b/libopie/pim/opimrecord.h
@@ -67,25 +67,33 @@ public:
67 */ 67 */
68 virtual QString toShortText()const = 0; 68 virtual QString toShortText()const = 0;
69 69
70 /** 70 /**
71 * the name of the Record 71 * the name of the Record
72 */ 72 */
73 virtual QString type()const = 0; 73 virtual QString type()const = 0;
74 74
75 /** 75 /**
76 * matches the Records the regular expression? 76 * matches the Records the regular expression?
77 */ 77 */
78 virtual bool match( const QString &regexp ) const 78 virtual bool match( const QString &regexp ) const
79 {return Qtopia::Record::match(QRegExp(regexp));}; 79 {setLastHitField( -1 );
80 return Qtopia::Record::match(QRegExp(regexp));};
81
82 /**
83 * if implemented this function returns which item has been
84 * last hit by the match() function.
85 * or -1 if not implemented or no hit has occured
86 */
87 int lastHitField()const;
80 88
81 /** 89 /**
82 * converts the internal structure to a map 90 * converts the internal structure to a map
83 */ 91 */
84 virtual QMap<int, QString> toMap()const = 0; 92 virtual QMap<int, QString> toMap()const = 0;
85 93
86 /** 94 /**
87 * key value representation of extra items 95 * key value representation of extra items
88 */ 96 */
89 virtual QMap<QString, QString> toExtraMap()const = 0; 97 virtual QMap<QString, QString> toExtraMap()const = 0;
90 98
91 /** 99 /**
@@ -112,24 +120,27 @@ public:
112 */ 120 */
113 static int rtti(); 121 static int rtti();
114 122
115 /** 123 /**
116 * some marshalling and de marshalling code 124 * some marshalling and de marshalling code
117 * saves the OPimRecord 125 * saves the OPimRecord
118 * to and from a DataStream 126 * to and from a DataStream
119 */ 127 */
120 virtual bool loadFromStream(QDataStream& ); 128 virtual bool loadFromStream(QDataStream& );
121 virtual bool saveToStream( QDataStream& stream )const; 129 virtual bool saveToStream( QDataStream& stream )const;
122 130
123protected: 131protected:
132 // need to be const cause it is called from const methods
133 mutable int m_lastHit;
134 void setLastHitField( int lastHit )const;
124 Qtopia::UidGen &uidGen(); 135 Qtopia::UidGen &uidGen();
125// QString crossToString()const; 136// QString crossToString()const;
126 137
127private: 138private:
128 class OPimRecordPrivate; 139 class OPimRecordPrivate;
129 OPimRecordPrivate *d; 140 OPimRecordPrivate *d;
130 OPimXRefManager m_xrefman; 141 OPimXRefManager m_xrefman;
131 static Qtopia::UidGen m_uidGen; 142 static Qtopia::UidGen m_uidGen;
132 143
133private: 144private:
134 void flush( const OPimXRefPartner&, QDataStream& stream )const; 145 void flush( const OPimXRefPartner&, QDataStream& stream )const;
135 OPimXRefPartner partner( QDataStream& ); 146 OPimXRefPartner partner( QDataStream& );