void QwcNewsWidget::on_fBtnRefresh_clicked() { QWebElement newsItemsElement = newsView->page()->mainFrame()->findFirstElement("#news_items"); newsItemsElement.setPlainText(QString()); m_newsCounter = 0; m_socket->getNews(); pageWidget->setCurrentIndex(1); }
/*! Clear the contents of the news view and set an empty HTML page with styles. */ void QwcNewsWidget::updateNewsCss() { QSettings settings; QFont newsFont; newsFont.fromString(settings.value("interface/news/font", QFont().toString()).toString()); composeMessage->setFont(newsFont); QWebElement styleElement = newsView->page()->mainFrame()->findFirstElement("#css_block"); styleElement.setPlainText(QString("body { %1 }").arg(QwcMessageStyle::cssFromFont(newsFont))); }
/** * @fn sendReportUsingGitreport */ void GitreportModule::sendReportUsingGitreport(const QMap<QString, QString> info) { if (debug) qDebug() << "[GitreportModule]" << "[sendReportUsingGitreport]"; QWebElement document = webView->page()->mainFrame()->documentElement(); QWebElement captchaKey = document.findFirst(QString("input#captcha")); QWebElement emailInput = document.findFirst(QString("input#email")); QWebElement textArea = document.findFirst(QString("textarea#details")); QWebElement usernameInput = document.findFirst(QString("input#name")); // input usernameInput.setAttribute(QString("value"), info[QString("username")]); emailInput.setAttribute(QString("value"), info[QString("password")]); textArea.setPlainText(info[QString("body")]); captchaKey.setAttribute(QString("value"), info[QString("captcha")]); // send request document.findFirst(QString("input[name=commit]")).evaluateJavaScript("this.click()"); disconnect(webView, SIGNAL(loadFinished(bool)), this, SLOT(gitreportLoaded(bool))); disconnect(webView, SIGNAL(loadFinished(bool)), this, SLOT(gitreportFinished(bool))); connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(gitreportFinished(bool))); }
void lmcMessageLog::updateFileMessage(FileMode mode, FileOp op, QString fileId) { QString szMessage = getFileStatusMessage(mode, op); QWebFrame* frame = page()->mainFrame(); QWebElement document = frame->documentElement(); QWebElement body = document.findFirst("body"); QString selector = "span#"; QString tempId = (mode == FM_Send) ? "send" : "receive"; tempId.append(fileId); selector.append(tempId); QWebElement span = body.findFirst(selector); span.setPlainText(szMessage); // update the entry in message log for(int index = 0; index < messageLog.count(); index++) { SingleMessage msg = messageLog.at(index); if(tempId.compare(msg.id) == 0) { XmlMessage xmlMessage = msg.message; xmlMessage.removeData(XN_FILEOP); xmlMessage.addData(XN_FILEOP, FileOpNames[op]); msg.message = xmlMessage; break; } } }
/* Modify an image tag. Basically we turn it back into a picture, write out the file, and modify the ENML */ void NoteFormatter::modifyImageTags(QWebElement &enMedia, QString &hash) { QString mimetype = enMedia.attribute("type"); qint32 resLid = 0; resLid = hashMap[hash]; QString highlightString = ""; if (resLid>0) { QLOG_TRACE() << "Getting resource"; Resource r = resourceMap[resLid]; QLOG_TRACE() << "resource retrieved"; MimeReference ref; QString filename; ResourceAttributes attributes; if (r.attributes.isSet()) attributes = r.attributes; if (attributes.fileName.isSet()) filename = attributes.fileName; QString type = ref.getExtensionFromMime(mimetype, filename); Data data; if (r.data.isSet()) data = r.data; if (data.size.isSet() && data.size > 0) { QString imgfile = "file:///"+global.fileManager.getDbDirPath(QString("dba/") +QString::number(resLid) +type); enMedia.setAttribute("src", imgfile); // Check if this is a LaTeX image ResourceAttributes attributes; if (r.attributes.isSet()) attributes = r.attributes; QString sourceUrl = ""; if (attributes.sourceURL.isSet()) sourceUrl = attributes.sourceURL; if (sourceUrl.toLower().startsWith("http://latex.codecogs.com/gif.latex?")) { enMedia.appendInside("<img/>"); QWebElement newText = enMedia.lastChild(); enMedia.setAttribute("en-tag", "en-latex"); newText.setAttribute("onMouseOver", "style.cursor='pointer'"); newText.setAttribute("title", sourceUrl); newText.setAttribute("href", "latex://"+QString::number(resLid)); } enMedia.setAttribute("onContextMenu", "window.browserWindow.imageContextMenu('" +QString::number(resLid) +"', '" +QString::number(resLid) +type +"');"); highlightString = addImageHighlight(resLid, imgfile); if (highlightString != "") enMedia.setAttribute("onload", highlightString); } } else { resourceError = true; readOnly = true; } // Reset the tags to something that WebKit will understand enMedia.setAttribute("en-tag", "en-media"); enMedia.setPlainText(""); enMedia.setAttribute("lid", QString::number(resLid)); // rename the <enmedia> tag to <img> enMedia.setOuterXml(enMedia.toOuterXml().replace("<en-media","<img")); enMedia.setOuterXml(enMedia.toOuterXml().replace("</en-media>","</img>")); }