#include "fb2html.h" #include "fb2utils.h" #include "fb2text.hpp" //--------------------------------------------------------------------------- // Fb2TextElement //--------------------------------------------------------------------------- void Fb2TextElement::getChildren(Fb2ElementList &list) { Fb2TextElement child = firstChild(); while (!child.isNull()) { QString tag = child.tagName().toLower(); if (tag == "div") { if (child.hasAttribute("class")) list << child; } else if (tag == "img") { list << child; } else { child.getChildren(list); } child = child.nextSibling(); } } QString Fb2TextElement::location() { static const QString javascript = FB2::read(":/js/get_location.js").prepend("var element=this;"); return evaluateJavaScript(javascript).toString(); } void Fb2TextElement::select() { static const QString javascript = FB2::read(":/js/set_cursor.js"); evaluateJavaScript(javascript); } bool Fb2TextElement::isSection() const { return tagName() == "DIV" && attribute("class").toLower() == "section"; } bool Fb2TextElement::isTitle() const { return tagName() == "DIV" && attribute("class").toLower() == "title"; } //--------------------------------------------------------------------------- // Fb2AddBodyCmd //--------------------------------------------------------------------------- void Fb2AddBodyCmd::undo() { m_page.body().lastChild().removeFromDocument(); Fb2TextElement(m_page.body().lastChild()).select(); m_page.update(); } void Fb2AddBodyCmd::redo() { m_page.body().appendInside("
text