Kandrashin Denis 13 lat temu
rodzic
commit
e31b570ae9

+ 9 - 0
source/fb2head.cpp

@@ -395,10 +395,12 @@ Fb2HeadView::Fb2HeadView(Fb2WebView &view, QWidget *parent)
     act->setShortcuts(QKeySequence::Delete);
 
     //setItemDelegate(new QItemDelegate(this));
+    setRootIsDecorated(false);
     setSelectionBehavior(QAbstractItemView::SelectItems);
     setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
     connect(&m_view, SIGNAL(loadFinished(bool)), SLOT(updateTree()));
     connect(this, SIGNAL(activated(QModelIndex)), SLOT(activated(QModelIndex)));
+    connect(this, SIGNAL(collapsed(QModelIndex)), SLOT(collapsed(QModelIndex)));
 
     header()->setDefaultSectionSize(200);
     connect(actionModify, SIGNAL(triggered()), SLOT(editCurrent()));
@@ -449,3 +451,10 @@ void Fb2HeadView::showStatus(const QModelIndex &current)
     QModelIndex index = model()->index(current.row(), 2, parent);
     emit status(model()->data(index).toString());
 }
+
+void Fb2HeadView::collapsed(const QModelIndex &index)
+{
+    if (model() && !model()->parent(index).isValid()) {
+        expand(index);
+    }
+}

+ 1 - 0
source/fb2head.hpp

@@ -146,6 +146,7 @@ public slots:
 
 private slots:
     void activated(const QModelIndex &index);
+    void collapsed(const QModelIndex &index);
 
 protected:
     void currentChanged(const QModelIndex &current, const QModelIndex &previous);

+ 1 - 1
source/fb2read.cpp

@@ -95,7 +95,7 @@ void Fb2ReadHandler::BaseHandler::writeAttributes(const QXmlAttributes &atts)
     for (int i = 0; i < count; i++) {
         if (atts.localName(i) == "href") continue;
         QString name = atts.qName(i);
-        if (name != "id") name.prepend("fb2.");
+        if (name != "id") name.prepend("fb2_");
         writer().writeAttribute(name, atts.value(i));
     }
 }

+ 1 - 1
source/fb2save.cpp

@@ -296,7 +296,7 @@ void Fb2SaveHandler::TextHandler::Init(const QXmlAttributes &atts)
             m_writer.writeAttribute(name, atts.value(i));
         } else if (name == "name") {
             m_writer.writeAttribute(name, atts.value(i));
-        } else if (name.left(4) == "fb2.") {
+        } else if (name.left(4) == "fb2_") {
             m_writer.writeAttribute(name.mid(4), atts.value(i));
         }
     }

+ 3 - 7
source/fb2tree.cpp

@@ -2,6 +2,7 @@
 
 #include <QtDebug>
 #include <QAction>
+#include <QApplication>
 #include <QVBoxLayout>
 #include <QWebFrame>
 #include <QWebPage>
@@ -206,7 +207,6 @@ void Fb2TreeModel::selectText(const QModelIndex &index)
     frame->scroll(0, node->pos().y() - frame->scrollPosition().y());
     QString selector = QString("var element=%1;").arg(node->selector());
     Fb2WebView::selectText(&m_view, selector);
-    m_view.setFocus();
 }
 
 QModelIndex Fb2TreeModel::index(const QString &location) const
@@ -262,16 +262,15 @@ void Fb2TreeView::contentsChanged()
 
 void Fb2TreeView::activated(const QModelIndex &index)
 {
+    if (qApp->focusWidget() == &m_view) return;
     if (!model()) return;
     Fb2TreeModel *model = static_cast<Fb2TreeModel*>(this->model());
-
-    disconnect(m_view.page(), SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
     model->selectText(index);
-    connect(m_view.page(), SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
 }
 
 void Fb2TreeView::selectTree()
 {
+    if (qApp->focusWidget() == this) return;
     if (model() == 0) return;
     Fb2TreeModel * model = static_cast<Fb2TreeModel*>(this->model());
     QWebFrame * frame = model->view().page()->mainFrame();
@@ -279,11 +278,8 @@ void Fb2TreeView::selectTree()
     QString location = frame->evaluateJavaScript(javascript).toString();
     QModelIndex index = model->index(location);
     if (!index.isValid()) return;
-
-    disconnect(this, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));
     setCurrentIndex(index);
     scrollTo(index);
-    connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));
 }
 
 void Fb2TreeView::updateTree()

+ 1 - 1
source/fb2view.cpp

@@ -42,7 +42,7 @@ void Fb2NoteView::hint(const QWebElement element, const QRect &rect)
     QString html = element.toOuterXml();
     html.prepend(
         "<body bgcolor=lightyellow style='overflow:hidden;padding:0;margin:0;margin-top:2;'>"
-        "<div class=body name=notes style='padding:0;margin:0;'>"
+        "<div class=body fb2_name=notes style='padding:0;margin:0;'>"
     );
     html.append("</div></body>");
     setGeometry(rect);

+ 3 - 3
source/res/style.css

@@ -92,7 +92,7 @@ div.poem p {
   margin-bottom: 0;
 }
 
-div.body[name=notes] {
+div.body[fb2_name=notes] {
   border-top: none;
   border-bottom: none;
   border-left: none;
@@ -103,7 +103,7 @@ div.body[name=notes] {
   padding-right: 0;
 }
 
-div.body[name=notes] div[id] div.title {
+div.body[fb2_name=notes] div[id] div.title {
   font: inherit;
   float: left;
   margin-left: 4;
@@ -112,7 +112,7 @@ div.body[name=notes] div[id] div.title {
   padding-right: 4;
 }
 
-div.body[name=notes] div[id] div.title p {
+div.body[fb2_name=notes] div[id] div.title p {
   margin-top: 0;
   margin-bottom: 0;
 }