本文整理汇总了C++中QDomDocument::isLocked方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomDocument::isLocked方法的具体用法?C++ QDomDocument::isLocked怎么用?C++ QDomDocument::isLocked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomDocument
的用法示例。
在下文中一共展示了QDomDocument::isLocked方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: indexRecognition
// Index any resources
void NoteIndexer::indexRecognition(qint32 reslid, Resource &r) {
QLOG_TRACE_IN();
if (!r.noteGuid.isSet() || !r.guid.isSet())
return;
if (reslid <= 0)
return;
NSqlQuery sql(db);
// Make sure we have something to look through.
Data recognition;
if (r.recognition.isSet())
recognition = r.recognition;
if (!recognition.body.isSet())
return;
QDomDocument doc;
QString emsg;
doc.setContent(recognition.body, &emsg);
// look for text tags
QDomNodeList anchors = doc.documentElement().elementsByTagName("t");
QLOG_TRACE() << "Beginning insertion of recognition:";
QLOG_TRACE() << "Anchors found: " << anchors.length();
sql.exec("begin;");
#if QT_VERSION < 0x050000
for (unsigned int i=0; i<anchors.length(); i++) {
#else
for (int i=0; i<anchors.length(); i++) {
#endif
QLOG_TRACE() << "Anchor: " << i;
QApplication::processEvents();
QDomElement enmedia = anchors.at(i).toElement();
QString weight = enmedia.attribute("w");
QString text = enmedia.text();
if (text != "") {
// Add the new content. it is basically a text version of the note with a weight of 100.
sql.prepare("Insert into SearchIndex (lid, weight, source, content) values (:lid, :weight, :source, :content)");
sql.bindValue(":lid", reslid);
sql.bindValue(":weight", weight);
sql.bindValue(":source", "recognition");
text = global.normalizeTermForSearchAndIndex(text);
sql.bindValue(":content", text);
sql.exec();
}
}
QLOG_TRACE() << "Committing";
sql.exec("commit");
QLOG_TRACE_OUT();
}
// Index any PDFs that are attached. Basically it turns the PDF into text and adds it the same
// way as a note's body
void NoteIndexer::indexPdf(qint32 reslid) {
QLOG_TRACE_IN();
if (!global.indexPDFLocally)
return;
NSqlQuery sql(db);
if (reslid <= 0)
return;
QString file = global.fileManager.getDbaDirPath() + QString::number(reslid) +".pdf";
QString text = "";
Poppler::Document *doc = Poppler::Document::load(file);
if (doc == nullptr || doc->isEncrypted() || doc->isLocked())
return;
for (int i=0; i<doc->numPages(); i++) {
QRectF rect;
text = text + doc->page(i)->text(rect) + QString(" ");
}
QLOG_TRACE() << "Adding PDF";
// Add the new content. it is basically a text version of the note with a weight of 100.
sql.prepare("Insert into SearchIndex (lid, weight, source, content) values (:lid, :weight, :source, :content)");
sql.bindValue(":lid", reslid);
sql.bindValue(":weight", 100);
sql.bindValue(":source", "recognition");
text = global.normalizeTermForSearchAndIndex(text);
sql.bindValue(":content", text);
sql.exec();
QLOG_TRACE_OUT();
}