Browse Source

Small changes

Kandrashin Denis 13 years ago
parent
commit
9d8a98b12b
3 changed files with 7 additions and 17 deletions
  1. 1 1
      source/fb2main.cpp
  2. 3 9
      source/fb2tree.cpp
  3. 3 7
      source/fb2view.cpp

+ 1 - 1
source/fb2main.cpp

@@ -432,7 +432,7 @@ void Fb2MainWindow::createText()
 void Fb2MainWindow::loadFinished(bool ok)
 {
     if (!treeView) return ;
-    Fb2TreeModel *model = new Fb2TreeModel(*textEdit);
+    Fb2TreeModel *model = new Fb2TreeModel(*textEdit, treeView);
     treeView->setModel(model);
     model->expand(treeView);
 }

+ 3 - 9
source/fb2tree.cpp

@@ -79,15 +79,9 @@ Fb2TreeModel::Fb2TreeModel(QWebView &view, QObject *parent)
     , m_root(NULL)
 {
     QWebElement doc = view.page()->mainFrame()->documentElement();
-    QWebElement child = doc.firstChild();
-    while (!child.isNull()) {
-        if (child.tagName().toLower() == "body") {
-            m_root = new Fb2TreeItem(child);
-            break;
-        } else {
-            child = child.nextSibling();
-        }
-    }
+    QWebElement body = doc.findFirst("body");
+    if (body.isNull()) return;
+    m_root = new Fb2TreeItem(body);
 }
 
 Fb2TreeModel::~Fb2TreeModel()

+ 3 - 7
source/fb2view.cpp

@@ -69,13 +69,9 @@ QString Fb2WebView::toXml()
 
 QString Fb2WebView::toBodyXml()
 {
-    QWebElement child = doc().firstChild();
-    while (!child.isNull()) {
-        if (child.tagName().toLower() == "body") {
-            return child.toOuterXml();
-        }
-    }
-    return QString();
+    QWebElement body = doc().findFirst("body");
+    if (body.isNull()) return QString();
+    return body.toOuterXml();
 }
 
 void Fb2WebView::fixContents()