blob: dc55954a94ed64ba1c6df07930c75d6d16b67682 (
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
|
/* ============================================================
* The rekonq project
* ============================================================
* SPDX-License-Identifier: GPL-3.0-only
* Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
* ============================================================ */
#include "bookmarkspanel.hpp"
#include "bookmarks/bookmarkstreemodel.hpp"
#include "bookmarkscontextmenu.hpp"
#include <QMenu>
BookmarksPanel::BookmarksPanel(QWidget *parent) : QTreeView(parent)
{
setEditTriggers(QAbstractItemView::NoEditTriggers);
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &QTreeView::activated, this, [this](const QModelIndex &index) { open(index); });
connect(this, &QTreeView::customContextMenuRequested, this, &BookmarksPanel::customContextMenu);
}
BookmarksTreeModel *BookmarksPanel::model() const
{
auto *m = qobject_cast<BookmarksTreeModel *>(QTreeView::model());
Q_CHECK_PTR(m);
return m;
}
void BookmarksPanel::customContextMenu(const QPoint &pos)
{
(new BookmarksContextMenu(indexAt(pos), model(), this))->popup(mapToGlobal(pos));
}
void BookmarksPanel::open(const QModelIndex &index, rekonq::OpenType type)
{
auto *item = model()->item(index);
const auto url = item->data(BookmarksTreeItem::Href).toUrl();
emit loadUrl(url, type);
}
|