Kandrashin Denis 13 anos atrás
pai
commit
d2b604b862
2 arquivos alterados com 3 adições e 9 exclusões
  1. 2 8
      source/fb2tree.cpp
  2. 1 1
      source/fb2tree.hpp

+ 2 - 8
source/fb2tree.cpp

@@ -203,7 +203,7 @@ void Fb2TreeModel::selectText(const QModelIndex &index)
     m_view.setFocus();
 }
 
-QModelIndex Fb2TreeModel::index(const QString &location, QModelIndex current) const
+QModelIndex Fb2TreeModel::index(const QString &location) const
 {
     QModelIndex index;
     Fb2TreeItem * parent = m_root;
@@ -216,12 +216,6 @@ QModelIndex Fb2TreeModel::index(const QString &location, QModelIndex current) co
         Fb2TreeItem * child = parent->content(*this, key, index);
         parent = child;
     }
-
-    while (current.isValid()) {
-        if (current == index) return QModelIndex();
-        current = this->parent(current);
-    }
-
     return index;
 }
 
@@ -275,7 +269,7 @@ void Fb2TreeView::selectTree()
     QWebFrame * frame = model->view().page()->mainFrame();
     static const QString javascript = FB2::read(":/js/get_location.js");
     QString location = frame->evaluateJavaScript(javascript).toString();
-    QModelIndex index = model->index(location, currentIndex());
+    QModelIndex index = model->index(location);
     if (!index.isValid()) return;
 
     disconnect(this, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));

+ 1 - 1
source/fb2tree.hpp

@@ -73,7 +73,7 @@ class Fb2TreeModel: public QAbstractItemModel
 public:
     explicit Fb2TreeModel(Fb2WebView &view, QObject *parent = 0);
     virtual ~Fb2TreeModel();
-    QModelIndex index(const QString &location, QModelIndex current) const;
+    QModelIndex index(const QString &location) const;
     Fb2WebView & view() { return m_view; }
     void selectText(const QModelIndex &index);