diff options
Diffstat (limited to 'src/bookmarks/bookmarksmanager.cpp')
-rw-r--r-- | src/bookmarks/bookmarksmanager.cpp | 97 |
1 files changed, 88 insertions, 9 deletions
diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp index 792baaeb..cade77b4 100644 --- a/src/bookmarks/bookmarksmanager.cpp +++ b/src/bookmarks/bookmarksmanager.cpp @@ -75,6 +75,45 @@ void BookmarkOwner::openBookmark(const KBookmark & bookmark, } +bool BookmarkOwner::deleteBookmark(KBookmark &bookmark) +{ + QString name = QString(bookmark.fullText()).replace("&&", "&"); + QString dialogCaption, dialogText; + + if (bookmark.isGroup()) + { + dialogCaption = i18n("Bookmark Folder Deletion"); + dialogText = i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?", name); + } + else if (bookmark.isSeparator()) + { + dialogCaption = i18n("Separator Deletion"); + dialogText = i18n("Are you sure you wish to remove this separator?", name); + } + else + { + dialogCaption = i18n("Bookmark Deletion"); + dialogText = i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", name); + } + + if (KMessageBox::warningContinueCancel( + QApplication::activeWindow(), + dialogText, + dialogCaption, + KStandardGuiItem::del(), + KStandardGuiItem::cancel(), + "bookmarkDeletition_askAgain") + != KMessageBox::Continue + ) + return false; + + KBookmarkGroup bmg = bookmark.parentGroup(); + bmg.deleteBookmark(bookmark); + Application::bookmarkProvider()->bookmarkManager()->emitChanged(bmg); + return true; +} + + bool BookmarkOwner::supportsTabs() const { return true; @@ -99,16 +138,16 @@ void BookmarkOwner::openFolderinTabs(const KBookmarkGroup &bookmark) if (urlList.length() > 8) { - if ( !(KMessageBox::warningContinueCancel( Application::instance()->mainWindow(), + if ( !(KMessageBox::warningContinueCancel( Application::instance()->mainWindow(), i18ncp("%1=Number of tabs. Value is always >=8", "You are about to open %1 tabs.\nAre you sure?", - "You are about to open %1 tabs.\nAre you sure?", + "You are about to open %1 tabs.\nAre you sure?", urlList.length()), "", KStandardGuiItem::cont(), KStandardGuiItem::cancel(), "openFolderInTabs_askAgain" - ) == KMessageBox::Continue) + ) == KMessageBox::Continue) ) return; } @@ -335,7 +374,7 @@ void BookmarkToolBar::actionHovered() // ------------------------------------------------------------------------------------------------------ - + BookmarkProvider::BookmarkProvider(QObject *parent) : QObject(parent) , m_manager(0) @@ -388,13 +427,15 @@ BookmarkProvider::~BookmarkProvider() void BookmarkProvider::setupBookmarkBar(BookmarkToolBar *toolbar) { + if (m_bookmarkToolBars.contains(toolbar)) + return; + kDebug() << "new bookmark bar..."; - + m_bookmarkToolBars.append(toolbar); toolbar->setContextMenuPolicy(Qt::CustomContextMenu); connect(toolbar, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); - - slotBookmarksChanged("", ""); + kDebug() << "new bookmark bar... DONE!"; } @@ -451,7 +492,7 @@ void BookmarkProvider::contextMenu(const QPoint &point) KActionMenu* BookmarkProvider::bookmarkActionMenu(QWidget *parent) { kDebug() << "new Bookmarks Menu..."; - + KMenu *menu = new KMenu(parent); _bookmarkActionMenu = new KActionMenu(parent); _bookmarkActionMenu->setMenu(menu); @@ -522,7 +563,7 @@ QList<KBookmark> BookmarkProvider::find(QString text) return list; } - KBookmark bookmark = bookGroup.first(); + KBookmark bookmark = bookGroup.first(); while (!bookmark.isNull()) { list = find(list, bookmark, text); @@ -591,3 +632,41 @@ void BookmarkProvider::slotPanelChanged() panel->startLoadFoldedState(); } } + + +KBookmark BookmarkProvider::bookmarkForUrl(const KUrl &url) +{ + KBookmark found; + + KBookmarkGroup root = rootGroup(); + if (root.isNull()) + { + return found; + } + + return bookmarkForUrl(root, url); +} + + +KBookmark BookmarkProvider::bookmarkForUrl(const KBookmark &bookmark, const KUrl &url) +{ + KBookmark found; + + if (bookmark.isGroup()) + { + KBookmarkGroup group = bookmark.toGroup(); + KBookmark bookmark = group.first(); + + while (!bookmark.isNull() && found.isNull()) + { + found = bookmarkForUrl(bookmark, url); + bookmark = group.next(bookmark); + } + } + else if (!bookmark.isSeparator() && bookmark.url() == url) + { + found = bookmark; + } + + return found; +} |