本文整理汇总了C++中QWebElement::removeAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebElement::removeAttribute方法的具体用法?C++ QWebElement::removeAttribute怎么用?C++ QWebElement::removeAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebElement
的用法示例。
在下文中一共展示了QWebElement::removeAttribute方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processTodo
void EnmlFormatter::processTodo(QWebElement &node) {
bool checked=false;
if (node.hasAttribute("checked"))
checked = true;
node.removeAttribute("style");
node.removeAttribute("type");
removeInvalidAttributes(node);
if (checked)
node.setAttribute("checked", "true");
node.setOuterXml(node.toOuterXml().replace("<input", "<en-todo").replace("</input", "</en-todo"));
}
示例2: SLOT
int PhpWebView::click2(QWebElement elem, bool samewnd)
{
if (elem.isNull())
return 0;
if (samewnd)
elem.removeAttribute("target");
QEventLoop loop;
isNewViewCreated = false;
isNewViewBegin = false;
QString js = "var e = document.createEvent('MouseEvents');";
//js += "e.initEvent( 'click', true, true );";
js += "e.initMouseEvent( 'click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);";
js += "this.dispatchEvent(e);";
elem.evaluateJavaScript(js);
QTimer::singleShot(1000, &loop, SLOT(quit()));
loop.exec();
while (browser && isNewViewBegin && !isNewViewCreated)
loop.processEvents();
return 1;
}
示例3: fixObjectNode
void EnmlFormatter::fixObjectNode(QWebElement &e) {
QString type = e.attribute("type", "");
if (type == "application/pdf") {
qint32 lid = e.attribute("lid", "0").toInt();
e.removeAttribute("width");
e.removeAttribute("height");
e.removeAttribute("lid");
e.removeAttribute("border");
if (lid>0) {
resources.append(lid);
e.setOuterXml(e.toOuterXml().replace("<object", "<en-media").replace("</object", "</en-media"));
}
removeInvalidAttributes(e);
} else {
e.removeFromDocument();
}
}
示例4: removeInvalidAttributes
void EnmlFormatter::removeInvalidAttributes(QWebElement &node) {
// Remove any invalid attributes
QStringList attributes = node.attributeNames();
for (int i=0; i<attributes.size(); i++) {
if (!isAttributeValid(attributes[i])) {
node.removeAttribute(attributes[i]);
}
}
}
示例5: fixLinkNode
void EnmlFormatter::fixLinkNode(QWebElement e) {
QString enTag = e.attribute("en-tag", "");
if (enTag.toLower() == "en-media") {
resources.append(e.attribute("lid").toInt());
e.removeAttribute("style");
e.removeAttribute("href");
e.removeAttribute("title");
removeInvalidAttributes(e);
e.removeAllChildren();
QString newXml = e.toOuterXml();
newXml.replace("<a", "<en-media");
newXml.replace("</a>", "</en-media>");
e.setOuterXml(newXml);
}
QString latex = e.attribute("href", "");
if (latex.toLower().startsWith("latex://")) {
removeInvalidAttributes(e);
e.removeAttribute("title");
e.removeAttribute("href");
e.setOuterXml(e.toInnerXml());
}
removeInvalidAttributes(e);
}
示例6: modifyTodoTags
// Modify the en-to tag into an input field
void NoteFormatter::modifyTodoTags(QWebElement &todo) {
todo.setAttribute("type", "checkbox");
// Checks the en-to tag wheter or not the todo-item is checked or not
// and sets up the HTML to keep storing the information in value
QString checked = todo.attribute("checked");
if (checked.toLower() == "true")
todo.setAttribute("checked", "checked");
else
todo.removeAttribute("checked");
todo.setAttribute("onClick", "if(!checked) removeAttribute('checked'); else setAttribute('checked', 'checked'); editorWindow.editAlert();");
todo.setAttribute("style", "cursor: hand;");
todo.setOuterXml(todo.toOuterXml().replace("en-todo","input"));
}
示例7: fixImgNode
void EnmlFormatter::fixImgNode(QWebElement &e) {
QString enType = e.attribute("en-tag", "");
// Check if we have an en-crypt tag. Change it from an img to en-crypt
if (enType.toLower() == "en-crypt") {
QString encrypted = e.attribute("alt");
QString cipher = e.attribute("cipher", "RC2");
QString hint = e.attribute("hint", "");
QString length = e.attribute("length", "64");
e.removeAttribute("onmouseover");
e.removeAttribute("name");
e.removeAttribute("alt");
e.removeAttribute("en-tag");
e.removeAttribute("contenteditable");
e.removeAttribute("style");
removeInvalidAttributes(e);
e.setInnerXml(encrypted);
e.setOuterXml("<en-crypt cipher=\"" +cipher +"\" length=\"" +
length + "\" hint=\"" +hint
+"\">"+encrypted+"</en-crypt>");
// e.setOuterXml(e.toOuterXml().replace("<img", "<en-crypt").replace("</img", "</en-crypt"));
return;
}
// Check if we have a temporary image. If so, remove it
if (enType.toLower() == "temporary") {;
e.removeFromDocument();
return;
}
// Latex images are really just img tags, so we now handle them later
// Check if we have a LaTeX image. Remove the parent link tag
// if (enType.toLower() == "en-latex") {
// enType = "en-media";
// parent.parentNode().replaceChild(e, parent);
// }
// If we've gotten this far, we have an en-media tag
e.removeAttribute("en-tag");
int lid = e.attribute("lid").toInt();
resources.append(lid);
removeInvalidAttributes(e);
e.setOuterXml(e.toOuterXml().replace("<img", "<en-media").replace("</img", "</en-media"));
}
示例8: fixEnCryptNode
void EnmlFormatter::fixEnCryptNode(QWebElement &e) {
QString crypt = e.attribute("value");
e.removeAttribute("value");
QDomText cryptValue = doc.createTextNode(crypt);
//e.appendChild(cryptValue);
}
示例9: modifyApplicationTags
// Modify the en-media tag into an attachment
void NoteFormatter::modifyApplicationTags(QWebElement &enmedia, QString &hash, QString appl) {
if (appl.toLower() == "vnd.evernote.ink") {
inkNote = true;
readOnly = true;
buildInkNote(enmedia, hash);
return;
}
ResourceTable resTable(global.db);
QString contextFileName;
qint32 resLid = resTable.getLidByHashHex(note.guid, hash);
Resource r;
resTable.get(r, resLid, false);
if (!r.data.isSet())
resourceError = true;
else {
// If we are running the formatter and we are not generating a thumbnail
QString mimetype = "";
if (r.mime.isSet())
mimetype = r.mime;
if (mimetype == "application/pdf" && pdfPreview && !thumbnail) {
modifyPdfTags(resLid, enmedia);
return;
}
// If we are running the formatter so we can generate a thumbnail and it is a PDF
if (mimetype == "application/pdf" && pdfPreview && thumbnail) {
QString printImageFile = global.fileManager.getTmpDirPath() + QString::number(resLid) +QString("-print.jpg");
QString file = global.fileManager.getDbaDirPath() + QString::number(resLid) +".pdf";
Poppler::Document *doc;
doc = Poppler::Document::load(file);
if (doc == NULL)
return;
QImage *image = new QImage(doc->page(0)->renderToImage());
image->save(printImageFile,"jpg");
delete image;
enmedia.setAttribute("src", printImageFile);
enmedia.removeAttribute("hash");
enmedia.removeAttribute("type");
enmedia.setOuterXml(enmedia.toOuterXml().replace("<en-media","<img"));
enmedia.setOuterXml(enmedia.toOuterXml().replace("</en-media>","</img>"));
return;
}
QString fileDetails = "";
MimeReference ref;
ResourceAttributes attributes;
if (r.attributes.isSet())
attributes = r.attributes;
if (attributes.fileName.isSet())
fileDetails = ref.getExtensionFromMime(r.mime, fileDetails);
enmedia.setAttribute("href", QString("nnres:") +global.fileManager.getDbaDirPath()+QString::number(resLid)
+fileDetails);
contextFileName = global.fileManager.getTmpDirPath("")+QString::number(resLid) +global.attachmentNameDelimeter + fileDetails;
// Setup the context menu. This is useful if we want to do a "save as" or such
contextFileName = contextFileName.replace("\\", "/");
enmedia.setAttribute("onContextMenu", "window.browserWindow.resourceContextMenu('" +contextFileName +"');");
enmedia.setAttribute("en-tag", "en-media");
enmedia.setAttribute("lid", QString::number(resLid));
enmedia.appendInside("<img/>");
QWebElement newText = enmedia.lastChild();
// Build an icon of the image
QString fileExt;
if (attributes.fileName.isSet())
fileExt = attributes.fileName;
else
fileExt = appl;
QString fn;
QString mime;
if (attributes.fileName.isSet())
fn = attributes.fileName;
if (r.mime.isSet())
mime = r.mime;
fileExt = ref.getExtensionFromMime(mime, fn);
QString icon = findIcon(resLid, r, fileExt);
newText.setAttribute("src", "file:///"+icon);
if (attributes.fileName.isSet())
newText.setAttribute("title",attributes.fileName);
newText.setAttribute("en-tag", "temporary");
//Rename the tag to a <a> link
enmedia.setOuterXml(enmedia.toOuterXml().replace("<en-media","<a"));
enmedia.setOuterXml(enmedia.toOuterXml().replace("</en-media>","</a>"));
}
}
示例10: click
int PhpWebView::click(const QString & xpath, bool samewnd)
{
QWebElement elem = getElementByXPath(QString(xpath));
if (elem.isNull())
return 0;
elem.setFocus();
if (samewnd)
elem.removeAttribute("target");
QString js = "var node = this; var x = node.offsetLeft; var y = node.offsetTop; ";
js += "var w = node.offsetWidth/2; ";
js += "var h = node.offsetHeight/2; ";
js += "while (node.offsetParent != null) { ";
js += " node = node.offsetParent; ";
js += " x += node.offsetLeft; ";
js += " y += node.offsetTop; ";
js += "} ";
js += "[x+w, y+h]; ";
QList<QVariant> vlist = elem.evaluateJavaScript(js).toList();
QPoint point;
point.setX(vlist.at(0).toInt());
point.setY(vlist.at(1).toInt());
QRect elGeom = elem.geometry();
QPoint elPoint = elGeom.center();
int elX = point.x(); //elPoint.x();
int elY = point.y(); //elPoint.y();
int webWidth = width();
int webHeight = height();
int pixelsToScrollRight=0;
int pixelsToScrollDown=0;
if (elX > webWidth)
pixelsToScrollRight = elX-webWidth+elGeom.width()/2+50; //the +10 part if for the page to scroll a bit further
if (elY > webHeight)
pixelsToScrollDown = elY-webHeight+elGeom.height()/2+50; //the +10 part if for the page to scroll a bit further
/*pixelsToScrollRight = elX-elGeom.width()/2-50;
pixelsToScrollDown = elY-elGeom.height()/2-50;
if (pixelsToScrollRight < 0)
pixelsToScrollRight = 0;
if (pixelsToScrollRight > page()->mainFrame()->scrollBarMaximum(Qt::Horizontal))
pixelsToScrollRight = page()->mainFrame()->scrollBarMaximum(Qt::Horizontal);
if (pixelsToScrollDown < 0)
pixelsToScrollDown = 0;
if (pixelsToScrollDown > page()->mainFrame()->scrollBarMaximum(Qt::Vertical))
pixelsToScrollDown = page()->mainFrame()->scrollBarMaximum(Qt::Vertical);*/
int oldHoriz = page()->mainFrame()->scrollBarValue(Qt::Horizontal);
int oldVert = page()->mainFrame()->scrollBarValue(Qt::Vertical);
page()->mainFrame()->setScrollBarValue(Qt::Horizontal, pixelsToScrollRight);
page()->mainFrame()->setScrollBarValue(Qt::Vertical, pixelsToScrollDown);
QPoint pointToClick(elX-pixelsToScrollRight, elY-pixelsToScrollDown);
QEventLoop loop;
isNewViewCreated = false;
isNewViewBegin = false;
//QMouseEvent *pressEvent = new QMouseEvent(QMouseEvent::MouseButtonPress, pointToClick, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
//QApplication::postEvent(browser, pressEvent);
//QApplication::processEvents();
//QMouseEvent releaseEvent(QMouseEvent::MouseButtonRelease,pointToClick,Qt::LeftButton,Qt::LeftButton,Qt::NoModifier);
//QApplication::sendEvent(browser, &releaseEvent);
QString js2 = "var e = document.createEvent('MouseEvents');";
//js2 += "e.initEvent( 'click', true, true );";
//js2 += "e.initMouseEvent('click', true, true, window, 0, 0, 0, "+QString::number(elX)+", "+QString::number(elY)+", false, false, false, false, 0, null);";
js2 += "e.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);";
js2 += "this.dispatchEvent(e);";
elem.evaluateJavaScript(js2);
QTimer::singleShot(1000, &loop, SLOT(quit()));
loop.exec();
while (browser && isNewViewBegin && !isNewViewCreated)
loop.processEvents();
//page()->mainFrame()->setScrollBarValue(Qt::Horizontal, oldHoriz);
//page()->mainFrame()->setScrollBarValue(Qt::Vertical, oldVert);
return 1;
}
示例11: setNumBlocks
void ShadowGUI::setNumBlocks(int count, int nTotalBlocks)
{
QWebElement blocksIcon = documentFrame->findFirstElement("#blocksIcon");
QWebElement syncingIcon = documentFrame->findFirstElement("#syncingIcon");
QWebElement syncProgressBar = documentFrame->findFirstElement("#syncProgressBar");
// don't show / hide progress bar and its label if we have no connection to the network
if (!clientModel || clientModel->getNumConnections() == 0)
{
syncProgressBar.setAttribute("style", "display:none;");
return;
}
// -- translation (tr()) makes it difficult to neatly pick block/header
static QString sBlockType = nNodeMode == NT_FULL ? tr("block") : tr("header");
static QString sBlockTypeMulti = nNodeMode == NT_FULL ? tr("blocks") : tr("headers");
QString strStatusBarWarnings = clientModel->getStatusBarWarnings();
QString tooltip;
if (nNodeMode != NT_FULL
&& nNodeState == NS_GET_FILTERED_BLOCKS)
{
tooltip = tr("Synchronizing with network...");
+ "\n"
+ tr("Downloading filtered blocks...");
int nRemainingBlocks = nTotalBlocks - pwalletMain->nLastFilteredHeight;
float nPercentageDone = pwalletMain->nLastFilteredHeight / (nTotalBlocks * 0.01f);
tooltip += "\n"
+ tr("~%1 filtered block(s) remaining (%2% done).").arg(nRemainingBlocks).arg(nPercentageDone);
count = pwalletMain->nLastFilteredHeight;
syncProgressBar.removeAttribute("style");
} else
if (count < nTotalBlocks)
{
int nRemainingBlocks = nTotalBlocks - count;
float nPercentageDone = count / (nTotalBlocks * 0.01f);
syncProgressBar.removeAttribute("style");
if (strStatusBarWarnings.isEmpty())
{
bridge->networkAlert("");
tooltip = tr("Synchronizing with network...");
if (nNodeMode == NT_FULL)
{
tooltip += "\n"
+ tr("~%n block(s) remaining", "", nRemainingBlocks);
} else
{
char temp[128];
snprintf(temp, sizeof(temp), "~%%n %s remaining", nRemainingBlocks == 1 ? qPrintable(sBlockType) : qPrintable(sBlockTypeMulti));
tooltip += "\n"
+ tr(temp, "", nRemainingBlocks);
};
}
tooltip += (tooltip.isEmpty()? "" : "\n")
+ tr("Downloaded %1 of %2 %3 of transaction history (%4% done).").arg(count).arg(nTotalBlocks).arg(sBlockTypeMulti).arg(nPercentageDone, 0, 'f', 2);
}
else
{
tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count);
}
// Override progressBarLabel text when we have warnings to display
if (!strStatusBarWarnings.isEmpty())
bridge->networkAlert(strStatusBarWarnings);
QDateTime lastBlockDate;
if (nNodeMode == NT_FULL)
lastBlockDate = clientModel->getLastBlockDate();
else
lastBlockDate = clientModel->getLastBlockThinDate();
int secs = lastBlockDate.secsTo(QDateTime::currentDateTime());
QString text;
// Represent time from last generated block in human readable text
if (secs <= 0)
{
// Fully up to date. Leave text empty.
} else
if (secs < 60)
{
text = tr("%n second(s) ago","",secs);
} else
if (secs < 60*60)
{
text = tr("%n minute(s) ago","",secs/60);
} else
if (secs < 24*60*60)
{
text = tr("%n hour(s) ago","",secs/(60*60));
//.........这里部分代码省略.........