Example #1
0
void CWizNoteInfoForm::setDocument(const WIZDOCUMENTDATA& data)
{
    Q_ASSERT(!data.strKbGUID.isEmpty());
    m_docKbGuid = data.strKbGUID;
    m_docGuid = data.strGUID;

    CWizDatabase& db = CWizDatabaseManager::instance()->db(data.strKbGUID);
    QString doc = db.GetDocumentFileName(data.strGUID);
    QString sz = ::WizGetFileSizeHumanReadalbe(doc);

    ui->editTitle->setText(data.strTitle);

    // private document
    if (data.strKbGUID == CWizDatabaseManager::instance()->db().kbGUID()) {
        ui->labelNotebook->setText(data.strLocation);

        QString tags = db.GetDocumentTagsText(data.strGUID);
        ui->labelTags->setText(tags);

        ui->editAuthor->setText(data.strAuthor);

    // group document
    } else {
        CWizTagDataArray arrayTag;
        if (!db.GetDocumentTags(data.strGUID, arrayTag)) {
            ui->labelNotebook->clear();
        } else {
            if (arrayTag.size() > 1) {
                TOLOG1("Group document should only have one tag: %1", data.strTitle);
            }

            QString tagText;
            if (arrayTag.size()) {
                tagText = db.getTagTreeText(arrayTag[0].strGUID);
            }

            ui->labelNotebook->setText("/" + db.name() + tagText + "/");
        }

        ui->labelTags->clear();
        ui->editAuthor->setText(data.strAuthor);
    }

    // common fields
    ui->editCreateTime->setText(data.tCreated.toString());
    ui->editUpdateTime->setText(data.tModified.toString());
    ui->editURL->setText(data.strURL);
    ui->labelOpenURL->setText(WizFormatString2("<a href=\"%1\">%2</a>", data.strURL, tr("Open")));
    ui->labelSize->setText(sz);
    ui->checkEncrypted->setChecked(data.nProtected ? true : false);

    bool canEdit = (db.CanEditDocument(data) && !CWizDatabase::IsInDeletedItems(data.strLocation));
    ui->editAuthor->setReadOnly(!canEdit);
    ui->editTitle->setReadOnly(!canEdit);
    ui->editURL->setReadOnly(!canEdit);
    ui->checkEncrypted->setEnabled(canEdit && !db.IsGroup());
}
Example #2
0
void CWizKbSync::onTagGetList(const CWizTagDataArray& arrayRet)
{
    m_db->UpdateTags(arrayRet);

    m_arrayAllTagsDownloaded.insert(m_arrayAllTagsDownloaded.end(),
                                    arrayRet.begin(), arrayRet.end());

    qDebug() << "[Syncing]download size: " << m_arrayAllTagsDownloaded.size();

    if (arrayRet.size() < WIZAPI_PAGE_MAX) {
        onDownloadTagsCompleted();
    } else {
        downloadNextTags(WizObjectsGetMaxVersion<WIZTAGDATA>(arrayRet));
    }
}
void CWizCategoryViewGroupItem::drop(const WIZDOCUMENTDATA& data, bool forceCopy)
{
    if (!acceptDrop(data))
        return;

    CWizDatabase& myDb = CWizDatabaseManager::instance()->db(kbGUID());

    if (!forceCopy && data.strKbGUID == m_strKbGUID)
    {
        CWizDocument doc(myDb, data);
        if (data.strLocation == LOCATION_DELETED_ITEMS)
        {
            CWizFolder folder(myDb, myDb.GetDefaultNoteLocation());
            doc.MoveDocument(&folder);
        }

        CWizTagDataArray arrayTag;
        myDb.GetDocumentTags(data.strGUID, arrayTag);
        if (arrayTag.size() > 0)
        {
            for (CWizTagDataArray::const_iterator it = arrayTag.begin(); it != arrayTag.end(); it++)
            {
                doc.RemoveTag(*it);
            }
        }
        doc.AddTag(tag());

    }
    else
    {
        CWizDatabase& sourceDb = CWizDatabaseManager::instance()->db(data.strKbGUID);
        QString strLocation = myDb.GetDefaultNoteLocation();
        Internal::MainWindow* window = qobject_cast<Internal::MainWindow *>(m_app.mainWindow());
        QString strNewDocGUID;
        sourceDb.CopyDocumentTo(data.strGUID, myDb, strLocation, m_tag, strNewDocGUID, window->downloaderHost());
    }
}