--- a/src/eric7/WebBrowser/Bookmarks/BookmarksModel.py Sun Nov 06 11:22:39 2022 +0100 +++ b/src/eric7/WebBrowser/Bookmarks/BookmarksModel.py Mon Nov 07 17:19:58 2022 +0100 @@ -22,6 +22,7 @@ ) from eric7.EricGui import EricPixmapCache +from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow class BookmarksModel(QAbstractItemModel): @@ -175,11 +176,11 @@ @param role data role (integer) @return bookmark data """ + from .BookmarkNode import BookmarkNode + if not index.isValid() or index.model() != self: return None - from .BookmarkNode import BookmarkNode - bookmarkNode = self.node(index) if role in [Qt.ItemDataRole.EditRole, Qt.ItemDataRole.DisplayRole]: if bookmarkNode.type() == BookmarkNode.Separator: @@ -212,8 +213,6 @@ if bookmarkNode.type() == BookmarkNode.Folder: return EricPixmapCache.getIcon("dirOpen") - from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow - return WebBrowserWindow.icon(QUrl(bookmarkNode.url)) return None @@ -306,14 +305,14 @@ @param parent index of the parent node (QModelIndex) @return flag indicating the presence of children (boolean) """ + from .BookmarkNode import BookmarkNode + if parent is None: parent = QModelIndex() if not parent.isValid(): return True - from .BookmarkNode import BookmarkNode - parentNode = self.node(parent) return parentNode.type() == BookmarkNode.Folder @@ -324,6 +323,8 @@ @param index index of the node cell (QModelIndex) @return flags (Qt.ItemFlags) """ + from .BookmarkNode import BookmarkNode + if not index.isValid(): return Qt.ItemFlag.NoItemFlags @@ -339,8 +340,6 @@ flags |= Qt.ItemFlag.ItemIsDragEnabled - from .BookmarkNode import BookmarkNode - if (index.column() == 0 and type_ != BookmarkNode.Separator) or ( index.column() == 1 and type_ == BookmarkNode.Bookmark ): @@ -406,6 +405,9 @@ @param parent index of the parent node (QModelIndex) @return flag indicating successful acceptance of the data (boolean) """ + from .BookmarkNode import BookmarkNode + from .XbelReader import XbelReader + if action == Qt.DropAction.IgnoreAction: return True @@ -418,8 +420,6 @@ if not data.hasUrls(): return False - from .BookmarkNode import BookmarkNode - node = BookmarkNode(BookmarkNode.Bookmark, parentNode) node.url = bytes(data.urls()[0].toEncoded()).decode() @@ -439,8 +439,6 @@ undoStack = self.__bookmarksManager.undoRedoStack() undoStack.beginMacro("Move Bookmarks") - from .XbelReader import XbelReader - while not stream.atEnd(): encodedData = QByteArray() stream >> encodedData