Browse Source

Show document history

Kandrashin Denis 13 years ago
parent
commit
54bb5d92ed
4 changed files with 44 additions and 6 deletions
  1. 4 2
      source/fb2read.cpp
  2. 12 3
      source/fb2tree.cpp
  3. 1 1
      source/fb2tree.hpp
  4. 27 0
      source/res/style.css

+ 4 - 2
source/fb2read.cpp

@@ -216,9 +216,9 @@ Fb2XmlHandler::NodeHandler * Fb2ReadHandler::DescrHandler::NewTag(const QString
     Q_UNUSED(atts);
     switch (toKeyword(name)) {
         case Title :
-            return new TitleHandler(m_owner, name, atts);
         case Document :
         case Publish :
+            return new TitleHandler(m_owner, name, atts);
         case Custom :
             return new HeadHandler(m_owner, name, atts);
         default:
@@ -232,7 +232,9 @@ Fb2XmlHandler::NodeHandler * Fb2ReadHandler::DescrHandler::NewTag(const QString
 
 Fb2XmlHandler::NodeHandler * Fb2ReadHandler::TitleHandler::NewTag(const QString &name, const QXmlAttributes &atts)
 {
-    if (name == "annotation") return new TextHandler(m_owner, name, atts, "div", name);
+    if (name == "annotation" || name == "history") {
+        return new TextHandler(m_owner, name, atts, "div", name);
+    }
     return new HeadHandler(m_owner, name, atts);
 }
 

+ 12 - 3
source/fb2tree.cpp

@@ -55,18 +55,27 @@ QString Fb2TreeItem::title(const QWebElement &element)
     return element.toPlainText().left(255).simplified();
 }
 
-void Fb2TreeItem::addChildren(QWebElement &parent, bool direct)
+void Fb2TreeItem::addChildren(QWebElement &parent, bool direct, bool header)
 {
     int number = 0;
     QWebElement child = parent.firstChild();
     while (!child.isNull()) {
         QString tag = child.tagName().toLower();
         if (tag == "div") {
-            m_list << new Fb2TreeItem(child, this, direct ? number : -1);
+            bool h = header;
+            QString style = child.attribute("class").toLower();
+            h = h || style == "description" || style == "stylesheet";
+            if (!h || style == "annotation" || style == "history") {
+                m_list << new Fb2TreeItem(child, this, direct ? number : -1);
+            } else {
+                addChildren(child, false, h);
+            }
+        } else if (header) {
+            // skip
         } else if (tag == "img") {
             m_list << new Fb2TreeItem(child, this, direct ? number : -1);
         } else {
-            addChildren(child, false);
+            addChildren(child, false, header);
         }
         child = child.nextSibling();
         number++;

+ 1 - 1
source/fb2tree.hpp

@@ -66,7 +66,7 @@ public:
 
 private:
     QString static title(const QWebElement &element);
-    void addChildren(QWebElement &parent, bool direct = true);
+    void addChildren(QWebElement &parent, bool direct = true, bool header = false);
 
 private:
     QList<Fb2TreeItem*> m_list;

+ 27 - 0
source/res/style.css

@@ -37,6 +37,33 @@ div.description div.title-info div.annotation div {
   display: block;
 }
 
+div.description div.document-info {
+  display: block;
+}
+
+div.description div.document-info div {
+  display: none;
+}
+
+div.description div.document-info div.history {
+  display: block;
+  padding-left: 10;
+  padding-right: 10;
+  border-width: thin;
+  border-style: solid;
+  border-color: blue;
+  border-top-left-radius: 10;
+  border-top-right-radius: 10;
+  border-bottom-left-radius: 10;
+  border-bottom-right-radius: 10;
+  margin-top: 1em;
+  margin-bottom: 1em;
+}
+
+div.description div.document-info div.history div {
+  display: block;
+}
+
 div.section {
   border-top: none;
   border-bottom: none;