summaryrefslogtreecommitdiff
path: root/src/panels/bookmarksmenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/panels/bookmarksmenu.cpp')
-rw-r--r--src/panels/bookmarksmenu.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/panels/bookmarksmenu.cpp b/src/panels/bookmarksmenu.cpp
new file mode 100644
index 00000000..94615ff4
--- /dev/null
+++ b/src/panels/bookmarksmenu.cpp
@@ -0,0 +1,41 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright (C) 2008-2013 by Andrea Diamantini <adjam7 at gmail dot com>
+ * Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================ */
+
+#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);
+ }
+}