77 |
77 |
78 #endif |
78 #endif |
79 |
79 |
80 void CntFilterDetailDisplayLabel::createSelectQuery(const QContactFilter& filter, |
80 void CntFilterDetailDisplayLabel::createSelectQuery(const QContactFilter& filter, |
81 QString& sqlQuery, |
81 QString& sqlQuery, |
82 QContactManager::Error& error) |
82 QContactManager::Error* error) |
83 |
83 |
84 { |
84 { |
85 //Commented currently since this will be checked in contacts call intially |
85 //Commented currently since this will be checked in contacts call intially |
86 //if(filterSupported(filter)) |
86 //if(filterSupported(filter)) |
87 { |
87 { |
88 const QContactDetailFilter detailFilter(filter); |
88 const QContactDetailFilter detailFilter(filter); |
89 |
89 |
90 error = QContactManager::NoError; |
90 *error = QContactManager::NoError; |
91 |
91 |
92 //get the contact fields that should be checked |
92 //get the contact fields that should be checked |
93 CntDisplayLabel displayLabel; |
93 CntDisplayLabel displayLabel; |
94 QList<QPair<QLatin1String, QLatin1String> > contactFields = displayLabel.contactFilterDetails(); |
94 QList<QPair<QLatin1String, QLatin1String> > contactFields = displayLabel.contactFilterDetails(); |
95 |
95 |
122 { |
122 { |
123 createQueryMultipleSearchValues(subQuery, searchStrings, columns); |
123 createQueryMultipleSearchValues(subQuery, searchStrings, columns); |
124 } |
124 } |
125 |
125 |
126 if(!subQuery.isEmpty()){ |
126 if(!subQuery.isEmpty()){ |
127 sqlQuery += " AND (" + subQuery + ")"; |
127 sqlQuery += " AND (" + subQuery + ')'; |
128 } |
128 } |
129 |
129 |
130 error = QContactManager::NoError; |
130 *error = QContactManager::NoError; |
131 } |
131 } |
132 |
132 |
133 //if specified more filter criterias than contact fields return error |
133 //if specified more filter criterias than contact fields return error |
134 else if(searchStrings.count() > contactFields.count()){ |
134 else if(searchStrings.count() > contactFields.count()){ |
135 error = QContactManager::BadArgumentError; |
135 *error = QContactManager::BadArgumentError; |
136 } |
136 } |
137 } |
137 } |
138 |
138 |
139 } |
139 } |
140 |
140 |
141 QString CntFilterDetailDisplayLabel::createSelectQuery(const QContactFilter& filter, |
141 QString CntFilterDetailDisplayLabel::createSelectQuery(const QContactFilter& filter, |
142 const QList<QContactSortOrder>& sortOrders, |
142 const QList<QContactSortOrder>& sortOrders, |
143 QContactManager::Error& error) const |
143 QContactManager::Error* error) const |
144 { |
144 { |
145 Q_UNUSED(sortOrders); |
145 Q_UNUSED(sortOrders); |
146 QString result; |
146 QString result; |
147 //Commented currently since this will be checked in contacts call intially |
147 //Commented currently since this will be checked in contacts call intially |
148 //if(filterSupported(filter)) |
148 //if(filterSupported(filter)) |
149 { |
149 { |
150 const QContactDetailFilter detailFilter(filter); |
150 const QContactDetailFilter detailFilter(filter); |
151 |
151 |
152 error = QContactManager::NoError; |
152 *error = QContactManager::NoError; |
153 |
153 |
154 //get the contact fields that should be checked |
154 //get the contact fields that should be checked |
155 CntDisplayLabel displayLabel; |
155 CntDisplayLabel displayLabel; |
156 QList<QPair<QLatin1String, QLatin1String> > contactFields = displayLabel.contactFilterDetails(); |
156 QList<QPair<QLatin1String, QLatin1String> > contactFields = displayLabel.contactFilterDetails(); |
157 |
157 |
184 { |
184 { |
185 createQueryMultipleSearchValues(subQuery, searchStrings, columns); |
185 createQueryMultipleSearchValues(subQuery, searchStrings, columns); |
186 } |
186 } |
187 |
187 |
188 if(!subQuery.isEmpty()){ |
188 if(!subQuery.isEmpty()){ |
189 result += " AND (" + subQuery + ")"; |
189 result += " AND (" + subQuery + ')'; |
190 } |
190 } |
191 |
191 |
192 error = QContactManager::NoError; |
192 *error = QContactManager::NoError; |
193 } |
193 } |
194 |
194 |
195 //if specified more filter criterias than contact fields return error |
195 //if specified more filter criterias than contact fields return error |
196 else if(searchStrings.count() > contactFields.count()){ |
196 else if(searchStrings.count() > contactFields.count()){ |
197 error = QContactManager::BadArgumentError; |
197 *error = QContactManager::BadArgumentError; |
198 } |
198 } |
199 } |
199 } |
200 |
200 |
201 return result; |
201 return result; |
202 } |
202 } |
244 * \a column to be added to the query |
244 * \a column to be added to the query |
245 * \return the sql LIKE query |
245 * \return the sql LIKE query |
246 */ |
246 */ |
247 QString CntFilterDetailDisplayLabel::createSubQuery(const QString &searchValue, const QString &column) const |
247 QString CntFilterDetailDisplayLabel::createSubQuery(const QString &searchValue, const QString &column) const |
248 { |
248 { |
249 return ("(" + column + " LIKE \'" + searchValue + "%\' OR " + column + " LIKE \'% " + searchValue + "%\')"); |
249 return ('(' + column + " LIKE \'" + searchValue + "%\' OR " + column + " LIKE \'% " + searchValue + "%\')"); |
250 } |
250 } |
251 |
251 |
252 /* |
252 /* |
253 * Get the sql column name based on the detail |
253 * Get the sql column name based on the detail |
254 * |
254 * |
260 QString columnName = ""; |
260 QString columnName = ""; |
261 |
261 |
262 //Name detail |
262 //Name detail |
263 if(detail.first == QContactName::DefinitionName) |
263 if(detail.first == QContactName::DefinitionName) |
264 { |
264 { |
265 if(detail.second == QContactName::FieldFirst) |
265 if(detail.second == QContactName::FieldFirstName) |
266 { |
266 { |
267 columnName = "first_name"; |
267 columnName = "first_name"; |
268 } |
268 } |
269 |
269 |
270 else if(detail.second == QContactName::FieldLast) |
270 else if(detail.second == QContactName::FieldLastName) |
271 { |
271 { |
272 columnName = "last_name"; |
272 columnName = "last_name"; |
273 } |
273 } |
274 } |
274 } |
275 |
275 |