String ForLoop::defineHtml() const { return L"<^><span class=\"keyword\">for</span> <span class=\"minor symbol\">(</span>" + toHtml(child(Initialiser)) + L"<span class=\"minor symbol\">;</span> " + toHtml(child(Condition)) + L"<span class=\"minor symbol\">;</span> " + toHtml(child(Ticker)) + L"<span class=\"minor symbol\">)</span>" + Corporal::defineHtml(true); }
SimpleAboutDialog::SimpleAboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::SimpleAboutDialog) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); ui->texteditDevelopers->setHtml(toHtml(PersonInfo::authors(), true)); QList<PersonInfo> translators = PersonInfo::translators(); if (translators.isEmpty()) ui->tabWidget->removeTab(1); else ui->texteditTranslators->setHtml(toHtml(translators, false)); ui->labelVersion->setText(QLatin1String(versionString())); ui->labelQtVer ->setText(tr("Based on Qt %1 (%2 bit).") .arg(QLatin1String(qVersion()), QString::number(QSysInfo::WordSize))); QFile licenseFile(":/GPL"); QString license = tr("<div><b>qutIM</b> %1 is licensed under GNU General Public License, version 2" " or (at your option) any later version.</div>" "<div>qutIM resources such as themes, icons, sounds may come along with a " "different license.</div><br><hr><br>"); // FIXME: Don't want to break translation before release license = license.replace("2", "3").arg(versionString()); if (licenseFile.open(QIODevice::ReadOnly | QIODevice::Text)) { license += Qt::escape(QLatin1String(licenseFile.readAll())); } else { license += QLatin1String("<a href=\"http://www.gnu.org/licenses/gpl-3.0.html\">GPLv3</a>"); } license.replace(QLatin1String("\n\n"), "<br><br>"); ui->texteditLicense->setHtml(license); }
/*! Handle keyboard events. */ void InputTextWidget::keyPressEvent(QKeyEvent* event) { // Send message on Return if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && (event->modifiers() == Qt::NoModifier || event->modifiers() == Qt::KeypadModifier)) { // Prevents empty messages if (toPlainText().trimmed().isEmpty()) { return; } if (toPlainText().startsWith("/me ") ) { QString html = toHtml(); html.remove(html.indexOf("/me "), 4); emit sendAction(Smileypack::desmilify(html)); } else { emit sendMessage(Smileypack::desmilify(toHtml())); } // not only clears the text, but also removes undo/redo history clear(); // Override default shortcuts } else if (event == QKeySequence::Copy) { copyPlainText(); } else if (event == QKeySequence::Cut) { cutPlainText(); } else if (event == QKeySequence::Paste) { pastePlainText(); // Normal text writing } else { QTextEdit::keyPressEvent(event); } }
/*! Handle keyboard events. */ void InputTextWidget::keyPressEvent(QKeyEvent* event) { // Send message on Return if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && (event->modifiers() == Qt::NoModifier || event->modifiers() == Qt::KeypadModifier)) { if (toPlainText().startsWith("/me ") ) { QString html = toHtml(); html.remove(html.indexOf("/me "), 4); emit sendAction(EmoticonMenu::desmile(html)); } else { emit sendMessage(EmoticonMenu::desmile(toHtml())); } clear(); // Override default shortcuts } else if (event == QKeySequence::Copy) { copyPlainText(); } else if (event == QKeySequence::Cut) { cutPlainText(); } else if (event == QKeySequence::Paste) { pastePlainText(); // Normal text writing } else { QTextEdit::keyPressEvent(event); } }
String SimpleBinaryOperation::defineHtml() const { if (id().symbol() == Operator::Slash && WebStylist::current()->property("SimpleBinaryOperation", "ProperMaths").toBool()) { String ret = displayParenthesise(L"<^><div style=\"display: inline-block; vertical-align: middle; text-align:center\">%1<hr style=\"margin:0; margin-top:1px; padding:0; border:0; border-bottom: 2px solid #666;\"/>%2</div>"); return ret .arg(toHtml(child(FirstOperand), childIs<Operation>(FirstOperand) ? L"class=\"Operation\"" : L"")) .arg(toHtml(child(SecondOperand), childIs<Operation>(SecondOperand) ? L"class=\"Operation\"" : L"")); } else return Super::defineHtml(); }
QString HtmlGenerator::toHtml(PreventiveAction &action) { if(!actionTemplate) return QString(); actionTemplate->setField("CASE", action.getTestCase()); actionTemplate->setField("NAME", action.getTestName()); actionTemplate->setField("DESCRIPTION", action.getShortDescription()); actionTemplate->setField("PREPARATION", toHtml(action.getPreparation())); actionTemplate->setField("ACTION", toHtml(action.getAction())); actionTemplate->setField("RESULT", toHtml(action.getExpectedResult())); return actionTemplate->getHtml(); }
void ElementTitle::focusOutEvent(QFocusEvent *event) { QGraphicsTextItem::focusOutEvent(event); QString htmlNormalizedText = toHtml().remove("\n", Qt::CaseInsensitive); setTextInteractionFlags(Qt::NoTextInteraction); parentItem()->setSelected(true); // Clear selection QTextCursor cursor = textCursor(); cursor.clearSelection(); setTextCursor(cursor); unsetCursor(); if (mReadOnly) return; if (mOldText != toPlainText()) { QString value = toPlainText(); if (mBinding == "name") static_cast<NodeElement*>(parentItem())->setName(value); else static_cast<NodeElement*>(parentItem())->setLogicalProperty(mBinding, value); } setHtml(htmlNormalizedText); }
void MyTextBrowser::htmlOrSvgDump(const char *filename) { #ifdef NO_WEBKIT FILE *fout = fopen(filename,"w"); if(fout == NULL) { printf("could not write %s\n", filename); return; } QString xml = toHtml(); fputs(xml.toUtf8(), fout); fclose(fout); #else QWebPage *p = page(); if(p == NULL) return; QWebFrame *f = p->currentFrame(); if(f == NULL) return; FILE *fout = fopen(filename,"w"); if(fout == NULL) { printf("could not write %s\n", filename); return; } QString xml = f->toHtml(); fputs(xml.toUtf8(), fout); fclose(fout); #endif }
void ChronTextEdit::extractHtml (QString & html, bool clearit) { firstKey = true; html = toHtml(); if (clearit) { clear(); } }
void InfoScreen::writeLogFile() { QString path=qApp->applicationDirPath(); path.append("/logs/"); // make the directory, if it does not exist QFileInfo dirInfo(path); if(dirInfo.exists()==false) { QDir dir(path); dir.mkpath(path); } QString filename=MainWindow::app()->getStartUpTime().toString("yyyy_MM_dd_hh:mm:ss")+"_log.html"; QFile file(path+filename); if(file.open(QFile::WriteOnly | QFile::Text)) { QTextStream out(&file); out << toHtml(); file.close(); } else { qDebug() << "ERROR writing log file"; } }
///En cas d'édition du texte, on met à jour l'historique void RzxTextEdit::onTextEdited() { //Supprime un <span></span> en trop qui apparaît lors de la première édition de l'objet.... //J'aimerais bien savoir d'où il sort, mais bon... ce hack crade résoud le problème //C'est transparent pour l'utilisateur et léger (exécuté une seule fois) if(!init) { static const QRegExp maskSpan("^(.*)<span style=\"([^\"]*)\">((?:[^<]|<(?!/span>))*)</span>(.*)$"); static const QRegExp maskP("^(.*)<p style=\"([^\"]*)\">((?:[^<]|<(?!/p>))*)</p>(.*)$"); QString text = toHtml(); if(maskSpan.indexIn(text) != -1) { QTextCursor cursor = textCursor(); //sauvegarde de la position du curseur setHtml(maskSpan.cap(1) + maskSpan.cap(3) + maskSpan.cap(4)); setTextCursor(cursor); //restauration de la position du curseur init = true; } else if(maskP.indexIn(text) != -1) { QTextCursor cursor = textCursor(); //sauvegarde de la position du curseur const Format formatP = formatFromStyle(maskP.cap(2)); const Format formatBody = formatFromMarket(text, "body"); Format formatText = (formatP - formatBody) % (currentFormat - formatBody); if(currentFormat.family != defaultFormat.family) formatText.family = currentFormat.family; if(currentFormat.color == defaultFormat.color) formatText.color = QColor(); setHtml(maskP.cap(1) + "<p>" + formatStyle(maskP.cap(3), formatText, "span") + "</p>" + maskP.cap(4)); setTextCursor(cursor); //restauration de la position du curseur init = true; } } //On informe que le texte est édité emit textWritten(); //Ajout du nouveau texte à l'historique if(!history) { history = new ListText(toHtml(), NULL); curLine = history; return; } history->texte = toHtml(); curLine = history; }
QString KNoteEdit::text() const { if ( acceptRichText() ) { return toHtml(); } else { return toPlainText(); } }
void QDictWidget::textChanged(const QString &text) { QString xml = "<entries>"; xml += searchExpr(text, 32); xml += "</entries>"; QString html = toHtml(xml); browser->setText(html); }
QString HtmlGenerator::toHtml(const RiskAssessment &risk) { if(!riskAssessmentTemplate) return QString(); riskAssessmentTemplate->setField("SCENARIO", toHtml(risk.scenario())); riskAssessmentTemplate->setField("MITIGATION_STRATEGY", toHtml(risk.mitigationStrategy())); riskAssessmentTemplate->setField("INITIAL_PROBABILITY", risk.initialRiskModel()->probability()); riskAssessmentTemplate->setField("INITIAL_DAMAGE", risk.initialRiskModel()->damageExtent()); riskAssessmentTemplate->setField("INITIAL_RISK", risk.initialRisk(Qt::DisplayRole).toString()); riskAssessmentTemplate->setField("FINAL_PROBABILITY", risk.finalRiskModel()->probability()); riskAssessmentTemplate->setField("FINAL_DAMAGE", risk.finalRiskModel()->damageExtent()); riskAssessmentTemplate->setField("FINAL_RISK", risk.finalRisk(Qt::DisplayRole).toString()); return riskAssessmentTemplate->getHtml(); }
QString EditorRichText::text(Qt::TextFormat format) const { switch (format) { case Qt::LogText: case Qt::PlainText: return toPlainText(); case Qt::RichText: return m_simplifyRichText ? simplifyRichTextFilter(toHtml()) : toHtml(); case Qt::AutoText: break; } const QString html = toHtml(); bool isPlainText; const QString simplifiedHtml = simplifyRichTextFilter(html, &isPlainText); if (isPlainText) return toPlainText(); return m_simplifyRichText ? simplifiedHtml : html; }
String EnumValue::defineHtml() const { String r = toHtml(child(Identity)); if (child(Definition)) { r += L" <span class=\"symbol\">" + String(WebStylist::current()->property("CSS", "Simple").toBool() ? L"=" : L":=") + L"</span> " + toHtml(child(Definition)); } return r; }
/** La validation consiste à l'envoie du contenu de la fenêtre * donc on incrémente l'historique et on vide la fenêtre. */ void RzxTextEdit::validate(bool val) { if(val) { history = new ListText(toHtml(), history); curLine = history; } useHtml(m_html); clear(); }
/** Gere la prise de focus du champ de texte @param e Objet decrivant la prise de focus */ void DiagramTextItem::focusInEvent(QFocusEvent *e) { QGraphicsTextItem::focusInEvent(e); // empeche le deplacement du texte pendant son edition setFlag(QGraphicsItem::ItemIsMovable, false); // memorise le texte avant que l'utilisateur n'y touche previous_text_ = toHtml(); // cela permettra de determiner si l'utilisateur a modifie le texte a la fin de l'edition }
/** * @brief Edit the text with HtmlEditor */ void DiagramTextItem::edit() { //Open the HtmlEditor qdesigner_internal::RichTextEditorDialog *editor = new qdesigner_internal::RichTextEditorDialog(); // connect the in/out connect(editor, SIGNAL(applyEditText(const QString &)), this, SLOT(setHtmlText(const QString &))); // load the Html txt editor->setText( toHtml() ); // show editor->show(); }
/** Gere la perte de focus du champ de texte @param e Objet decrivant la perte de focus */ void DiagramTextItem::focusOutEvent(QFocusEvent *e) { QGraphicsTextItem::focusOutEvent(e); // signale la modification du texte si besoin if (toPlainText() != previous_text_) { emit(diagramTextChanged(this, previous_text_, toHtml())); previous_text_ = toHtml(); } // deselectionne le texte QTextCursor cursor = textCursor(); cursor.clearSelection(); setTextCursor(cursor); // hack a la con pour etre re-entrant setTextInteractionFlags(Qt::NoTextInteraction); // autorise de nouveau le deplacement du texte setFlag(QGraphicsItem::ItemIsMovable, true); QTimer::singleShot(0, this, SIGNAL(lostFocus())); }
void ImageTextBrowser::addString(QString s) { if (preprocessor_) s = preprocessor_->preprocess(s); downloadResources(s); QString html = toHtml(); if (s.indexOf("<img") == 0) s = "<br>" + s; html += s + "\n"; setHtml(html); QScrollBar * vBar = this->verticalScrollBar(); vBar->setValue(vBar->maximum()); }
QDomElement TupTextItem::toXml(QDomDocument &doc) const { QDomElement root = doc.createElement("text"); QDomText text = doc.createTextNode(toHtml()); root.appendChild(text); root.appendChild(TupSerializer::properties(this, doc)); QFont font = this->font(); root.appendChild(TupSerializer::font(&font, doc)); return root; }
void TextBrowser::setFullWidthImage(bool s) { if (s!=fullWidthImg) { fullWidthImg=s; verticalScrollBar()->removeEventFilter(this); if (fullWidthImg) { verticalScrollBar()->installEventFilter(this); } if (haveImg) { setHtml(toHtml()); } } }
int QTextControl::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 38) qt_static_metacall(this, _c, _id, _a); _id -= 38; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = toHtml(); break; case 1: *reinterpret_cast< bool*>(_v) = overwriteMode(); break; case 2: *reinterpret_cast< bool*>(_v) = acceptRichText(); break; case 3: *reinterpret_cast< int*>(_v) = cursorWidth(); break; case 4: *reinterpret_cast< Qt::TextInteractionFlags*>(_v) = textInteractionFlags(); break; case 5: *reinterpret_cast< bool*>(_v) = openExternalLinks(); break; case 6: *reinterpret_cast< bool*>(_v) = ignoreUnusedNavigationEvents(); break; } _id -= 7; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setHtml(*reinterpret_cast< QString*>(_v)); break; case 1: setOverwriteMode(*reinterpret_cast< bool*>(_v)); break; case 2: setAcceptRichText(*reinterpret_cast< bool*>(_v)); break; case 3: setCursorWidth(*reinterpret_cast< int*>(_v)); break; case 4: setTextInteractionFlags(*reinterpret_cast< Qt::TextInteractionFlags*>(_v)); break; case 5: setOpenExternalLinks(*reinterpret_cast< bool*>(_v)); break; case 6: setIgnoreUnusedNavigationEvents(*reinterpret_cast< bool*>(_v)); break; } _id -= 7; } else if (_c == QMetaObject::ResetProperty) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 7; } #endif // QT_NO_PROPERTIES return _id; }
void RSTextBrowser::showImages() { if (mImageBlockWidget && sender() == mImageBlockWidget) { mImageBlockWidget->hide(); } if (mShowImages) { return; } mShowImages = true; QString html = toHtml(); clear(); setHtml(html); }
void ImageTextBrowser::requestFinished(QNetworkReply * result) { if (!result->error()) { QByteArray res = result->readAll(); QPixmap pixmap; pixmap.loadFromData(res); QImage img = pixmap.toImage(); QTextDocument *doc = this->document(); doc->addResource(QTextDocument::ImageResource,result->url(),QVariant(img)); setHtml(toHtml()); QScrollBar * vBar = this->verticalScrollBar(); vBar->setValue(vBar->maximum()); } }
/** Le HTML de Qt4 est relavitement complexe (formatage via style CSS) * il faut donc le simplifier pour obtenir qqch de compatible avec * les versions antérieures de qRezix */ QString RzxTextEdit::toSimpleHtml() const { static const QRegExp mask("<body[^>]*>(.*)</body>"); static const QRegExp spanRE("<span style=\"([^\"]*)\">((?:[^<]|<(?!/span>))*)</span>"); static const QRegExp pRE("<p style=\"([^\"]*)\">((?:[^<]|<(?!/p>))*)</p>"); QString text = toHtml(); //On supprime tous les en-têtes if(mask.indexIn(text) != -1) text = mask.cap(1); //On vire les <span style=" font-family:Terminal [DEC]; font-size:22pt; color:#000000;" text = convertStyle(text, spanRE); text = convertStyle(text, pRE, "<br>"); if(text.right(4) == "<br>") text = text.left(text.length() - 4); return text; }
void UBGraphicsTextItem::copyItemParameters(UBItem *copy) const { UBGraphicsTextItem *cp = dynamic_cast<UBGraphicsTextItem*>(copy); if (cp) { cp->setHtml(toHtml()); cp->setPos(this->pos()); cp->setTransform(this->transform()); cp->setFlag(QGraphicsItem::ItemIsMovable, true); cp->setFlag(QGraphicsItem::ItemIsSelectable, true); cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType)); cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked)); cp->setData(UBGraphicsItemData::ItemEditable, data(UBGraphicsItemData::ItemEditable).toBool()); cp->setTextWidth(this->textWidth()); cp->setTextHeight(this->textHeight()); cp->setSourceUrl(this->sourceUrl()); } }
QString QTextDocumentExtra::toXml() const { QHash<QString,QString> t; t.insert(QDOCUMENT_VERSION_XML_TAG, d->xmlVersion); t.insert(QDOCUMENT_PRESENCE_XML_TAG,QString::number(presence())); t.insert(QDOCUMENT_PRIORITY_XML_TAG, QString::number(priority())); t.insert(QDOCUMENT_EXTRA_XML_TAG, ""); t.insert(QDOCUMENT_HTML_XML_TAG, toHtml()); QDomDocument doc; QDomElement main = doc.createElement(QDOCUMENT_GENERAL_XML_TAG); doc.appendChild(main); foreach( const QString &k, t.keys() ) { QDomElement data = doc.createElement(k); QDomText dataText = doc.createTextNode(t.value(k)); main.appendChild(data); data.appendChild(dataText); } return doc.toString(4); }
QSize K3ActiveLabel::minimumSizeHint() const { QSize ms = minimumSize(); if ((ms.width() > 0) && (ms.height() > 0)) return ms; int w = 400; if (ms.width() > 0) w = ms.width(); QString txt = toHtml(); Q3SimpleRichText rt(txt, font()); rt.setWidth(w - 2*frameWidth() - 10); w = 10 + rt.widthUsed() + 2*frameWidth(); if (w < ms.width()) w = ms.width(); int h = rt.height() + 2*frameWidth(); if ( h < ms.height()) h = ms.height(); return QSize(w, h); }