bool CWizIndexBase::ModifyTagEx(const WIZTAGDATA& d) { qDebug() << "modify tag, name: " << d.strName; Q_ASSERT(d.strKbGUID == m_strKbGUID); WIZTAGDATA dataOld; TagFromGUID(d.strGUID, dataOld); WIZTAGDATA data = d; if (data.strGUID == data.strParentGUID) { data.strParentGUID.Empty(); } CString strFormat = FormatUpdateSQLFormat(TABLE_NAME_WIZ_TAG, FIELD_LIST_WIZ_TAG_MODIFY, TABLE_KEY_WIZ_TAG); CString strSQL; strSQL.Format(strFormat, STR2SQL(data.strParentGUID).utf16(), STR2SQL(data.strName).utf16(), STR2SQL(data.strDescription).utf16(), TIME2SQL(data.tModified).utf16(), WizInt64ToStr(data.nVersion).utf16(), STR2SQL(data.strGUID).utf16() ); if (!ExecSQL(strSQL)) return false; WIZTAGDATA dataNew; TagFromGUID(d.strGUID, dataNew); if (!m_bUpdating) { emit tagModified(dataOld, dataNew); } return true; }
bool CWizDatabase::UpdateTag(const WIZTAGDATA& data) { bool bRet = false; WIZTAGDATA dataTemp; if (TagFromGUID(data.strGUID, dataTemp)) { bRet = ModifyTagEx(data); } else { bRet = CreateTagEx(data); } if (!bRet) { Q_EMIT updateError("Failed to update tag: " + data.strName); } return bRet; }