/* ============================================================ * The rekonq project * ============================================================ * SPDX-License-Identifier: GPL-2.0-or-later * Copyright (C) 2008-2013 by Andrea Diamantini * Copyright (C) 2010 by Yoann Laissus * SPDX-License-Identifier: GPL-3.0-only * Copyright (C) 2022 aqua * ============================================================ */ #include "bookmarksmenu.hpp" #include "bookmarks/bookmarkstreemodel.hpp" BookmarksMenu::BookmarksMenu(QWidget *parent) : QMenu(parent) { connect(this, &QMenu::aboutToShow, this, &BookmarksMenu::refill); } void BookmarksMenu::refill() { Q_CHECK_PTR(model); for (auto *a : actions) { removeAction(a); delete a; } actions.clear(); actions.append(addSeparator()); const auto *root = model->item(); Q_CHECK_PTR(root); for (int i = 0; i < root->childCount(); ++i) { const auto *child = root->child(i); if (child->type() != BookmarksTreeItem::Bookmark) continue; auto *action = addAction(child->data(BookmarksTreeItem::Title).toString(), this, [this, child]() { emit loadUrl(child->data(BookmarksTreeItem::Href).toUrl(), rekonq::CurrentTab); }); actions.append(action); } }