88 Updates widgets. |
88 Updates widgets. |
89 */ |
89 */ |
90 void CaClientProxy::updateWidgets() |
90 void CaClientProxy::updateWidgets() |
91 { |
91 { |
92 qDebug("CaClientProxy::updateWidgets start"); |
92 qDebug("CaClientProxy::updateWidgets start"); |
93 |
93 |
94 HsWidgetRegistryService *rs = |
94 HsWidgetRegistryService *rs = |
95 new HsWidgetRegistryService(mWidgetRegistryPath); |
95 new HsWidgetRegistryService(mWidgetRegistryPath); |
96 QList<HsWidgetToken> widgets = rs->widgets(); |
96 QList<HsWidgetToken> widgets = rs->widgets(); |
97 |
97 |
98 // Read widgets in order to add synchronize the content of the widgets |
98 // Read widgets in order to add synchronize the content of the widgets |
99 // registry with Content Storage database. |
99 // registry with Content Storage database. |
100 foreach (const HsWidgetToken &widgetToken, widgets) { |
100 foreach(const HsWidgetToken &widgetToken, widgets) { |
101 int uid = widgetToken.mUid; |
101 int uid = widgetToken.mUid; |
102 |
102 |
103 if (!hsWidgetExists(uid)) { |
103 if (!hsWidgetExists(uid)) { |
104 // The given widget does not have a corresonding entry |
104 // The given widget does not have a corresonding entry |
105 // in the databse, so such an entry needs do be created. |
105 // in the databse, so such an entry needs do be created. |
106 addWidgetEntry(widgetToken); |
106 addWidgetEntry(widgetToken); |
107 } |
107 } |
108 } |
108 } |
109 |
109 |
110 delete rs; |
110 delete rs; |
111 qDebug("CaClientProxy::updateWidgets end"); |
111 qDebug("CaClientProxy::updateWidgets end"); |
112 } |
112 } |
113 |
113 |
114 /*! |
114 /*! |
125 QSqlDatabase db = dbConnection(); |
125 QSqlDatabase db = dbConnection(); |
126 QSqlQuery query(db); |
126 QSqlQuery query(db); |
127 QString hexUid; |
127 QString hexUid; |
128 hexUid.setNum(uid,16); |
128 hexUid.setNum(uid,16); |
129 QDir currentDir = QDir::current(); |
129 QDir currentDir = QDir::current(); |
130 |
130 |
131 // Add icon. |
131 // Add icon. |
132 QString queryAddIcon = |
132 QString queryAddIcon = |
133 "INSERT INTO CA_ICON " \ |
133 "INSERT INTO CA_ICON " \ |
134 "(IC_FILENAME) " \ |
134 "(IC_FILENAME) " \ |
135 "VALUES " \ |
135 "VALUES " \ |
136 "(?)"; |
136 "(?)"; |
137 |
137 |
138 query.prepare(queryAddIcon); |
138 query.prepare(queryAddIcon); |
139 query.addBindValue(iconUri); |
139 query.addBindValue(iconUri); |
140 query.exec(); |
140 query.exec(); |
141 qDebug() << query.executedQuery(); |
141 qDebug() << query.executedQuery(); |
142 |
142 |
143 // Add entry. |
143 // Add entry. |
144 QString queryAddEntry = |
144 QString queryAddEntry = |
145 "INSERT INTO CA_ENTRY " \ |
145 "INSERT INTO CA_ENTRY " \ |
146 "(EN_TEXT, EN_DESCRIPTION, EN_ROLE, EN_TYPE_NAME, EN_ICON_ID) " \ |
146 "(EN_TEXT, EN_DESCRIPTION, EN_ROLE, EN_TYPE_NAME, EN_ICON_ID) " \ |
147 "VALUES " \ |
147 "VALUES " \ |
148 "(?, ?, 1, 'widget', last_insert_rowid())"; |
148 "(?, ?, 1, 'widget', last_insert_rowid())"; |
149 |
149 |
150 query.prepare(queryAddEntry); |
150 query.prepare(queryAddEntry); |
151 query.addBindValue(title); |
151 query.addBindValue(title); |
152 query.addBindValue(description); |
152 query.addBindValue(description); |
153 query.exec(); |
153 query.exec(); |
154 qDebug() << query.executedQuery(); |
154 qDebug() << query.executedQuery(); |
155 |
155 |
156 // Get last id |
156 // Get last id |
157 QString queryLastId = "SELECT last_insert_rowid() AS LAST_ID"; |
157 QString queryLastId = "SELECT last_insert_rowid() AS LAST_ID"; |
158 query.prepare(queryLastId); |
158 query.prepare(queryLastId); |
159 query.exec(); |
159 query.exec(); |
160 query.next(); |
160 query.next(); |
161 int lastId = query.value(query.record().indexOf("LAST_ID")).toInt(); |
161 int lastId = query.value(query.record().indexOf("LAST_ID")).toInt(); |
162 |
162 |
163 // Add attribute packageuid |
163 // Add attribute packageuid |
164 QString queryAddAttribute1 = |
164 QString queryAddAttribute1 = |
165 "INSERT INTO CA_ATTRIBUTE " \ |
165 "INSERT INTO CA_ATTRIBUTE " \ |
166 "(AT_ENTRY_ID, AT_NAME, AT_VALUE) " \ |
166 "(AT_ENTRY_ID, AT_NAME, AT_VALUE) " \ |
167 "VALUES " \ |
167 "VALUES " \ |
168 "(?, 'packageuid', ?)"; |
168 "(?, 'packageuid', ?)"; |
169 |
169 |
170 query.prepare(queryAddAttribute1); |
170 query.prepare(queryAddAttribute1); |
171 query.addBindValue(lastId); |
171 query.addBindValue(lastId); |
172 query.addBindValue(hexUid); |
172 query.addBindValue(hexUid); |
173 query.exec(); |
173 query.exec(); |
174 qDebug() << query.executedQuery(); |
174 qDebug() << query.executedQuery(); |
175 |
175 |
176 // Add attribute widget uri |
176 // Add attribute widget uri |
177 QString queryAddAttribute2 = |
177 QString queryAddAttribute2 = |
178 "INSERT INTO CA_ATTRIBUTE " \ |
178 "INSERT INTO CA_ATTRIBUTE " \ |
179 "(AT_ENTRY_ID, AT_NAME, AT_VALUE) " \ |
179 "(AT_ENTRY_ID, AT_NAME, AT_VALUE) " \ |
180 "VALUES " \ |
180 "VALUES " \ |
181 "(?, 'widget:uri', ?)"; |
181 "(?, 'widget:uri', ?)"; |
182 |
182 |
183 query.prepare(queryAddAttribute2); |
183 query.prepare(queryAddAttribute2); |
184 query.addBindValue(lastId); |
184 query.addBindValue(lastId); |
185 query.addBindValue(uri); |
185 query.addBindValue(uri); |
186 query.exec(); |
186 query.exec(); |
187 qDebug() << query.executedQuery(); |
187 qDebug() << query.executedQuery(); |
188 |
188 |
189 // Add attribute widget library |
189 // Add attribute widget library |
190 QString queryAddAttribute3 = |
190 QString queryAddAttribute3 = |
191 "INSERT INTO CA_ATTRIBUTE " \ |
191 "INSERT INTO CA_ATTRIBUTE " \ |
192 "(AT_ENTRY_ID, AT_NAME, AT_VALUE) " \ |
192 "(AT_ENTRY_ID, AT_NAME, AT_VALUE) " \ |
193 "VALUES " \ |
193 "VALUES " \ |
194 "(?, 'widget:library', ?)"; |
194 "(?, 'widget:library', ?)"; |
195 |
195 |
196 query.prepare(queryAddAttribute3); |
196 query.prepare(queryAddAttribute3); |
197 query.addBindValue(lastId); |
197 query.addBindValue(lastId); |
198 query.addBindValue(library); |
198 query.addBindValue(library); |
199 query.exec(); |
199 query.exec(); |
206 bool CaClientProxy::hsWidgetExists(int uid) |
206 bool CaClientProxy::hsWidgetExists(int uid) |
207 { |
207 { |
208 bool exists(false); |
208 bool exists(false); |
209 QSqlDatabase db = dbConnection(); |
209 QSqlDatabase db = dbConnection(); |
210 QSqlQuery query(db); |
210 QSqlQuery query(db); |
211 QString hexUid; |
211 QString hexUid; |
212 hexUid.setNum(uid,16); |
212 hexUid.setNum(uid,16); |
213 |
213 |
214 QString queryString = |
214 QString queryString = |
215 "SELECT " \ |
215 "SELECT " \ |
216 "AT_ENTRY_ID " \ |
216 "AT_ENTRY_ID " \ |
217 "FROM " \ |
217 "FROM " \ |
218 "CA_ATTRIBUTE " \ |
218 "CA_ATTRIBUTE " \ |
219 "WHERE " \ |
219 "WHERE " \ |
220 "AT_VALUE LIKE ?"; |
220 "AT_VALUE LIKE ?"; |
221 |
221 |
222 query.prepare(queryString); |
222 query.prepare(queryString); |
223 query.addBindValue(hexUid); |
223 query.addBindValue(hexUid); |
224 |
224 |
225 if (query.exec() && query.next()) { |
225 if (query.exec() && query.next()) { |
226 // Query returned a non empty result. |
226 // Query returned a non empty result. |
227 exists = true; |
227 exists = true; |
228 } else { |
228 } else { |
229 // The widget with the given uid was not found. |
229 // The widget with the given uid was not found. |
230 exists = false; |
230 exists = false; |
231 } |
231 } |
232 |
232 |
233 qDebug() << query.executedQuery(); |
233 qDebug() << query.executedQuery(); |
234 |
234 |
235 return exists; |
235 return exists; |
236 } |
236 } |
237 |
237 |
238 //---------------------------------------------------------------------------- |
238 //---------------------------------------------------------------------------- |
239 // |
239 // |
240 //---------------------------------------------------------------------------- |
240 //---------------------------------------------------------------------------- |
241 ErrorCode CaClientProxy::addData(const CaEntry &entryToAdd, |
241 ErrorCode CaClientProxy::addData(const CaEntry &entryToAdd, |
242 CaEntry &targetEntry) |
242 CaEntry &targetEntry) |
243 { |
243 { |
244 qDebug() << "CaClientProxy::addData" << "entry id: " |
244 qDebug() << "CaClientProxy::addData" << "entry id: " |
245 << entryToAdd.id(); |
245 << entryToAdd.id(); |
246 |
246 |
247 targetEntry = entryToAdd; |
247 targetEntry = entryToAdd; |
248 QSqlDatabase db = dbConnection(); |
248 QSqlDatabase db = dbConnection(); |
249 QSqlQuery query(db); |
249 QSqlQuery query(db); |
250 if (entryToAdd.id() == 0) { |
250 if (entryToAdd.id() == 0) { |
251 CaObjectAdapter::setId(targetEntry, 0); |
251 CaObjectAdapter::setId(targetEntry, 0); |
252 } |
252 } |
253 query.exec("begin"); |
253 query.exec("begin"); |
254 bool success = (setIconInDb(&targetEntry) |
254 bool success = (setIconInDb(&targetEntry) |
255 && setEntryInDb(&targetEntry) |
255 && setEntryInDb(&targetEntry) |
256 && setAttributesInDb(&targetEntry)); |
256 && setAttributesInDb(&targetEntry)); |
257 if (success) { |
257 if (success) { |
258 query.exec("commit"); |
258 query.exec("commit"); |
259 QList<int> parentIds; |
259 QList<int> parentIds; |
260 GetParentsIds(QList<int>() << targetEntry.id(), parentIds); |
260 GetParentsIds(QList<int>() << targetEntry.id(), parentIds); |
261 if (entryToAdd.id() == 0) { |
261 if (entryToAdd.id() == 0) { |
274 // |
274 // |
275 //---------------------------------------------------------------------------- |
275 //---------------------------------------------------------------------------- |
276 ErrorCode CaClientProxy::removeData(const QList<int> &entryIdList) |
276 ErrorCode CaClientProxy::removeData(const QList<int> &entryIdList) |
277 { |
277 { |
278 qDebug() << "CaClientProxy::removeData" << "entryIdList: " |
278 qDebug() << "CaClientProxy::removeData" << "entryIdList: " |
279 << entryIdList; |
279 << entryIdList; |
280 |
280 |
281 QList<CaEntry*> entryList; |
281 QList<CaEntry *> entryList; |
282 getData(entryIdList, entryList); |
282 getData(entryIdList, entryList); |
283 QList<QList<int> > parentsIds; |
283 QList<QList<int> > parentsIds; |
284 foreach (CaEntry *entry, entryList) { |
284 foreach(CaEntry *entry, entryList) { |
285 QList<int> parentIds; |
285 QList<int> parentIds; |
286 GetParentsIds(QList<int>() << entry->id(), parentIds); |
286 GetParentsIds(QList<int>() << entry->id(), parentIds); |
287 parentsIds.append(parentIds); |
287 parentsIds.append(parentIds); |
288 } |
288 } |
289 |
289 |
297 "SELECT ENTRY_ID FROM CA_ENTRY WHERE ENTRY_ID = ?"); |
297 "SELECT ENTRY_ID FROM CA_ENTRY WHERE ENTRY_ID = ?"); |
298 query.addBindValue(entryId); |
298 query.addBindValue(entryId); |
299 success = query.exec(); |
299 success = query.exec(); |
300 if (success && query.next()) { |
300 if (success && query.next()) { |
301 success |
301 success |
302 = query.value(query.record().indexOf("ENTRY_ID")).toInt() |
302 = query.value(query.record().indexOf("ENTRY_ID")).toInt() |
303 > 0; |
303 > 0; |
304 } |
304 } |
305 if (!success) { |
305 if (!success) { |
306 break; |
306 break; |
307 } |
307 } |
308 |
308 |
309 query.prepare( |
309 query.prepare( |
310 "SELECT EN_ICON_ID FROM CA_ENTRY WHERE ENTRY_ID = ?"); |
310 "SELECT EN_ICON_ID FROM CA_ENTRY WHERE ENTRY_ID = ?"); |
311 query.addBindValue(entryId); |
311 query.addBindValue(entryId); |
312 int iconId(0); |
312 int iconId(0); |
313 success = query.exec(); |
313 success = query.exec(); |
314 if (success && query.next()){ |
314 if (success && query.next()) { |
315 iconId |
315 iconId |
316 = query.value(query.record().indexOf("EN_ICON_ID")).toInt(); |
316 = query.value(query.record().indexOf("EN_ICON_ID")).toInt(); |
317 } else { |
317 } else { |
318 break; |
318 break; |
319 } |
319 } |
320 |
320 |
321 query.prepare("DELETE FROM CA_LAUNCH WHERE LA_ENTRY_ID = ?"); |
321 query.prepare("DELETE FROM CA_LAUNCH WHERE LA_ENTRY_ID = ?"); |
322 query.addBindValue(entryId); |
322 query.addBindValue(entryId); |
323 success = query.exec(); |
323 success = query.exec(); |
324 if (success) { |
324 if (success) { |
325 qDebug() << query.lastQuery() << " rows deleted: " |
325 qDebug() << query.lastQuery() << " rows deleted: " |
326 << query.numRowsAffected(); |
326 << query.numRowsAffected(); |
327 } else { |
327 } else { |
328 break; |
328 break; |
329 } |
329 } |
330 |
330 |
331 query.prepare( |
331 query.prepare( |
332 "DELETE FROM CA_GROUP_ENTRY WHERE GE_ENTRY_ID = ?"); |
332 "DELETE FROM CA_GROUP_ENTRY WHERE GE_ENTRY_ID = ?"); |
333 query.addBindValue(entryId); |
333 query.addBindValue(entryId); |
334 success = query.exec(); |
334 success = query.exec(); |
335 if (success) { |
335 if (success) { |
336 qDebug() << query.lastQuery() << " rows deleted: " |
336 qDebug() << query.lastQuery() << " rows deleted: " |
337 << query.numRowsAffected(); |
337 << query.numRowsAffected(); |
338 } else { |
338 } else { |
339 break; |
339 break; |
340 } |
340 } |
341 |
341 |
342 query.prepare( |
342 query.prepare( |
343 "DELETE FROM CA_GROUP_ENTRY WHERE GE_GROUP_ID = ?"); |
343 "DELETE FROM CA_GROUP_ENTRY WHERE GE_GROUP_ID = ?"); |
344 query.addBindValue(entryId); |
344 query.addBindValue(entryId); |
345 success = query.exec(); |
345 success = query.exec(); |
346 if (success) { |
346 if (success) { |
347 qDebug() << query.lastQuery() << " rows deleted: " |
347 qDebug() << query.lastQuery() << " rows deleted: " |
348 << query.numRowsAffected(); |
348 << query.numRowsAffected(); |
349 } else { |
349 } else { |
350 break; |
350 break; |
351 } |
351 } |
352 |
352 |
353 query.prepare("DELETE FROM CA_ATTRIBUTE WHERE AT_ENTRY_ID = ?"); |
353 query.prepare("DELETE FROM CA_ATTRIBUTE WHERE AT_ENTRY_ID = ?"); |
354 query.addBindValue(entryId); |
354 query.addBindValue(entryId); |
355 success = query.exec(); |
355 success = query.exec(); |
356 if (success) { |
356 if (success) { |
357 qDebug() << query.lastQuery() << " rows deleted: " |
357 qDebug() << query.lastQuery() << " rows deleted: " |
358 << query.numRowsAffected(); |
358 << query.numRowsAffected(); |
359 } else { |
359 } else { |
360 break; |
360 break; |
361 } |
361 } |
362 |
362 |
363 query.prepare("DELETE FROM CA_ENTRY WHERE ENTRY_ID = ?"); |
363 query.prepare("DELETE FROM CA_ENTRY WHERE ENTRY_ID = ?"); |
364 query.addBindValue(entryId); |
364 query.addBindValue(entryId); |
365 success = query.exec(); |
365 success = query.exec(); |
366 if (success) { |
366 if (success) { |
367 qDebug() << query.lastQuery() << " rows deleted: " |
367 qDebug() << query.lastQuery() << " rows deleted: " |
368 << query.numRowsAffected(); |
368 << query.numRowsAffected(); |
369 } else { |
369 } else { |
370 break; |
370 break; |
371 } |
371 } |
372 |
372 |
373 if (iconId != 0) { |
373 if (iconId != 0) { |
374 query.prepare("DELETE FROM CA_ICON WHERE ICON_ID = ?"); |
374 query.prepare("DELETE FROM CA_ICON WHERE ICON_ID = ?"); |
375 query.addBindValue(iconId); |
375 query.addBindValue(iconId); |
376 success = query.exec(); |
376 success = query.exec(); |
377 if (success) { |
377 if (success) { |
378 qDebug() << query.lastQuery() << " rows deleted: " |
378 qDebug() << query.lastQuery() << " rows deleted: " |
379 << query.numRowsAffected(); |
379 << query.numRowsAffected(); |
380 } else { |
380 } else { |
381 // ignore, this means that the icon cannot be removed |
381 // ignore, this means that the icon cannot be removed |
382 // because some other entry has the same icon. |
382 // because some other entry has the same icon. |
383 success = true; |
383 success = true; |
384 } |
384 } |
404 |
404 |
405 //---------------------------------------------------------------------------- |
405 //---------------------------------------------------------------------------- |
406 // |
406 // |
407 //---------------------------------------------------------------------------- |
407 //---------------------------------------------------------------------------- |
408 ErrorCode CaClientProxy::insertEntriesIntoGroup(int groupId, |
408 ErrorCode CaClientProxy::insertEntriesIntoGroup(int groupId, |
409 const QList<int> &entryIdList, int beforeEntryId) |
409 const QList<int> &entryIdList, int beforeEntryId) |
410 { |
410 { |
411 qDebug() << "CaClientProxy::insertEntriesIntoGroup" << "groupId: " |
411 qDebug() << "CaClientProxy::insertEntriesIntoGroup" << "groupId: " |
412 << groupId << "beforeEntryId: " << beforeEntryId << "entryIdList: " |
412 << groupId << "beforeEntryId: " << beforeEntryId << "entryIdList: " |
413 << entryIdList; |
413 << entryIdList; |
414 |
414 |
415 removeEntriesFromGroup(groupId, entryIdList, false); |
415 removeEntriesFromGroup(groupId, entryIdList, false); |
416 QString queryText; |
416 QString queryText; |
417 if (beforeEntryId == AfterTheLastEntry) { |
417 if (beforeEntryId == AfterTheLastEntry) { |
418 queryText = QString("INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID,GE_ENTRY_ID,GE_POSITION) " |
418 queryText = QString("INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID,GE_ENTRY_ID,GE_POSITION) " |
419 "VALUES ( ?, ?,(SELECT MAX(DATA) FROM ( SELECT MAX(GE_POSITION)+ 1 AS DATA FROM CA_GROUP_ENTRY " |
419 "VALUES ( ?, ?,(SELECT MAX(DATA) FROM ( SELECT MAX(GE_POSITION)+ 1 AS DATA FROM CA_GROUP_ENTRY " |
420 "WHERE GE_GROUP_ID = %1 UNION SELECT 1 AS DATA FROM CA_GROUP_ENTRY ) ) )").arg(groupId); |
420 "WHERE GE_GROUP_ID = %1 UNION SELECT 1 AS DATA FROM CA_GROUP_ENTRY ) ) )").arg(groupId); |
421 } else if (beforeEntryId == BeforeTheFirstEntry) { |
421 } else if (beforeEntryId == BeforeTheFirstEntry) { |
422 queryText = "INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID,GE_ENTRY_ID,GE_POSITION) VALUES ( ?, ?, 0 ) "; |
422 queryText = "INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID,GE_ENTRY_ID,GE_POSITION) VALUES ( ?, ?, 0 ) "; |
423 } else { |
423 } else { |
424 queryText = QString("INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID,GE_ENTRY_ID,GE_POSITION) VALUES ( " |
424 queryText = QString("INSERT INTO CA_GROUP_ENTRY (GE_GROUP_ID,GE_ENTRY_ID,GE_POSITION) VALUES ( " |
425 "?, ?, ( SELECT GE_POSITION FROM CA_GROUP_ENTRY WHERE GE_ENTRY_ID = %1 ) ) ").arg(beforeEntryId); |
425 "?, ?, ( SELECT GE_POSITION FROM CA_GROUP_ENTRY WHERE GE_ENTRY_ID = %1 ) ) ").arg(beforeEntryId); |
426 } |
426 } |
427 |
427 |
428 bool success = true; |
428 bool success = true; |
429 QSqlDatabase db = dbConnection(); |
429 QSqlDatabase db = dbConnection(); |
430 QSqlQuery query(db); |
430 QSqlQuery query(db); |
484 |
484 |
485 //---------------------------------------------------------------------------- |
485 //---------------------------------------------------------------------------- |
486 // |
486 // |
487 //---------------------------------------------------------------------------- |
487 //---------------------------------------------------------------------------- |
488 ErrorCode CaClientProxy::getData(const QList<int> &entryIdList, |
488 ErrorCode CaClientProxy::getData(const QList<int> &entryIdList, |
489 QList<CaEntry*> &sourceList) |
489 QList<CaEntry *> &sourceList) |
490 { |
490 { |
491 qDebug() << "CaClientProxy::getData" << "entryIdList: " |
491 qDebug() << "CaClientProxy::getData" << "entryIdList: " |
492 << entryIdList; |
492 << entryIdList; |
493 |
493 |
494 QSqlDatabase db = dbConnection(); |
494 QSqlDatabase db = dbConnection(); |
495 |
495 |
496 bool success(true); |
496 bool success(true); |
497 foreach (int i, entryIdList) { |
497 foreach(int i, entryIdList) { |
498 QSqlQuery query(db); |
498 QSqlQuery query(db); |
499 query.prepare( |
499 query.prepare( |
500 "SELECT ENTRY_ID, EN_TEXT, EN_DESCRIPTION, EN_TYPE_NAME, EN_FLAGS, EN_ROLE, EN_UID, \ |
500 "SELECT ENTRY_ID, EN_TEXT, EN_DESCRIPTION, EN_TYPE_NAME, EN_FLAGS, EN_ROLE, EN_UID, \ |
501 ICON_ID, IC_BITMAP_ID, IC_MASK_ID, IC_SKINMAJOR_ID, IC_SKINMINOR_ID, IC_FILENAME \ |
501 ICON_ID, IC_BITMAP_ID, IC_MASK_ID, IC_SKINMAJOR_ID, IC_SKINMINOR_ID, IC_FILENAME \ |
502 FROM CA_ENTRY LEFT JOIN CA_ICON ON EN_ICON_ID = ICON_ID WHERE ENTRY_ID = ?"); |
502 FROM CA_ENTRY LEFT JOIN CA_ICON ON EN_ICON_ID = ICON_ID WHERE ENTRY_ID = ?"); |
505 success = query.exec(); |
505 success = query.exec(); |
506 if (success && query.next()) { |
506 if (success && query.next()) { |
507 qDebug() << query.executedQuery(); |
507 qDebug() << query.executedQuery(); |
508 int role = |
508 int role = |
509 query.value(query.record().indexOf("EN_ROLE")).toInt(); |
509 query.value(query.record().indexOf("EN_ROLE")).toInt(); |
510 CaEntry* entry = new CaEntry((EntryRole) role); |
510 CaEntry *entry = new CaEntry((EntryRole) role); |
511 CaObjectAdapter::setId(*entry, |
511 CaObjectAdapter::setId(*entry, |
512 query.value(query.record().indexOf("ENTRY_ID")).toInt()); |
512 query.value(query.record().indexOf("ENTRY_ID")).toInt()); |
513 entry->setText(query.value( |
513 entry->setText(query.value( |
514 query.record().indexOf("EN_TEXT")).toString()); |
514 query.record().indexOf("EN_TEXT")).toString()); |
515 entry->setDescription(query.value( |
515 entry->setDescription(query.value( |
516 query.record().indexOf("EN_DESCRIPTION")).toString()); |
516 query.record().indexOf("EN_DESCRIPTION")).toString()); |
517 entry->setEntryTypeName(query.value(query.record().indexOf( |
517 entry->setEntryTypeName(query.value(query.record().indexOf( |
518 "EN_TYPE_NAME")).toString()); |
518 "EN_TYPE_NAME")).toString()); |
519 entry->setFlags(static_cast<EntryFlag> (query.value( |
519 entry->setFlags(static_cast<EntryFlag>(query.value( |
520 query.record().indexOf("EN_FLAGS")).toUInt())); |
520 query.record().indexOf("EN_FLAGS")).toUInt())); |
521 |
521 |
522 CaIconDescription icon; |
522 CaIconDescription icon; |
523 CaObjectAdapter::setId(icon, |
523 CaObjectAdapter::setId(icon, |
524 query.value(query.record().indexOf("ICON_ID")).toInt()); |
524 query.value(query.record().indexOf("ICON_ID")).toInt()); |
525 icon.setBitmapId(query.value(query.record().indexOf( |
525 icon.setBitmapId(query.value(query.record().indexOf( |
526 "IC_BITMAP_ID")).toInt()); |
526 "IC_BITMAP_ID")).toInt()); |
527 icon.setMaskId(query.value(query.record().indexOf( |
527 icon.setMaskId(query.value(query.record().indexOf( |
528 "IC_MASK_ID")).toInt()); |
528 "IC_MASK_ID")).toInt()); |
529 icon.setSkinMajorId(query.value(query.record().indexOf( |
529 icon.setSkinMajorId(query.value(query.record().indexOf( |
530 "IC_SKINMAJOR_ID")).toInt()); |
530 "IC_SKINMAJOR_ID")).toInt()); |
531 icon.setSkinMinorId(query.value(query.record().indexOf( |
531 icon.setSkinMinorId(query.value(query.record().indexOf( |
532 "IC_SKINMINOR_ID")).toInt()); |
532 "IC_SKINMINOR_ID")).toInt()); |
533 icon.setFilename(query.value(query.record().indexOf( |
533 icon.setFilename(query.value(query.record().indexOf( |
534 "IC_FILENAME")).toString()); |
534 "IC_FILENAME")).toString()); |
535 entry->setIconDescription(icon); |
535 entry->setIconDescription(icon); |
536 |
536 |
537 // attributes |
537 // attributes |
538 // UID as attribute |
538 // UID as attribute |
539 if (query.value(query.record().indexOf("EN_UID")).toString().length() |
539 if (query.value(query.record().indexOf("EN_UID")).toString().length() |
540 > 0) { |
540 > 0) { |
541 entry->setAttribute("application:uid", query.value( |
541 entry->setAttribute("application:uid", query.value( |
542 query.record().indexOf("EN_UID")).toString()); |
542 query.record().indexOf("EN_UID")).toString()); |
543 } |
543 } |
544 |
544 |
545 // fetch from DB attributes |
545 // fetch from DB attributes |
546 QSqlQuery attributesQuery(db); |
546 QSqlQuery attributesQuery(db); |
547 attributesQuery.prepare( |
547 attributesQuery.prepare( |
586 |
586 |
587 //---------------------------------------------------------------------------- |
587 //---------------------------------------------------------------------------- |
588 // |
588 // |
589 //---------------------------------------------------------------------------- |
589 //---------------------------------------------------------------------------- |
590 ErrorCode CaClientProxy::getEntryIds(const CaQuery &query, |
590 ErrorCode CaClientProxy::getEntryIds(const CaQuery &query, |
591 QList<int> &sourceIdList) |
591 QList<int> &sourceIdList) |
592 { |
592 { |
593 qDebug() << "CaClientProxy::getEntryIds"; |
593 qDebug() << "CaClientProxy::getEntryIds"; |
594 |
594 |
595 QSqlDatabase db = dbConnection(); |
595 QSqlDatabase db = dbConnection(); |
596 |
596 |
597 bool success(true); |
597 bool success(true); |
598 QString whereStatement; |
598 QString whereStatement; |
599 if (query.flagsOn() != 0) |
599 if (query.flagsOn() != 0) |
600 whereStatement.append(" AND ").append(QString().setNum( |
600 whereStatement.append(" AND ").append(QString().setNum( |
601 query.flagsOn())).append(" & EN_FLAGS == ").append( |
601 query.flagsOn())).append(" & EN_FLAGS == ").append( |
602 QString().setNum(query.flagsOn())); |
602 QString().setNum(query.flagsOn())); |
603 if (query.flagsOff() != 0) |
603 if (query.flagsOff() != 0) |
604 whereStatement.append(" AND ").append(QString().setNum( |
604 whereStatement.append(" AND ").append(QString().setNum( |
605 query.flagsOff())).append(" & (~EN_FLAGS) == ").append( |
605 query.flagsOff())).append(" & (~EN_FLAGS) == ").append( |
606 QString().setNum(query.flagsOff())); |
606 QString().setNum(query.flagsOff())); |
607 if (query.entryRoles() != 0) |
607 if (query.entryRoles() != 0) |
608 whereStatement.append(" AND ").append(QString().setNum( |
608 whereStatement.append(" AND ").append(QString().setNum( |
609 query.entryRoles())) .append(" | EN_ROLE == ").append( |
609 query.entryRoles())) .append(" | EN_ROLE == ").append( |
610 QString().setNum(query.entryRoles())); |
610 QString().setNum(query.entryRoles())); |
611 //TODO: by uid??? |
611 //TODO: by uid??? |
612 |
612 |
613 if (query.entryTypeNames().count()) { |
613 if (query.entryTypeNames().count()) { |
614 whereStatement.append(" AND EN_TYPE_NAME IN ("); |
614 whereStatement.append(" AND EN_TYPE_NAME IN ("); |
615 for (int i = 0; i < query.entryTypeNames().count(); i++) { |
615 for (int i = 0; i < query.entryTypeNames().count(); i++) { |
627 queryString.append(whereStatement); |
627 queryString.append(whereStatement); |
628 modifyQueryForSortOrder(queryString, query, false); |
628 modifyQueryForSortOrder(queryString, query, false); |
629 if (query.count() > 0) |
629 if (query.count() > 0) |
630 queryString.append(" LIMIT ").append(query.count()); |
630 queryString.append(" LIMIT ").append(query.count()); |
631 qDebug() << "CaServicePrivate::getEntryIds query text: " |
631 qDebug() << "CaServicePrivate::getEntryIds query text: " |
632 << queryString; |
632 << queryString; |
633 success = sqlquery.prepare(queryString); |
633 success = sqlquery.prepare(queryString); |
634 success = sqlquery.exec(); |
634 success = sqlquery.exec(); |
635 if (success) { |
635 if (success) { |
636 while (sqlquery.next()) { |
636 while (sqlquery.next()) { |
637 sourceIdList << sqlquery.value(sqlquery.record().indexOf( |
637 sourceIdList << sqlquery.value(sqlquery.record().indexOf( |
638 "ENTRY_ID")).toInt(); |
638 "ENTRY_ID")).toInt(); |
639 } |
639 } |
640 } |
640 } |
641 } |
641 } else { |
642 else { |
|
643 QString |
642 QString |
644 queryString( |
643 queryString( |
645 "SELECT ENTRY_ID FROM CA_ENTRY \ |
644 "SELECT ENTRY_ID FROM CA_ENTRY \ |
646 LEFT JOIN CA_GROUP_ENTRY ON GE_ENTRY_ID = ENTRY_ID WHERE GE_GROUP_ID = ? "); |
645 LEFT JOIN CA_GROUP_ENTRY ON GE_ENTRY_ID = ENTRY_ID WHERE GE_GROUP_ID = ? "); |
647 queryString.append(whereStatement); |
646 queryString.append(whereStatement); |
648 modifyQueryForSortOrder(queryString, query, true); |
647 modifyQueryForSortOrder(queryString, query, true); |
649 if (query.count() > 0) |
648 if (query.count() > 0) |
650 queryString.append(" LIMIT ").append(query.count()); |
649 queryString.append(" LIMIT ").append(query.count()); |
651 qDebug() << "CaServicePrivate::getEntryIds query text: " |
650 qDebug() << "CaServicePrivate::getEntryIds query text: " |
652 << queryString; |
651 << queryString; |
653 sqlquery.prepare(queryString); |
652 sqlquery.prepare(queryString); |
654 sqlquery.addBindValue(query.parentId()); |
653 sqlquery.addBindValue(query.parentId()); |
655 success = sqlquery.exec(); |
654 success = sqlquery.exec(); |
656 if (success) { |
655 if (success) { |
657 while (sqlquery.next()) { |
656 while (sqlquery.next()) { |
658 sourceIdList << sqlquery.value(sqlquery.record().indexOf( |
657 sourceIdList << sqlquery.value(sqlquery.record().indexOf( |
659 "ENTRY_ID")).toInt(); |
658 "ENTRY_ID")).toInt(); |
660 } |
659 } |
661 } |
660 } |
662 } |
661 } |
663 ErrorCode error = UnknownErrorCode; |
662 ErrorCode error = UnknownErrorCode; |
664 if (success) { |
663 if (success) { |
665 error = NoErrorCode; |
664 error = NoErrorCode; |
666 } |
665 } |
667 return error; |
666 return error; |
668 } |
667 } |
669 |
668 |
670 //---------------------------------------------------------------------------- |
669 //---------------------------------------------------------------------------- |
671 // |
670 // |
672 //---------------------------------------------------------------------------- |
671 //---------------------------------------------------------------------------- |
673 ErrorCode CaClientProxy::executeCommand(const CaEntry &entry, |
672 ErrorCode CaClientProxy::executeCommand(const CaEntry &entry, |
674 const QString &command) |
673 const QString &command) |
675 { |
674 { |
676 qDebug() << "CaClientProxy::executeCommand" << "entry id: " |
675 qDebug() << "CaClientProxy::executeCommand" << "entry id: " |
677 << entry.id() << "command: " << command; |
676 << entry.id() << "command: " << command; |
678 return touch(entry); |
677 return NoErrorCode; |
679 } |
678 } |
680 |
679 |
681 //---------------------------------------------------------------------------- |
680 //---------------------------------------------------------------------------- |
682 // |
681 // |
683 //---------------------------------------------------------------------------- |
682 //---------------------------------------------------------------------------- |
716 } |
715 } |
717 } else { |
716 } else { |
718 query.exec("rollback"); |
717 query.exec("rollback"); |
719 error = UnknownErrorCode; |
718 error = UnknownErrorCode; |
720 } |
719 } |
721 |
720 |
722 return error; |
721 return error; |
723 } |
722 } |
724 |
723 |
725 //---------------------------------------------------------------------------- |
724 //---------------------------------------------------------------------------- |
726 // |
725 // |
727 //---------------------------------------------------------------------------- |
726 //---------------------------------------------------------------------------- |
728 ErrorCode CaClientProxy::customSort(const QList<int> &entryIdList, |
727 ErrorCode CaClientProxy::customSort(const QList<int> &entryIdList, |
729 int groupId) |
728 int groupId) |
730 { |
729 { |
731 bool success = true; |
730 bool success = true; |
732 QSqlDatabase db = dbConnection(); |
731 QSqlDatabase db = dbConnection(); |
733 QSqlQuery query(db); |
732 QSqlQuery query(db); |
734 query.exec("begin"); |
733 query.exec("begin"); |
735 for (int i = 0; i < entryIdList.count(); i++) { |
734 for (int i = 0; i < entryIdList.count(); i++) { |
736 int position = i+1; |
735 int position = i+1; |
737 query.prepare( |
736 query.prepare( |
738 "UPDATE CA_GROUP_ENTRY SET GE_POSITION = ? WHERE GE_ENTRY_ID = ? AND GE_GROUP_ID = ?" ); |
737 "UPDATE CA_GROUP_ENTRY SET GE_POSITION = ? WHERE GE_ENTRY_ID = ? AND GE_GROUP_ID = ?"); |
739 query.addBindValue(position); |
738 query.addBindValue(position); |
740 query.addBindValue(entryIdList.at(i)); |
739 query.addBindValue(entryIdList.at(i)); |
741 query.addBindValue(groupId); |
740 query.addBindValue(groupId); |
742 success = query.exec(); |
741 success = query.exec(); |
743 if (!success) { |
742 if (!success) { |
757 } |
756 } |
758 |
757 |
759 /*! |
758 /*! |
760 //TODO: |
759 //TODO: |
761 */ |
760 */ |
762 void CaClientProxy::modifyQueryForSortOrder(QString& queryString, |
761 void CaClientProxy::modifyQueryForSortOrder(QString &queryString, |
763 const CaQuery &query, bool parent) const |
762 const CaQuery &query, bool parent) const |
764 { |
763 { |
765 SortAttribute sortAttribute; |
764 SortAttribute sortAttribute; |
766 Qt::SortOrder sortOrder; |
765 Qt::SortOrder sortOrder; |
767 query.getSort(sortAttribute, sortOrder); |
766 query.getSort(sortAttribute, sortOrder); |
768 QString oldQueryString(queryString); |
767 QString oldQueryString(queryString); |
769 queryString.clear(); |
768 queryString.clear(); |
770 |
769 |
771 if (sortAttribute == NameSortAttribute) { |
770 if (sortAttribute == NameSortAttribute) { |
772 queryString.append(oldQueryString).append(" ORDER BY EN_TEXT "); |
771 queryString.append(oldQueryString).append(" ORDER BY EN_TEXT "); |
773 } |
772 } else if (sortAttribute == CreatedTimestampSortAttribute) { |
774 else if (sortAttribute == CreatedTimestampSortAttribute) { |
|
775 queryString.append(oldQueryString).append( |
773 queryString.append(oldQueryString).append( |
776 " ORDER BY EN_CREATION_TIME "); |
774 " ORDER BY EN_CREATION_TIME "); |
777 } |
775 } else if (sortAttribute == MostUsedSortAttribute) { |
778 else if (sortAttribute == MostUsedSortAttribute) { |
|
779 queryString.append("SELECT ENTRY_ID FROM (").append(oldQueryString).append( |
776 queryString.append("SELECT ENTRY_ID FROM (").append(oldQueryString).append( |
780 " \ |
777 " \ |
781 ) LEFT JOIN \ |
778 ) LEFT JOIN \ |
782 (SELECT LA_ENTRY_ID, COUNT(*) AS USAGE_DATA FROM CA_LAUNCH GROUP BY LA_ENTRY_ID) \ |
779 (SELECT LA_ENTRY_ID, COUNT(*) AS USAGE_DATA FROM CA_LAUNCH GROUP BY LA_ENTRY_ID) \ |
783 ON ENTRY_ID = LA_ENTRY_ID ORDER BY USAGE_DATA "); |
780 ON ENTRY_ID = LA_ENTRY_ID ORDER BY USAGE_DATA "); |
784 } |
781 } else if (sortAttribute == LastUsedSortAttribute) { |
785 else if (sortAttribute == LastUsedSortAttribute) { |
|
786 queryString.append("SELECT ENTRY_ID FROM (").append(oldQueryString).append( |
782 queryString.append("SELECT ENTRY_ID FROM (").append(oldQueryString).append( |
787 " \ |
783 " \ |
788 ) LEFT JOIN \ |
784 ) LEFT JOIN \ |
789 (SELECT LA_ENTRY_ID, MAX(LA_LAUNCH_TIME) AS USAGE_DATA FROM CA_LAUNCH GROUP BY LA_ENTRY_ID) \ |
785 (SELECT LA_ENTRY_ID, MAX(LA_LAUNCH_TIME) AS USAGE_DATA FROM CA_LAUNCH GROUP BY LA_ENTRY_ID) \ |
790 ON ENTRY_ID = LA_ENTRY_ID ORDER BY USAGE_DATA "); |
786 ON ENTRY_ID = LA_ENTRY_ID ORDER BY USAGE_DATA "); |
791 } |
787 } else if (parent && sortAttribute == DefaultSortAttribute) { |
792 else if (parent && sortAttribute == DefaultSortAttribute) { |
|
793 queryString.append(oldQueryString).append( |
788 queryString.append(oldQueryString).append( |
794 " ORDER BY GE_GROUP_ID, GE_POSITION "); |
789 " ORDER BY GE_GROUP_ID, GE_POSITION "); |
795 } |
790 } else if (!parent && sortAttribute == DefaultSortAttribute) { |
796 else if (!parent && sortAttribute == DefaultSortAttribute) { |
|
797 queryString.append(oldQueryString).append(" ORDER BY ENTRY_ID "); |
791 queryString.append(oldQueryString).append(" ORDER BY ENTRY_ID "); |
798 } |
792 } else { |
799 else { |
|
800 queryString.append(oldQueryString); |
793 queryString.append(oldQueryString); |
801 } |
794 } |
802 |
795 |
803 if (sortAttribute == NameSortAttribute || sortAttribute |
796 if (sortAttribute == NameSortAttribute || sortAttribute |
804 == CreatedTimestampSortAttribute || sortAttribute |
797 == CreatedTimestampSortAttribute || sortAttribute |
805 == MostUsedSortAttribute || sortAttribute == LastUsedSortAttribute |
798 == MostUsedSortAttribute || sortAttribute == LastUsedSortAttribute |
806 || (sortAttribute == DefaultSortAttribute && parent)) { |
799 || (sortAttribute == DefaultSortAttribute && parent)) { |
807 if (sortOrder == Qt::AscendingOrder) |
800 if (sortOrder == Qt::AscendingOrder) |
808 queryString.append(" ASC "); |
801 queryString.append(" ASC "); |
809 else |
802 else |
810 queryString.append(" DESC "); |
803 queryString.append(" DESC "); |
811 } |
804 } |
824 AND IC_BITMAP_ID = :IC_BITMAP_ID \ |
817 AND IC_BITMAP_ID = :IC_BITMAP_ID \ |
825 AND IC_MASK_ID = :IC_MASK_ID \ |
818 AND IC_MASK_ID = :IC_MASK_ID \ |
826 AND IC_SKINMAJOR_ID = :IC_SKINMAJOR_ID \ |
819 AND IC_SKINMAJOR_ID = :IC_SKINMAJOR_ID \ |
827 AND IC_SKINMINOR_ID = :IC_SKINMINOR_ID"); |
820 AND IC_SKINMINOR_ID = :IC_SKINMINOR_ID"); |
828 query.bindValue(":IC_FILENAME", |
821 query.bindValue(":IC_FILENAME", |
829 entryClone->iconDescription().filename()); |
822 entryClone->iconDescription().filename()); |
830 query.bindValue(":IC_BITMAP_ID", |
823 query.bindValue(":IC_BITMAP_ID", |
831 entryClone->iconDescription().bitmapId()); |
824 entryClone->iconDescription().bitmapId()); |
832 query.bindValue(":IC_MASK_ID", entryClone->iconDescription().maskId()); |
825 query.bindValue(":IC_MASK_ID", entryClone->iconDescription().maskId()); |
833 query.bindValue(":IC_SKINMAJOR_ID", |
826 query.bindValue(":IC_SKINMAJOR_ID", |
834 entryClone->iconDescription().skinMajorId()); |
827 entryClone->iconDescription().skinMajorId()); |
835 query.bindValue(":IC_SKINMINOR_ID", |
828 query.bindValue(":IC_SKINMINOR_ID", |
836 entryClone->iconDescription().skinMinorId()); |
829 entryClone->iconDescription().skinMinorId()); |
837 |
830 |
838 bool success = query.exec(); |
831 bool success = query.exec(); |
839 if (success && query.next()) { |
832 if (success && query.next()) { |
840 qDebug() << "query.executedQuery() : " << query.executedQuery(); |
833 qDebug() << "query.executedQuery() : " << query.executedQuery(); |
841 int iconId = query.value(query.record().indexOf("ICON_ID")).toInt(); |
834 int iconId = query.value(query.record().indexOf("ICON_ID")).toInt(); |
842 qDebug() << "iconId = " << iconId; |
835 qDebug() << "iconId = " << iconId; |
843 CaIconDescription iconDescription = entryClone->iconDescription(); |
836 CaIconDescription iconDescription = entryClone->iconDescription(); |
844 if (iconId <= 0 && (iconDescription.filename() != "" |
837 if (iconId <= 0 && (iconDescription.filename() != "" |
845 || iconDescription.bitmapId() != 0 || iconDescription.maskId() != 0 |
838 || iconDescription.bitmapId() != 0 || iconDescription.maskId() != 0 |
846 || iconDescription.skinMajorId() != 0 |
839 || iconDescription.skinMajorId() != 0 |
847 || iconDescription.skinMinorId() != 0)) { |
840 || iconDescription.skinMinorId() != 0)) { |
848 query.prepare( |
841 query.prepare( |
849 "INSERT INTO CA_ICON \ |
842 "INSERT INTO CA_ICON \ |
850 (IC_FILENAME,IC_BITMAP_ID,IC_MASK_ID,IC_SKINMAJOR_ID,IC_SKINMINOR_ID) \ |
843 (IC_FILENAME,IC_BITMAP_ID,IC_MASK_ID,IC_SKINMAJOR_ID,IC_SKINMINOR_ID) \ |
851 VALUES ( ? , ? , ? , ? , ? )"); |
844 VALUES ( ? , ? , ? , ? , ? )"); |
852 query.addBindValue(iconDescription.filename()); |
845 query.addBindValue(iconDescription.filename()); |
870 bool CaClientProxy::setEntryInDb(CaEntry *entryClone) const |
863 bool CaClientProxy::setEntryInDb(CaEntry *entryClone) const |
871 { |
864 { |
872 QSqlQuery query(dbConnection()); |
865 QSqlQuery query(dbConnection()); |
873 bool isNewEntry(entryClone->id() <= 0); |
866 bool isNewEntry(entryClone->id() <= 0); |
874 QString |
867 QString |
875 queryText( |
868 queryText( |
876 "INSERT INTO CA_ENTRY \ |
869 "INSERT INTO CA_ENTRY \ |
877 (EN_TEXT,EN_ROLE,EN_TYPE_NAME,EN_FLAGS,EN_ICON_ID ) VALUES ( ?, ?, ?, ?, "); |
870 (EN_TEXT,EN_ROLE,EN_TYPE_NAME,EN_FLAGS,EN_ICON_ID ) VALUES ( ?, ?, ?, ?, "); |
878 if (!isNewEntry) |
871 if (!isNewEntry) |
879 queryText |
872 queryText |
880 = "REPLACE INTO CA_ENTRY \ |
873 = "REPLACE INTO CA_ENTRY \ |
881 (ENTRY_ID,EN_TEXT,EN_ROLE,EN_TYPE_NAME,EN_FLAGS,EN_ICON_ID ) VALUES ( ?, ?, ?, ?, ?, "; |
874 (ENTRY_ID,EN_TEXT,EN_ROLE,EN_TYPE_NAME,EN_FLAGS,EN_ICON_ID ) VALUES ( ?, ?, ?, ?, ?, "; |
882 if (entryClone->iconDescription().id() > 0) { |
875 if (entryClone->iconDescription().id() > 0) { |
883 queryText.append("?"); |
876 queryText.append("?"); |
884 } |
877 } else { |
885 else { |
|
886 queryText.append("NULL"); |
878 queryText.append("NULL"); |
887 } |
879 } |
888 queryText.append(")"); |
880 queryText.append(")"); |
889 query.prepare(queryText); |
881 query.prepare(queryText); |
890 if (!isNewEntry) |
882 if (!isNewEntry) |
926 { |
918 { |
927 bool success = true; |
919 bool success = true; |
928 QSqlQuery query(dbConnection()); |
920 QSqlQuery query(dbConnection()); |
929 if (entryClone->attributes().count() > 0) { |
921 if (entryClone->attributes().count() > 0) { |
930 QMap<QString, QString> attributesMap = entryClone->attributes(); |
922 QMap<QString, QString> attributesMap = entryClone->attributes(); |
931 foreach (QString key, attributesMap.keys()) { |
923 foreach(QString key, attributesMap.keys()) { |
932 query.prepare( |
924 query.prepare( |
933 "REPLACE INTO CA_ATTRIBUTE (AT_ENTRY_ID,AT_NAME,AT_VALUE) VALUES ( \ |
925 "REPLACE INTO CA_ATTRIBUTE (AT_ENTRY_ID,AT_NAME,AT_VALUE) VALUES ( \ |
934 :AT_ENTRY_ID,\ |
926 :AT_ENTRY_ID,\ |
935 :AT_NAME,\ |
927 :AT_NAME,\ |
936 :AT_VALUE )"); |
928 :AT_VALUE )"); |
937 query.bindValue(":AT_ENTRY_ID", entryClone->id()); |
929 query.bindValue(":AT_ENTRY_ID", entryClone->id()); |
938 query.bindValue(":AT_NAME", key); |
930 query.bindValue(":AT_NAME", key); |
939 query.bindValue(":AT_VALUE", attributesMap.value(key)); |
931 query.bindValue(":AT_VALUE", attributesMap.value(key)); |
940 success = query.exec(); |
932 success = query.exec(); |
941 if (!success) { |
933 if (!success) { |
942 break; |
934 break; |
943 } |
|
944 qDebug() << "CaServicePrivate::setAttributesInDb" |
|
945 << query.boundValues(); |
|
946 } |
935 } |
947 } |
936 qDebug() << "CaServicePrivate::setAttributesInDb" |
948 return success; |
937 << query.boundValues(); |
|
938 } |
|
939 } |
|
940 return success; |
949 } |
941 } |
950 |
942 |
951 |
943 |
952 void CaClientProxy::CreateGetParentsIdsQuery( |
944 void CaClientProxy::CreateGetParentsIdsQuery( |
953 const QList<int> &entryIds, |
945 const QList<int> &entryIds, |