本文整理汇总了C++中QWebElementCollection::toList方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebElementCollection::toList方法的具体用法?C++ QWebElementCollection::toList怎么用?C++ QWebElementCollection::toList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebElementCollection
的用法示例。
在下文中一共展示了QWebElementCollection::toList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseMarkdown
void tdRenderer::parseMarkdown(int at, int removed, int added)
{
QTextCursor cursor = m_editor->textCursor();
cursor.beginEditBlock();
int steps = m_editor->document()->availableUndoSteps();
bool undoStepsChanged = (steps != m_undoSteps);
m_undoSteps = steps;
if (undoStepsChanged && !m_isUndoRedo)
m_undoStack->push(new tdRendererCursorCommand(this, at, removed, added));
m_isUndoRedo = false;
int start;
int end;
if (m_sizes.isEmpty()) {
start = end = 0;
} else {
int i = 0, n = 0;
while (i < m_fframe)
n += m_sizes.at(i++);
start = n;
while (i <= m_lframe)
n += m_sizes.at(i++);
end = n;
}
int diff = added - removed;
m_count += diff;
if (m_sizes.isEmpty()) end = m_count;
else end += diff;
cursor.setPosition(start);
cursor.setPosition(qMin(end, m_count), QTextCursor::KeepAnchor);
int c = m_fframe;
int klass = 0;
QWebElementCollection collection;
while (c++ <= m_lframe && !m_sizes.isEmpty()) {
m_sizes.takeAt(m_fframe);
klass = m_indices.takeAt(m_fframe);
collection.append(m_body.findAll(".__" % QString::number(klass) % "__"));
}
QList<QWebElement> list = collection.toList();
QWebElement element;
if (klass) {
QString k = "__" % QString::number(klass) % "__";
element = list.last();
while (element.parent().hasClass(k))
element = element.parent();
list.removeAll(element);
element.setOuterXml("<div class=\"__tmp__\"></div>");
QList<QWebElement>::iterator i = list.begin();
for (; i != list.end(); ++i)
i->takeFromDocument();
} else {
m_body.prependInside("<div class=\"__tmp__\"></div>");
}
render(cursor.selection().toPlainText().toAscii());
cursor.endEditBlock();
updateFrameInterval();
emit parsingDone();
}
示例2: modifyTags
/*
This will go through and modify some of the ENML tags and turn
them into HTML tags. Things like en-media & en-crypt have no
HTML values, so we turn them into HTML.
*/
void NoteFormatter::modifyTags(QWebPage &doc) {
tempFiles.clear();
// Modify en-media tags
QLOG_TRACE() << "Searching for all en-media tags;";
QWebElementCollection anchors = doc.mainFrame()->findAllElements("en-media");
QLOG_TRACE() << "Search complete: " << anchors.toList().size();
foreach (QWebElement enmedia, anchors) {
if (enmedia.hasAttribute("type")) {
QString attr = enmedia.attribute("type");
QString hash = enmedia.attribute("hash");
QStringList type = attr.split("/");
if (type.size() >= 2) {
QString appl = type[1];
QLOG_TRACE() << "En-Media tag type: " << type[0];
if (type[0] == "image")
modifyImageTags(enmedia, hash);
else
modifyApplicationTags(enmedia, hash, appl);
QLOG_TRACE() << "Type modified";
}
}
}
// Modify todo tags
anchors = doc.mainFrame()->findAllElements("en-todo");
qint32 enTodoCount = anchors.count();
for (qint32 i=enTodoCount-1; i>=0; i--) {
QWebElement enmedia = anchors.at(i);
modifyTodoTags(enmedia);
}
anchors = doc.mainFrame()->findAllElements("en-crypt");
qint32 enCryptLen = anchors.count();
for (qint32 i=enCryptLen-1; i>=0; i--) {
QWebElement enmedia = anchors.at(i);
QString hint = enmedia.attribute("hint");
QString cipher = enmedia.attribute("cipher", "RC2");
QString length = enmedia.attribute("length","64");
enmedia.setAttribute("contentEditable","false");
enmedia.setAttribute("src", QString("file://")+global.fileManager.getImageDirPath("encrypt.png"));
enmedia.setAttribute("en-tag","en-crypt");
enmedia.setAttribute("cipher", cipher);
enmedia.setAttribute("length", length);
enmedia.setAttribute("hint", hint);
enmedia.setAttribute("alt", enmedia.toInnerXml());
global.cryptCounter++;
enmedia.setAttribute("id", "crypt"+QString().number(global.cryptCounter));
QString encryptedText = enmedia.toInnerXml();
// If the encryption string contains crlf at the end, remove them because they mess up the javascript.
if (encryptedText.endsWith("\n"))
encryptedText.truncate(encryptedText.length()-1);
if (encryptedText.endsWith("\r"))
encryptedText.truncate(encryptedText.length()-1);
// Add the commands
hint = hint.replace("'","'");
enmedia.setAttribute("onClick", "window.browserWindow.decryptText('crypt"+
QString().number(global.cryptCounter)+
"', '"+encryptedText+"', '"+
hint +"', '" +
cipher+ "', " +
length +
");");
enmedia.setAttribute("onMouseOver", "style.cursor='hand'");
enmedia.setInnerXml("");
QString k = enmedia.toOuterXml();
k.replace("<en-crypt", "<img");
k.replace("img>", "<en-crypt");
enmedia.setOuterXml(k);
}
// Modify link tags
anchors = doc.mainFrame()->findAllElements("a");
enCryptLen = anchors.count();
for (qint32 i=0; i<anchors.count(); i++) {
QWebElement element = anchors.at(i);
if (!element.attribute("href").toLower().startsWith("latex://"))
element.setAttribute("title", element.attribute("href"));
else {
element.setAttribute("title", element.attribute("title").toLower().replace("http://latex.codecogs.com/gif.latex?",""));
}
}
}