Example #1
0
bool CWizIndexBase::GetAllChildTags(const CString& strParentTagGUID, CWizTagDataArray& arrayTag)
{
    CWizTagDataArray arrayTagCurrent;
    GetChildTags(strParentTagGUID, arrayTagCurrent);

    arrayTag.insert(arrayTag.begin(), arrayTagCurrent.begin(), arrayTagCurrent.end());

    CWizTagDataArray::const_iterator it;
    for (it = arrayTagCurrent.begin(); it != arrayTagCurrent.end(); it++) {
        GetAllChildTags(it->strGUID, arrayTag);
    }

    return true;
}
Example #2
0
bool CWizIndexBase::SQLToTagDataArray(const CString& strSQL, CWizTagDataArray& arrayTag)
{
    try
    {
        CppSQLite3Query query = m_db.execQuery(strSQL);
        while (!query.eof())
        {
            WIZTAGDATA data;
            data.strKbGUID = kbGUID();
            data.strGUID = query.getStringField(tagTAG_GUID);
            data.strParentGUID = query.getStringField(tagTAG_GROUP_GUID);
            data.strName = query.getStringField(tagTAG_NAME);
            data.strDescription = query.getStringField(tagTAG_DESCRIPTION);
            data.tModified = query.getTimeField(tagDT_MODIFIED);
            data.nVersion = query.getInt64Field(tagVersion);

            arrayTag.push_back(data);
            query.nextRow();
        }

        std::sort(arrayTag.begin(), arrayTag.end());
        return true;
    }
    catch (const CppSQLite3Exception& e)
    {
        return LogSQLException(e, strSQL);
    }
}
bool CWizDatabase::UpdateTags(const CWizTagDataArray& arrayTag)
{
    if (arrayTag.empty())
        return false;

    qint64 nVersion = -1;

    bool bHasError = false;
    CWizTagDataArray::const_iterator it;
    for (it = arrayTag.begin(); it != arrayTag.end(); it++) {
        const WIZTAGDATA& tag = *it;

        Q_EMIT processLog("tag: " + tag.strName);

        if (!UpdateTag(tag)) {
            bHasError = true;
        }

        nVersion = qMax(nVersion, tag.nVersion);
    }

    if (!bHasError) {
        SetObjectVersion(WIZTAGDATA::ObjectName(), nVersion);
    }

    return !bHasError;
}
Example #4
0
void CWizKbSync::onTagPostList(const CWizTagDataArray& arrayData)
{
    CWizTagDataArray::const_iterator it;
    for (it = arrayData.begin(); it != arrayData.end(); it++) {
        m_db->ModifyObjectVersion(it->strGUID, WIZTAGDATA::ObjectName(), 0);
    }

    uploadNextTags();
}
Example #5
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));
    }
}
Example #6
0
bool CWizIndexBase::GetAllChildTagsSize(const CString& strParentTagGUID, int& size)
{
    int nSizeCurrent;
    GetChildTagsSize(strParentTagGUID, nSizeCurrent);
    size += nSizeCurrent;

    CWizTagDataArray arrayTagCurrent;
    GetChildTags(strParentTagGUID, arrayTagCurrent);

    CWizTagDataArray::const_iterator it;
    for (it = arrayTagCurrent.begin(); it != arrayTagCurrent.end(); it++) {
        GetAllChildTagsSize(it->strGUID, size);
    }

    return true;
}
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());
    }
}