Return if a note is dirty given its lid
| 2473 | |
| 2474 | // Return if a note is dirty given its lid |
| 2475 | void NoteTable::pinNote(qint32 lid, bool value) { |
| 2476 | if (value && isPinned(lid)) |
| 2477 | return; |
| 2478 | |
| 2479 | NSqlQuery query(db); |
| 2480 | db->lockForWrite(); |
| 2481 | query.prepare("Delete from DataStore where key=:key and lid=:lid"); |
| 2482 | query.bindValue(":lid", lid); |
| 2483 | query.bindValue(":key", NOTE_ISPINNED); |
| 2484 | query.exec(); |
| 2485 | |
| 2486 | if (!value) { |
| 2487 | query.prepare("Update NoteTable set isPinned=0 where lid=:lid"); |
| 2488 | query.bindValue(":lid", lid); |
| 2489 | query.exec(); |
| 2490 | QLOG_DEBUG() << query.lastError(); |
| 2491 | query.finish(); |
| 2492 | return; |
| 2493 | } |
| 2494 | |
| 2495 | query.prepare("Insert into DataStore (lid, key, data) values (:lid, :key, 1)"); |
| 2496 | query.bindValue(":lid", lid); |
| 2497 | query.bindValue(":key", NOTE_ISPINNED); |
| 2498 | query.exec(); |
| 2499 | |
| 2500 | query.prepare("Update NoteTable set isPinned=1 where lid=:lid"); |
| 2501 | query.bindValue(":lid", lid); |
| 2502 | query.exec(); |
| 2503 | query.lastError(); |
| 2504 | query.finish(); |
| 2505 | db->unlock(); |
| 2506 | |
| 2507 | //setDirty(lid, true, false); |
| 2508 | } |
| 2509 | |
| 2510 | |
| 2511 | // Determine if a note is pinned given a guid |
no test coverage detected