void CWizFolderView::initFolders() { CWizCategoryViewAllFoldersItem* pAllFoldersItem = new CWizCategoryViewAllFoldersItem(m_app, tr("Note Folders"), m_dbMgr.db().kbGUID()); addTopLevelItem(pAllFoldersItem); CWizStdStringArray arrayAllLocation; m_dbMgr.db().GetAllLocations(arrayAllLocation); // folder cache CWizStdStringArray arrayExtLocation; m_dbMgr.db().GetExtraFolder(arrayExtLocation); if (!arrayExtLocation.empty()) { for (CWizStdStringArray::const_iterator it = arrayExtLocation.begin(); it != arrayExtLocation.end(); it++) { if (-1 == ::WizFindInArray(arrayAllLocation, *it)) { arrayAllLocation.push_back(*it); } } } if (arrayAllLocation.empty()) { arrayAllLocation.push_back(m_dbMgr.db().GetDefaultNoteLocation()); } initFolders(pAllFoldersItem, "", arrayAllLocation); pAllFoldersItem->setExpanded(true); pAllFoldersItem->sortChildren(0, Qt::AscendingOrder); }
BOOL CWizKMDatabaseServer::document_downloadFullListEx(const CWizStdStringArray& arrayDocumentGUID, std::deque<WIZDOCUMENTDATAEX>& arrayRet) { int nCountPerPage = 30; // CWizStdStringArray::const_iterator it = arrayDocumentGUID.begin(); // while (1) { // CWizStdStringArray subArray; // for (; it != arrayDocumentGUID.end(); ) { subArray.push_back(*it); it++; // if (subArray.size() == nCountPerPage) break; } // std::deque<WIZDOCUMENTDATAEX> subRet; if (!document_downloadFullList(subArray, subRet)) return FALSE; // arrayRet.insert(arrayRet.end(), subRet.begin(), subRet.end()); // if (it == arrayDocumentGUID.end()) break; } // return TRUE; }
GenericName[en_US.UTF-8]=WizNote\n\ "; void installOnLinux() { QString appPath = Utils::PathResolve::appPath(); QString strText = WizFormatString3(g_lpszDesktopFileName, appPath, QObject::tr("WizNote"), QObject::tr("WizNote")); // QString applicationsPath = QDir::homePath() + "/.local/share/applications/"; ::WizEnsurePathExists(applicationsPath); // QString iconsBasePath = QDir::homePath() + "/.local/share/icons/hicolor/"; ::WizEnsurePathExists(applicationsPath); // CWizStdStringArray arrayIconSize; arrayIconSize.push_back("16"); arrayIconSize.push_back("32"); arrayIconSize.push_back("48"); arrayIconSize.push_back("64"); arrayIconSize.push_back("128"); arrayIconSize.push_back("256"); for (CWizStdStringArray::const_iterator it = arrayIconSize.begin(); it != arrayIconSize.end(); it++) { QString iconSize = *it; QString iconPathName = iconSize + "x" + iconSize; QString iconFullPath = iconsBasePath + iconPathName + "/apps/"; WizEnsurePathExists(iconFullPath); // QString resourceName = ":/logo_" + iconSize + ".png"; QPixmap pixmap(resourceName); if (pixmap.isNull()) continue; // pixmap.save(iconFullPath + "wiznote.png"); } QString desktopFileName = applicationsPath + "wiznote.desktop"; ::WizSaveUnicodeTextToUtf8File(desktopFileName, strText, false); // chmod(desktopFileName.toUtf8(), ACCESSPERMS); }
void CWizKbSync::queryAttachmentInfo(const CString& strGUID, const CString& strName) { Q_EMIT processLog(tr("query attachment info: ") + strName); CWizStdStringArray arrayGUID; arrayGUID.push_back(strGUID); callAttachmentsGetInfo(arrayGUID); }
void CWizKbSync::queryDocumentInfo(const CString& strGUID, const CString& strTitle) { Q_EMIT processLog(tr("query note info: ") + strTitle); CWizStdStringArray arrayGUID; arrayGUID.push_back(strGUID); callDocumentsGetInfo(arrayGUID); }
bool CWizIndexBase::SQLToDocumentDataArray(const CString& strSQL, CWizDocumentDataArray& arrayDocument) { try { CppSQLite3Query query = m_db.execQuery(strSQL); CWizStdStringArray arrayGUID; std::map<CString, int> mapDocumentIndex; while (!query.eof()) { WIZDOCUMENTDATA data; data.strKbGUID = kbGUID(); data.strGUID = query.getStringField(documentDOCUMENT_GUID); data.strTitle = query.getStringField(documentDOCUMENT_TITLE); data.strLocation = query.getStringField(documentDOCUMENT_LOCATION); data.strName = query.getStringField(documentDOCUMENT_NAME); data.strSEO = query.getStringField(documentDOCUMENT_SEO); data.strURL = query.getStringField(documentDOCUMENT_URL); data.strAuthor = query.getStringField(documentDOCUMENT_AUTHOR); data.strKeywords = query.getStringField(documentDOCUMENT_KEYWORDS); data.strType = query.getStringField(documentDOCUMENT_TYPE); data.strOwner = query.getStringField(documentDOCUMENT_OWNER); data.strFileType = query.getStringField(documentDOCUMENT_FILE_TYPE); data.strStyleGUID = query.getStringField(documentSTYLE_GUID); data.tCreated = query.getTimeField(documentDT_CREATED); data.tModified = query.getTimeField(documentDT_MODIFIED); data.tAccessed = query.getTimeField(documentDT_ACCESSED); data.nIconIndex = query.getIntField(documentDOCUMENT_ICON_INDEX); data.nSync = query.getIntField(documentDOCUMENT_SYNC); data.nProtected = query.getIntField(documentDOCUMENT_PROTECT); data.nReadCount = query.getIntField(documentDOCUMENT_READ_COUNT); data.nAttachmentCount = query.getIntField(documentDOCUMENT_ATTACHEMENT_COUNT); data.nIndexed = query.getIntField(documentDOCUMENT_INDEXED); data.tInfoModified = query.getTimeField(documentDT_INFO_MODIFIED); data.strInfoMD5 = query.getStringField(documentDOCUMENT_INFO_MD5); data.tDataModified = query.getTimeField(documentDT_DATA_MODIFIED); data.strDataMD5 = query.getStringField(documentDOCUMENT_DATA_MD5); data.tParamModified = query.getTimeField(documentDT_PARAM_MODIFIED); data.strParamMD5 = query.getStringField(documentDOCUMENT_PARAM_MD5); data.nVersion = query.getInt64Field(documentVersion); arrayGUID.push_back(data.strGUID); arrayDocument.push_back(data); mapDocumentIndex[data.strGUID] = int(arrayDocument.size() - 1); query.nextRow(); } if (!arrayGUID.empty()) { InitDocumentExFields(arrayDocument, arrayGUID, mapDocumentIndex); } return true; } catch (const CppSQLite3Exception& e) { return LogSQLException(e, strSQL); } }
BOOL WIZDOCUMENTDATAEX::ParamArrayToStringArray(CWizStdStringArray& params) const { for (std::deque<WIZDOCUMENTPARAMDATA>::const_iterator it = arrayParam.begin(); it != arrayParam.end(); it++) { params.push_back(it->strName + _T("=") + it->strValue); } return TRUE; }
QString note2Mime(const CWizDocumentDataArray& arrayDocument) { CWizStdStringArray arrayGUID; for (CWizDocumentDataArray::const_iterator it = arrayDocument.begin(); it != arrayDocument.end(); it++) { const WIZDOCUMENTDATA& data = *it; arrayGUID.push_back(data.strKbGUID + ":" + data.strGUID); } CString strMime; ::WizStringArrayToText(arrayGUID, strMime, ";"); return strMime; }
bool WizXmlRpcArrayValue::toStringArray(CWizStdStringArray& arrayRet) { std::deque<WizXmlRpcValue*>::const_iterator it; for (it = m_array.begin(); it != m_array.end(); it++) { WizXmlRpcStringValue* pValue = dynamic_cast<WizXmlRpcStringValue*>(*it); if (!pValue) { TOLOG("Fault error: element of array is null or not a string"); return false; } QString str = *pValue; arrayRet.push_back(str); } return true; }
BOOL CWizXmlRpcArrayValue::ToStringArray(CWizStdStringArray& arrayRet) { for (std::deque<CWizXmlRpcValue*>::const_iterator it = m_array.begin(); it != m_array.end(); it++) { CWizXmlRpcStringValue* pValue = dynamic_cast<CWizXmlRpcStringValue*>(*it); if (!pValue) { TOLOG(_T("Fault error: element of array is null or not a string")); return FALSE; } // arrayRet.push_back(pValue->ToString()); } // return TRUE; }
bool CWizIndexBase::SQLToStringArray(const CString& strSQL, int nFieldIndex, CWizStdStringArray& arrayString) { try { CppSQLite3Query query = m_db.execQuery(strSQL); while (!query.eof()) { CString strGUID = query.getStringField(nFieldIndex); arrayString.push_back(strGUID); query.nextRow(); } return true; } catch (const CppSQLite3Exception& e) { return LogSQLException(e, strSQL); } }
QWebEngineProfile* createWebEngineProfile(const WizWebEngineViewInjectObjects& objects, QObject* parent) { if (objects.empty()) return nullptr; // QWebEngineProfile *profile = new QWebEngineProfile("WizNoteWebEngineProfile", parent); // QString jsWebChannelFileName = Utils::WizPathResolve::resourcesPath() + "files/webengine/wizwebchannel.js"; QString jsWebChannel; WizLoadUnicodeTextFromFile(jsWebChannelFileName, jsWebChannel); // QString initFileName = Utils::WizPathResolve::resourcesPath() + "files/webengine/wizwebengineviewinit.js"; QString jsInit; WizLoadUnicodeTextFromFile(initFileName, jsInit); // CWizStdStringArray names; for (auto inject : objects) { names.push_back("\"" + inject.name + "\""); } // CString objectNames; WizStringArrayToText(names, objectNames, ", "); // jsInit.replace("__objectNames__", objectNames); // QString jsAll = jsWebChannel + "\n" + jsInit; // { QWebEngineScript script; script.setSourceCode(jsAll); script.setName("qwebchannel.js"); script.setWorldId(QWebEngineScript::MainWorld); script.setInjectionPoint(QWebEngineScript::DocumentCreation); script.setRunsOnSubFrames(true); profile->scripts()->insert(script); } // return profile; }
void CWizDocumentListView::startDrag(Qt::DropActions supportedActions) { Q_UNUSED(supportedActions); CWizStdStringArray arrayGUID; QList<QListWidgetItem*> items = selectedItems(); foreach (QListWidgetItem* it, items) { if (CWizDocumentListViewItem* item = dynamic_cast<CWizDocumentListViewItem*>(it)) { // not support drag group document currently if (item->document().strKbGUID != m_dbMgr.db().kbGUID()) return; arrayGUID.push_back((item->document().strGUID)); } } if (arrayGUID.empty()) return; CString strGUIDs; ::WizStringArrayToText(arrayGUID, strGUIDs, ";"); QDrag* drag = new QDrag(this); QMimeData* mimeData = new QMimeData(); mimeData->setData(WIZNOTE_MIMEFORMAT_DOCUMENTS, strGUIDs.toUtf8()); drag->setMimeData(mimeData); // FIXME: need deal with more then 1 drag event! if (items.size() == 1) { QRect rect = visualItemRect(items[0]); drag->setPixmap(QPixmap::grabWindow(winId(), rect.x(), rect.y(), rect.width(), rect.height())); } drag->exec(); }
void CWizFolderView::initFolders() { CWizCategoryViewAllFoldersItem* pAllFoldersItem = new CWizCategoryViewAllFoldersItem(m_app, tr("Note Folders"), m_dbMgr.db().kbGUID()); addTopLevelItem(pAllFoldersItem); CWizStdStringArray arrayAllLocation; m_dbMgr.db().GetAllLocations(arrayAllLocation); initFolders(pAllFoldersItem, "", arrayAllLocation); if (arrayAllLocation.empty()) { const QString strNotes("/My Notes/"); m_dbMgr.db().AddExtraFolder(strNotes); m_dbMgr.db().SetObjectVersion("folder", 0); arrayAllLocation.push_back(strNotes); } //init extra folders CWizStdStringArray arrayExtLocation; m_dbMgr.db().GetExtraFolder(arrayExtLocation); CWizStdStringArray::const_iterator it; for (it = arrayExtLocation.begin(); it != arrayExtLocation.end(); it++) { QString strLocation = *it; if (strLocation.isEmpty()) continue; if (m_dbMgr.db().IsInDeletedItems(strLocation)) continue; addFolder(strLocation, true); } pAllFoldersItem->setExpanded(true); pAllFoldersItem->sortChildren(0, Qt::AscendingOrder); }
void CWizSync::queryDocumentInfo(const CString& strGUID, const CString& strTitle) { // if current modified document already inside need download list, means confilict found! // no need to query document info anymore. std::deque<WIZDOCUMENTDATABASE>::const_iterator it; for (it = m_arrayAllDocumentsNeedToBeDownloaded.begin(); \ it != m_arrayAllDocumentsNeedToBeDownloaded.end(); it++) { WIZDOCUMENTDATABASE data = *it; if (data.strGUID == strGUID) { Q_EMIT processLog(tr("Conflict found: ") + strTitle); m_conflictedDocument = data; callDocumentGetData(data); return; } } Q_EMIT processLog(tr("query note info: ") + strTitle); CWizStdStringArray arrayGUID; arrayGUID.push_back(strGUID); callDocumentsGetInfo(arrayGUID); }
bool WizKMCombineDocumentsToHtmlFile(WizDatabaseManager& dbMgr, const CWizDocumentDataArray& arrayDocument, QString splitter, bool addTitle, QString& strResultFileName, CWizDocumentAttachmentDataArray& arrayAttachment, QString& strError) { QString strTempPath = Utils::WizPathResolve::tempPath() + WizGenGUIDLowerCaseLetterOnly() + "/"; ::WizEnsurePathExists(strTempPath); // CWizStdStringArray htmls; // size_t nCount = arrayDocument.size(); for (size_t i = 0; i < nCount; i++) { WIZDOCUMENTDATA doc = arrayDocument[i]; // WizDatabase& db = dbMgr.db(doc.strKbGUID); if (!db.isDocumentDownloaded(doc.strGUID)) { strError = QObject::tr("Note has not been downloaded"); return false; } // if (!db.documentToHtmlFile(doc, strTempPath)) { strError = QObject::tr("Failed to get note data"); return false; } // QString htmlFileName = strTempPath + "index.html"; if (!QFileInfo::exists(htmlFileName)) { strError = QObject::tr("Failed to get note data"); return false; } // QString html; if (!WizLoadUnicodeTextFromFile(htmlFileName, html)) { strError = QObject::tr("Failed to read note data"); return false; } // htmls.push_back(html); // CWizDocumentAttachmentDataArray atts; db.getDocumentAttachments(doc.strGUID, atts); for (WIZDOCUMENTATTACHMENTDATA att : atts) { if (!db.isAttachmentDownloaded(att.strGUID)) { strError = QObject::tr("Note attachment %1 has not been downloaded").arg(att.strName); return false; } // arrayAttachment.push_back(att); } } // CString strAllHTML; // for (size_t i = 0; i < nCount; i++) { CString html = htmls[i]; WIZDOCUMENTDATA doc = arrayDocument[i]; if (-1 != WizStrStrI_Pos(html, CString(_T("<frameset")))) { strError = QObject::tr("Cannot combine html because html contains frame set"); return false; } // CString strTitle = doc.strTitle; WizOleDateTime t = doc.tCreated; CString strDate = t.toLocalLongDate(); // if (addTitle) { CString strInfoHtml = WizFormatString2(_T("<h2>%1 (%2)</h2>"), strTitle, strDate); ::WizHTMLInsertTextBeforeBody(strInfoHtml, html); } // if (!WizCombineHtmlText(strAllHTML, html)) { strError = QObject::tr("Cannot combine html"); return false; } // if (i < nCount - 1) { if (!splitter.isEmpty()) { WizCombineHtmlText(strAllHTML, splitter); } } } // strResultFileName = strTempPath + "index.html"; // bool ret = ::WizSaveUnicodeTextToUtf8File(strResultFileName, strAllHTML); if (!ret) { strError = QObject::tr("Cannot save note html"); return false; } return true; }