bool CWizIndexBase::SQLToStyleDataArray(const CString& strSQL, CWizStyleDataArray& arrayStyle) { try { CppSQLite3Query query = m_db.execQuery(strSQL); while (!query.eof()) { WIZSTYLEDATA data; data.strKbGUID = kbGUID(); data.strGUID = query.getStringField(styleSTYLE_GUID); data.strName = query.getStringField(styleSTYLE_NAME); data.strDescription = query.getStringField(styleSTYLE_DESCRIPTION); data.crTextColor = query.getColorField(styleSTYLE_TEXT_COLOR); data.crBackColor = query.getColorField(styleSTYLE_BACK_COLOR); data.bTextBold = query.getBoolField(styleSTYLE_TEXT_BOLD); data.nFlagIndex = query.getIntField(styleSTYLE_FLAG_INDEX); data.tModified = query.getTimeField(styleDT_MODIFIED); data.nVersion = query.getInt64Field(styleVersion); arrayStyle.push_back(data); query.nextRow(); } std::sort(arrayStyle.begin(), arrayStyle.end()); return true; } catch (const CppSQLite3Exception& e) { return LogSQLException(e, strSQL); } }
bool CWizDatabase::UpdateStyles(const CWizStyleDataArray& arrayStyle) { if (arrayStyle.empty()) return true; qint64 nVersion = -1; bool bHasError = false; CWizStyleDataArray::const_iterator it; for (it = arrayStyle.begin(); it != arrayStyle.end(); it++) { const WIZSTYLEDATA& data = *it; Q_EMIT processLog("style: " + data.strName); if (!UpdateStyle(data)) { bHasError = true; } nVersion = qMax(nVersion, data.nVersion); } if (!bHasError) { SetObjectVersion(WIZSTYLEDATA::ObjectName(), nVersion); } return !bHasError; }
void CWizKbSync::onStylePostList(const CWizStyleDataArray& arrayData) { CWizStyleDataArray::const_iterator it; for (it = arrayData.begin(); it != arrayData.end(); it++) { m_db->ModifyObjectVersion(it->strGUID, WIZSTYLEDATA::ObjectName(), 0); } uploadNextStyles(); }
void CWizKbSync::onStyleGetList(const CWizStyleDataArray& arrayRet) { m_db->UpdateStyles(arrayRet); m_arrayAllStylesDownloaded.insert(m_arrayAllStylesDownloaded.end(), arrayRet.begin(), arrayRet.end()); qDebug() << "[Syncing]download size: " << m_arrayAllStylesDownloaded.size(); if (arrayRet.size() < WIZAPI_PAGE_MAX) { onDownloadStylesCompleted(); } else { downloadNextStyles(WizObjectsGetMaxVersion<WIZSTYLEDATA>(arrayRet)); } }