equal
deleted
inserted
replaced
57 // TODO Auto-generated destructor stub |
57 // TODO Auto-generated destructor stub |
58 } |
58 } |
59 |
59 |
60 void CntDisplayLabelSqlFilter::createSqlQuery(const QContactDetailFilter& filter, |
60 void CntDisplayLabelSqlFilter::createSqlQuery(const QContactDetailFilter& filter, |
61 QString& sqlQuery, |
61 QString& sqlQuery, |
62 QContactManager::Error& error) |
62 QContactManager::Error* error) |
63 { |
63 { |
64 error = QContactManager::NoError; |
64 *error = QContactManager::NoError; |
65 |
65 |
66 //get the contact fields that should be checked |
66 //get the contact fields that should be checked |
67 CntDisplayLabel displayLabel; |
67 CntDisplayLabel displayLabel; |
68 QList<QPair<QLatin1String, QLatin1String> > contactFields = displayLabel.contactFilterDetails(); |
68 QList<QPair<QLatin1String, QLatin1String> > contactFields = displayLabel.contactFilterDetails(); |
69 |
69 |
96 { |
96 { |
97 createQueryMultipleSearchValues(subQuery, searchStrings, columns); |
97 createQueryMultipleSearchValues(subQuery, searchStrings, columns); |
98 } |
98 } |
99 |
99 |
100 if(!subQuery.isEmpty()){ |
100 if(!subQuery.isEmpty()){ |
101 sqlQuery += " AND (" + subQuery + ")"; |
101 sqlQuery += " AND (" + subQuery + ')'; |
102 } |
102 } |
103 |
103 |
104 error = QContactManager::NoError; |
104 *error = QContactManager::NoError; |
105 } |
105 } |
106 |
106 |
107 //if specified more filter criterias than contact fields return error |
107 //if specified more filter criterias than contact fields return error |
108 else if(searchStrings.count() > contactFields.count()){ |
108 else if(searchStrings.count() > contactFields.count()){ |
109 error = QContactManager::BadArgumentError; |
109 *error = QContactManager::BadArgumentError; |
110 } |
110 } |
111 } |
111 } |
112 |
112 |
113 /* Creates a sql query for a single search value |
113 /* Creates a sql query for a single search value |
114 * |
114 * |
153 * \a column to be added to the query |
153 * \a column to be added to the query |
154 * \return the sql LIKE query |
154 * \return the sql LIKE query |
155 */ |
155 */ |
156 QString CntDisplayLabelSqlFilter::createSubQuery(const QString &searchValue, const QString &column) const |
156 QString CntDisplayLabelSqlFilter::createSubQuery(const QString &searchValue, const QString &column) const |
157 { |
157 { |
158 return ("(" + column + " LIKE \'" + searchValue + "%\' OR " + column + " LIKE \'% " + searchValue + "%\')"); |
158 return ('(' + column + " LIKE \'" + searchValue + "%\' OR " + column + " LIKE \'% " + searchValue + "%\')"); |
159 } |
159 } |
160 |
160 |
161 /* |
161 /* |
162 * Get the sql column name based on the detail |
162 * Get the sql column name based on the detail |
163 * |
163 * |
169 QString columnName = ""; |
169 QString columnName = ""; |
170 |
170 |
171 //Name detail |
171 //Name detail |
172 if(detail.first == QContactName::DefinitionName) |
172 if(detail.first == QContactName::DefinitionName) |
173 { |
173 { |
174 if(detail.second == QContactName::FieldFirst) |
174 if(detail.second == QContactName::FieldFirstName) |
175 { |
175 { |
176 columnName = "first_name"; |
176 columnName = "first_name"; |
177 } |
177 } |
178 |
178 |
179 else if(detail.second == QContactName::FieldLast) |
179 else if(detail.second == QContactName::FieldLastName) |
180 { |
180 { |
181 columnName = "last_name"; |
181 columnName = "last_name"; |
182 } |
182 } |
183 } |
183 } |
184 |
184 |