MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / updateDocumentAbstract

Method updateDocumentAbstract

src/database/WizDatabase.cpp:4317–4414  ·  view source on GitHub ↗

! Update document abstract from local cache. */

Source from the content-addressed store, hash-verified

4315 Update document abstract from local cache.
4316 */
4317bool WizDatabase::updateDocumentAbstract(const QString& strDocumentGUID)
4318{
4319 CString strFileName = getDocumentFileName(strDocumentGUID);
4320 if (!WizPathFileExists(strFileName)) {
4321 return false;
4322 }
4323
4324 WIZDOCUMENTDATA data;
4325 if (!documentFromGuid(strDocumentGUID, data)) {
4326 qDebug() << "[updateDocumentAbstract]invalide guid: " << strDocumentGUID;
4327 return false;
4328 }
4329
4330 if (data.nProtected)
4331 emptyProtectedAbstract(strDocumentGUID);
4332
4333 QString strTempFolder = Utils::WizPathResolve::tempPath() + data.strGUID + "-thumb/";
4334 // delete folder to clear unused images.
4335 ::WizDeleteAllFilesInFolder(strTempFolder);
4336 if (!documentToHtmlFile(data, strTempFolder)) {
4337 qDebug() << "[updateDocumentAbstract]decompress to temp failed, guid: "
4338 << strDocumentGUID;
4339 return false;
4340 }
4341 CString strHtmlFileName = strTempFolder + "index.html";
4342
4343 CString strHtmlTempPath = Utils::WizMisc::extractFilePath(strHtmlFileName);
4344
4345 CString strHtml;
4346 ::WizLoadUnicodeTextFromFile(strHtmlFileName, strHtml);
4347
4348 WIZABSTRACT abstract;
4349 abstract.guid = strDocumentGUID;
4350
4351 WizHtmlToPlainText htmlConverter;
4352 htmlConverter.toText(strHtml, abstract.text);
4353 abstract.text = abstract.text.left(2000);
4354
4355 CString strResourcePath = Utils::WizMisc::extractFilePath(strHtmlFileName) + "index_files/";
4356 CWizStdStringArray arrayImageFileName;
4357 ::WizEnumFiles(strResourcePath, "*.jpg;*.png;*.bmp;*.gif", arrayImageFileName, 0);
4358 if (!arrayImageFileName.empty())
4359 {
4360 CString strImageFileName;
4361
4362 qint64 m = 0;
4363 CWizStdStringArray::const_iterator it;
4364 for (it = arrayImageFileName.begin(); it != arrayImageFileName.end(); it++) {
4365 CString strFileName = *it;
4366 //
4367 QString name = Utils::WizMisc::extractFileName(strFileName);
4368 if (name.startsWith("wizIcon"))
4369 continue;
4370 if (name.startsWith("checked"))
4371 continue;
4372 if (name.startsWith("unchecked"))
4373 continue;
4374 //

Callers 2

load_implMethod · 0.80

Calls 13

WizPathFileExistsFunction · 0.85
WizEnumFilesFunction · 0.85
WizDeleteFolderFunction · 0.85
toTextMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
isEmptyMethod · 0.80
widthMethod · 0.80
heightMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected