419 url.setScheme("file") |
423 url.setScheme("file") |
420 node.url = url.toString() |
424 node.url = url.toString() |
421 self.addBookmark(self.menu(), convertedRootNode) |
425 self.addBookmark(self.menu(), convertedRootNode) |
422 |
426 |
423 Preferences.Prefs.settings.remove('Bookmarks') |
427 Preferences.Prefs.settings.remove('Bookmarks') |
|
428 |
|
429 def iconChanged(self, url): |
|
430 """ |
|
431 Public slot to update the icon image for an URL. |
|
432 |
|
433 @param url URL of the icon to update (QUrl or string) |
|
434 """ |
|
435 if isinstance(url, QUrl): |
|
436 url = url.toString() |
|
437 nodes = self.bookmarksForUrl(url) |
|
438 for node in nodes: |
|
439 self.bookmarksModel().entryChanged(node) |
|
440 |
|
441 def bookmarkForUrl(self, url, start = StartRoot): |
|
442 """ |
|
443 Public method to get a bookmark node for a given URL. |
|
444 |
|
445 @param url URL of the bookmark to search for (QUrl or string) |
|
446 @keyparam start indicator for the start of the search |
|
447 (StartRoot, StartMenu, StartToolBar) |
|
448 @return bookmark node for the given url (BookmarkNode) |
|
449 """ |
|
450 if start == StartMenu: |
|
451 startNode = self.__menu |
|
452 elif start == StartToolBar: |
|
453 startNode = self.__toolbar |
|
454 else: |
|
455 startNode = self.__bookmarkRootNode |
|
456 if startNode is None: |
|
457 return None |
|
458 |
|
459 if isinstance(url, QUrl): |
|
460 url = url.toString() |
|
461 |
|
462 return self.__searchBookmark(url, startNode) |
|
463 |
|
464 def __searchBookmark(self, url, startNode): |
|
465 """ |
|
466 Private method get a bookmark node for a given URL. |
|
467 |
|
468 @param url URL of the bookmark to search for (string) |
|
469 @param startNode reference to the node to start searching (BookmarkNode) |
|
470 @return bookmark node for the given url (BookmarkNode) |
|
471 """ |
|
472 bm = None |
|
473 for node in startNode.children(): |
|
474 if node.type() == BookmarkNode.Folder: |
|
475 bm = self.__searchBookmark(url, node) |
|
476 elif node.type() == BookmarkNode.Bookmark: |
|
477 if node.url == url: |
|
478 bm = node |
|
479 if bm is not None: |
|
480 return bm |
|
481 return None |
|
482 |
|
483 def bookmarksForUrl(self, url, start = StartRoot): |
|
484 """ |
|
485 Public method to get a list of bookmark nodes for a given URL. |
|
486 |
|
487 @param url URL of the bookmarks to search for (QUrl or string) |
|
488 @keyparam start indicator for the start of the search |
|
489 (StartRoot, StartMenu, StartToolBar) |
|
490 @return list of bookmark nodes for the given url (list of BookmarkNode) |
|
491 """ |
|
492 if start == StartMenu: |
|
493 startNode = self.__menu |
|
494 elif start == StartToolBar: |
|
495 startNode = self.__toolbar |
|
496 else: |
|
497 startNode = self.__bookmarkRootNode |
|
498 if startNode is None: |
|
499 return None |
|
500 |
|
501 if isinstance(url, QUrl): |
|
502 url = url.toString() |
|
503 |
|
504 return self.__searchBookmarks(url, startNode) |
|
505 |
|
506 def __searchBookmarks(self, url, startNode): |
|
507 """ |
|
508 Private method get a list of bookmark nodes for a given URL. |
|
509 |
|
510 @param url URL of the bookmarks to search for (string) |
|
511 @param startNode reference to the node to start searching (BookmarkNode) |
|
512 @return list of bookmark nodes for the given url (list of BookmarkNode) |
|
513 """ |
|
514 bm = [] |
|
515 for node in startNode.children(): |
|
516 if node.type() == BookmarkNode.Folder: |
|
517 bm.extend(self.__searchBookmarks(url, node)) |
|
518 elif node.type() == BookmarkNode.Bookmark: |
|
519 if node.url == url: |
|
520 bm.append(node) |
|
521 return bm |
424 |
522 |
425 class RemoveBookmarksCommand(QUndoCommand): |
523 class RemoveBookmarksCommand(QUndoCommand): |
426 """ |
524 """ |
427 Class implementing the Remove undo command. |
525 Class implementing the Remove undo command. |
428 """ |
526 """ |