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); }
void updateInformation(CWizDatabase& db, const WIZDOCUMENTDATA& doc) { // retrieve document info and reset WIZDOCUMENTDATA data; if (!db.DocumentFromGUID(doc.strGUID, data)) { return; } //title if (m_titleEdit->text() != data.strTitle) { m_titleEdit->setText(data.strTitle); } //tags CWizStdStringArray arrayTagGUID; db.GetDocumentTags(data.strGUID, arrayTagGUID); QString strTagText = arrayTagGUID.empty() ? QString() : QString::number(arrayTagGUID.size()); m_tagsButton->setText(strTagText); QString tagsShortcut = ::WizGetShortcut("EditNoteTags", "Alt+2"); QString strTagsToolTip = QObject::tr("Tags (%1)").arg(tagsShortcut); m_tagsButton->setToolTip(strTagsToolTip); m_tagsButton->setShortcut(QKeySequence::fromString(tagsShortcut)); //attachments int nAttachmentCount = db.GetDocumentAttachmentCount(data.strGUID); CString strAttachmentText = nAttachmentCount ? WizIntToStr(nAttachmentCount) : CString(); m_attachmentButton->setText(strAttachmentText); QString attachmentShortcut = ::WizGetShortcut("EditNoteAttachments", "Alt+3"); m_attachmentButton->setToolTip(QObject::tr("Attachments (%1)").arg(attachmentShortcut)); m_attachmentButton->setShortcut(QKeySequence::fromString(attachmentShortcut)); }
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); } }
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); }