| 571 | |
| 572 | |
| 573 | bool WizDocument::copyDocumentTo( |
| 574 | const QString& sourceGUID, |
| 575 | WizDatabase& targetDB, |
| 576 | const QString& strTargetLocation, |
| 577 | const WIZTAGDATA& targetTag, |
| 578 | QString& resultGUID, |
| 579 | bool keepDocTime, |
| 580 | bool keepOtherInfo /*= true*/) |
| 581 | { |
| 582 | TOLOG("Copy document"); |
| 583 | WIZDOCUMENTDATA sourceDoc; |
| 584 | if (!m_db.documentFromGuid(sourceGUID, sourceDoc)) |
| 585 | return false; |
| 586 | |
| 587 | if (!WizMakeSureDocumentExistAndBlockWidthEventloop(m_db, sourceDoc)) |
| 588 | return false; |
| 589 | |
| 590 | if (!m_db.tryAccessDocument(sourceDoc)) |
| 591 | return false; |
| 592 | |
| 593 | QByteArray ba; |
| 594 | if (!m_db.loadDocumentDecryptedData(sourceDoc.strGUID, ba)) |
| 595 | return false; |
| 596 | |
| 597 | WIZDOCUMENTDATA newDoc; |
| 598 | if (!targetDB.createDocumentAndInit(sourceDoc, ba, strTargetLocation, targetTag, newDoc)) { |
| 599 | TOLOG("Failed to new document!"); |
| 600 | return false; |
| 601 | } |
| 602 | |
| 603 | resultGUID = newDoc.strGUID; |
| 604 | |
| 605 | if (!copyDocumentAttachment(sourceDoc, targetDB, newDoc)) |
| 606 | return false; |
| 607 | |
| 608 | if (keepDocTime) { |
| 609 | newDoc.tCreated = sourceDoc.tCreated; |
| 610 | newDoc.tAccessed = sourceDoc.tAccessed; |
| 611 | newDoc.tDataModified = sourceDoc.tDataModified; |
| 612 | newDoc.tModified = sourceDoc.tModified; |
| 613 | } |
| 614 | |
| 615 | if (keepOtherInfo) { |
| 616 | newDoc.strURL = sourceDoc.strURL; |
| 617 | } |
| 618 | |
| 619 | newDoc.nAttachmentCount = targetDB.getDocumentAttachmentCount(newDoc.strGUID); |
| 620 | targetDB.modifyDocumentInfoEx(newDoc); |
| 621 | |
| 622 | return true; |
| 623 | } |
| 624 | |
| 625 | bool WizDocument::copyDocumentAttachment(const WIZDOCUMENTDATA& sourceDoc, |
| 626 | WizDatabase& targetDB, WIZDOCUMENTDATA& targetDoc) |
nothing calls this directly
no test coverage detected