author | zautrix <zautrix> | 2005-08-22 15:42:41 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-22 15:42:41 (UTC) |
commit | 1d82d044bbdedd407f6d08305522187ffd256552 (patch) (unidiff) | |
tree | 08f5651d72548b643ed012e5f6ad938b36d1ae3f /kabc/address.cpp | |
parent | f516a558e6d18982a54152b28ca3da78fe76e3fc (diff) | |
download | kdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.zip kdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.tar.gz kdepimpi-1d82d044bbdedd407f6d08305522187ffd256552.tar.bz2 |
kapi search fix
-rw-r--r-- | kabc/address.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/kabc/address.cpp b/kabc/address.cpp index 5ffe511..6151f9e 100644 --- a/kabc/address.cpp +++ b/kabc/address.cpp | |||
@@ -56,96 +56,123 @@ Address::Address( int type ) : | |||
56 | 56 | ||
57 | bool Address::operator==( const Address &a ) const | 57 | bool Address::operator==( const Address &a ) const |
58 | { | 58 | { |
59 | if ( mPostOfficeBox != a.mPostOfficeBox ) return false; | 59 | if ( mPostOfficeBox != a.mPostOfficeBox ) return false; |
60 | if ( mExtended != a.mExtended ) return false; | 60 | if ( mExtended != a.mExtended ) return false; |
61 | if ( mStreet != a.mStreet ) return false; | 61 | if ( mStreet != a.mStreet ) return false; |
62 | if ( mLocality != a.mLocality ) return false; | 62 | if ( mLocality != a.mLocality ) return false; |
63 | if ( mRegion != a.mRegion ) return false; | 63 | if ( mRegion != a.mRegion ) return false; |
64 | if ( mPostalCode != a.mPostalCode ) return false; | 64 | if ( mPostalCode != a.mPostalCode ) return false; |
65 | if ( mCountry != a.mCountry ) return false; | 65 | if ( mCountry != a.mCountry ) return false; |
66 | if ( mLabel != a.mLabel ) return false; | 66 | if ( mLabel != a.mLabel ) return false; |
67 | 67 | ||
68 | return true; | 68 | return true; |
69 | } | 69 | } |
70 | 70 | ||
71 | bool Address::operator!=( const Address &a ) const | 71 | bool Address::operator!=( const Address &a ) const |
72 | { | 72 | { |
73 | return !( a == *this ); | 73 | return !( a == *this ); |
74 | } | 74 | } |
75 | 75 | ||
76 | bool Address::isEmpty() const | 76 | bool Address::isEmpty() const |
77 | { | 77 | { |
78 | if ( mPostOfficeBox.isEmpty() && | 78 | if ( mPostOfficeBox.isEmpty() && |
79 | mExtended.isEmpty() && | 79 | mExtended.isEmpty() && |
80 | mStreet.isEmpty() && | 80 | mStreet.isEmpty() && |
81 | mLocality.isEmpty() && | 81 | mLocality.isEmpty() && |
82 | mRegion.isEmpty() && | 82 | mRegion.isEmpty() && |
83 | mPostalCode.isEmpty() && | 83 | mPostalCode.isEmpty() && |
84 | mCountry.isEmpty() && | 84 | mCountry.isEmpty() && |
85 | mLabel.isEmpty() ) { | 85 | mLabel.isEmpty() ) { |
86 | return true; | 86 | return true; |
87 | } | 87 | } |
88 | return false; | 88 | return false; |
89 | } | 89 | } |
90 | 90 | ||
91 | QStringList Address::asList() | 91 | QStringList Address::asList() |
92 | { | 92 | { |
93 | QStringList result; | 93 | QStringList result; |
94 | if ( ! mPostOfficeBox.isEmpty() )result.append(mPostOfficeBox); | 94 | if ( ! mPostOfficeBox.isEmpty() )result.append(mPostOfficeBox); |
95 | if ( ! mExtended.isEmpty())result.append(mExtended); | 95 | if ( ! mExtended.isEmpty())result.append(mExtended); |
96 | if ( ! mStreet.isEmpty())result.append(mStreet); | 96 | if ( ! mStreet.isEmpty())result.append(mStreet); |
97 | if ( ! mLocality.isEmpty() )result.append(mLocality); | 97 | if ( ! mLocality.isEmpty() )result.append(mLocality); |
98 | if ( ! mRegion.isEmpty())result.append(mRegion); | 98 | if ( ! mRegion.isEmpty())result.append(mRegion); |
99 | if ( ! mPostalCode.isEmpty())result.append(mPostalCode); | 99 | if ( ! mPostalCode.isEmpty())result.append(mPostalCode); |
100 | if ( ! mCountry.isEmpty())result.append(mCountry); | 100 | if ( ! mCountry.isEmpty())result.append(mCountry); |
101 | if ( ! mLabel.isEmpty() )result.append(mLabel); | 101 | if ( ! mLabel.isEmpty() )result.append(mLabel); |
102 | return result; | 102 | return result; |
103 | } | 103 | } |
104 | |||
105 | bool Address::matchAddress( QRegExp* re ) const | ||
106 | { | ||
107 | |||
108 | #if QT_VERSION >= 0x030000 | ||
109 | if (re->search( mPostOfficeBox ) == 0) return true; | ||
110 | if (re->search( mExtended ) == 0) return true; | ||
111 | if (re->search( mStreet ) == 0) return true; | ||
112 | if (re->search( mLocality ) == 0) return true; | ||
113 | if (re->search( mRegion ) == 0) return true; | ||
114 | if (re->search( mPostalCode ) == 0) return true; | ||
115 | if (re->search( mCountry ) == 0) return true; | ||
116 | if (re->search( mLabel ) == 0) return true; | ||
117 | #else | ||
118 | if (re->match( mPostOfficeBox ) == 0) return true; | ||
119 | if (re->match( mExtended ) == 0) return true; | ||
120 | if (re->match( mStreet ) == 0) return true; | ||
121 | if (re->match( mLocality ) == 0) return true; | ||
122 | if (re->match( mRegion ) == 0) return true; | ||
123 | if (re->match( mPostalCode ) == 0) return true; | ||
124 | if (re->match( mCountry ) == 0) return true; | ||
125 | if (re->match( mLabel ) == 0) return true; | ||
126 | #endif | ||
127 | |||
128 | return false; | ||
129 | } | ||
130 | |||
104 | void Address::clear() | 131 | void Address::clear() |
105 | { | 132 | { |
106 | *this = Address(); | 133 | *this = Address(); |
107 | } | 134 | } |
108 | 135 | ||
109 | void Address::setId( const QString &id ) | 136 | void Address::setId( const QString &id ) |
110 | { | 137 | { |
111 | mEmpty = false; | 138 | mEmpty = false; |
112 | 139 | ||
113 | mId = id; | 140 | mId = id; |
114 | } | 141 | } |
115 | 142 | ||
116 | QString Address::id() const | 143 | QString Address::id() const |
117 | { | 144 | { |
118 | return mId; | 145 | return mId; |
119 | } | 146 | } |
120 | 147 | ||
121 | void Address::setType( int type ) | 148 | void Address::setType( int type ) |
122 | { | 149 | { |
123 | mEmpty = false; | 150 | mEmpty = false; |
124 | 151 | ||
125 | mType = type; | 152 | mType = type; |
126 | } | 153 | } |
127 | 154 | ||
128 | int Address::type() const | 155 | int Address::type() const |
129 | { | 156 | { |
130 | return mType; | 157 | return mType; |
131 | } | 158 | } |
132 | 159 | ||
133 | QString Address::typeLabel() const | 160 | QString Address::typeLabel() const |
134 | { | 161 | { |
135 | QString label; | 162 | QString label; |
136 | bool first = true; | 163 | bool first = true; |
137 | 164 | ||
138 | TypeList list = typeList(); | 165 | TypeList list = typeList(); |
139 | 166 | ||
140 | TypeList::Iterator it; | 167 | TypeList::Iterator it; |
141 | for ( it = list.begin(); it != list.end(); ++it ) { | 168 | for ( it = list.begin(); it != list.end(); ++it ) { |
142 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { | 169 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { |
143 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); | 170 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); |
144 | if ( first ) | 171 | if ( first ) |
145 | first = false; | 172 | first = false; |
146 | } | 173 | } |
147 | } | 174 | } |
148 | 175 | ||
149 | return label; | 176 | return label; |
150 | } | 177 | } |
151 | 178 | ||