173 |
174 |
174 @param index index of bookmark to get data for (QModelIndex) |
175 @param index index of bookmark to get data for (QModelIndex) |
175 @param role data role (integer) |
176 @param role data role (integer) |
176 @return bookmark data |
177 @return bookmark data |
177 """ |
178 """ |
|
179 from .BookmarkNode import BookmarkNode |
|
180 |
178 if not index.isValid() or index.model() != self: |
181 if not index.isValid() or index.model() != self: |
179 return None |
182 return None |
180 |
|
181 from .BookmarkNode import BookmarkNode |
|
182 |
183 |
183 bookmarkNode = self.node(index) |
184 bookmarkNode = self.node(index) |
184 if role in [Qt.ItemDataRole.EditRole, Qt.ItemDataRole.DisplayRole]: |
185 if role in [Qt.ItemDataRole.EditRole, Qt.ItemDataRole.DisplayRole]: |
185 if bookmarkNode.type() == BookmarkNode.Separator: |
186 if bookmarkNode.type() == BookmarkNode.Separator: |
186 if index.column() == 0: |
187 if index.column() == 0: |
210 |
211 |
211 elif role == Qt.ItemDataRole.DecorationRole and index.column() == 0: |
212 elif role == Qt.ItemDataRole.DecorationRole and index.column() == 0: |
212 if bookmarkNode.type() == BookmarkNode.Folder: |
213 if bookmarkNode.type() == BookmarkNode.Folder: |
213 return EricPixmapCache.getIcon("dirOpen") |
214 return EricPixmapCache.getIcon("dirOpen") |
214 |
215 |
215 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
|
216 |
|
217 return WebBrowserWindow.icon(QUrl(bookmarkNode.url)) |
216 return WebBrowserWindow.icon(QUrl(bookmarkNode.url)) |
218 |
217 |
219 return None |
218 return None |
220 |
219 |
221 def columnCount(self, parent=None): |
220 def columnCount(self, parent=None): |
304 Public method to check, if a parent node has some children. |
303 Public method to check, if a parent node has some children. |
305 |
304 |
306 @param parent index of the parent node (QModelIndex) |
305 @param parent index of the parent node (QModelIndex) |
307 @return flag indicating the presence of children (boolean) |
306 @return flag indicating the presence of children (boolean) |
308 """ |
307 """ |
|
308 from .BookmarkNode import BookmarkNode |
|
309 |
309 if parent is None: |
310 if parent is None: |
310 parent = QModelIndex() |
311 parent = QModelIndex() |
311 |
312 |
312 if not parent.isValid(): |
313 if not parent.isValid(): |
313 return True |
314 return True |
314 |
315 |
315 from .BookmarkNode import BookmarkNode |
|
316 |
|
317 parentNode = self.node(parent) |
316 parentNode = self.node(parent) |
318 return parentNode.type() == BookmarkNode.Folder |
317 return parentNode.type() == BookmarkNode.Folder |
319 |
318 |
320 def flags(self, index): |
319 def flags(self, index): |
321 """ |
320 """ |
322 Public method to get flags for a node cell. |
321 Public method to get flags for a node cell. |
323 |
322 |
324 @param index index of the node cell (QModelIndex) |
323 @param index index of the node cell (QModelIndex) |
325 @return flags (Qt.ItemFlags) |
324 @return flags (Qt.ItemFlags) |
326 """ |
325 """ |
|
326 from .BookmarkNode import BookmarkNode |
|
327 |
327 if not index.isValid(): |
328 if not index.isValid(): |
328 return Qt.ItemFlag.NoItemFlags |
329 return Qt.ItemFlag.NoItemFlags |
329 |
330 |
330 node = self.node(index) |
331 node = self.node(index) |
331 type_ = node.type() |
332 type_ = node.type() |
336 |
337 |
337 if node in (self.__bookmarksManager.menu(), self.__bookmarksManager.toolbar()): |
338 if node in (self.__bookmarksManager.menu(), self.__bookmarksManager.toolbar()): |
338 return flags |
339 return flags |
339 |
340 |
340 flags |= Qt.ItemFlag.ItemIsDragEnabled |
341 flags |= Qt.ItemFlag.ItemIsDragEnabled |
341 |
|
342 from .BookmarkNode import BookmarkNode |
|
343 |
342 |
344 if (index.column() == 0 and type_ != BookmarkNode.Separator) or ( |
343 if (index.column() == 0 and type_ != BookmarkNode.Separator) or ( |
345 index.column() == 1 and type_ == BookmarkNode.Bookmark |
344 index.column() == 1 and type_ == BookmarkNode.Bookmark |
346 ): |
345 ): |
347 flags |= Qt.ItemFlag.ItemIsEditable |
346 flags |= Qt.ItemFlag.ItemIsEditable |
404 @param row row number (integer) |
403 @param row row number (integer) |
405 @param column column number (integer) |
404 @param column column number (integer) |
406 @param parent index of the parent node (QModelIndex) |
405 @param parent index of the parent node (QModelIndex) |
407 @return flag indicating successful acceptance of the data (boolean) |
406 @return flag indicating successful acceptance of the data (boolean) |
408 """ |
407 """ |
|
408 from .BookmarkNode import BookmarkNode |
|
409 from .XbelReader import XbelReader |
|
410 |
409 if action == Qt.DropAction.IgnoreAction: |
411 if action == Qt.DropAction.IgnoreAction: |
410 return True |
412 return True |
411 |
413 |
412 if column > 0: |
414 if column > 0: |
413 return False |
415 return False |
415 parentNode = self.node(parent) |
417 parentNode = self.node(parent) |
416 |
418 |
417 if not data.hasFormat(self.MIMETYPE): |
419 if not data.hasFormat(self.MIMETYPE): |
418 if not data.hasUrls(): |
420 if not data.hasUrls(): |
419 return False |
421 return False |
420 |
|
421 from .BookmarkNode import BookmarkNode |
|
422 |
422 |
423 node = BookmarkNode(BookmarkNode.Bookmark, parentNode) |
423 node = BookmarkNode(BookmarkNode.Bookmark, parentNode) |
424 node.url = bytes(data.urls()[0].toEncoded()).decode() |
424 node.url = bytes(data.urls()[0].toEncoded()).decode() |
425 |
425 |
426 if data.hasText(): |
426 if data.hasText(): |
436 if stream.atEnd(): |
436 if stream.atEnd(): |
437 return False |
437 return False |
438 |
438 |
439 undoStack = self.__bookmarksManager.undoRedoStack() |
439 undoStack = self.__bookmarksManager.undoRedoStack() |
440 undoStack.beginMacro("Move Bookmarks") |
440 undoStack.beginMacro("Move Bookmarks") |
441 |
|
442 from .XbelReader import XbelReader |
|
443 |
441 |
444 while not stream.atEnd(): |
442 while not stream.atEnd(): |
445 encodedData = QByteArray() |
443 encodedData = QByteArray() |
446 stream >> encodedData |
444 stream >> encodedData |
447 buffer = QBuffer(encodedData) |
445 buffer = QBuffer(encodedData) |