blob: 761a0026d52c8b4dd6240a8533b7660e65509a2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/* ============================================================
* 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>
* ============================================================
* Description: rekonq bookmarks menu
* ============================================================ */
#include "bookmarksmenu.hpp"
#include "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);
}
}
|