diff options
Diffstat (limited to 'src/bookmarks/bookmarkstreeitem.hpp')
-rw-r--r-- | src/bookmarks/bookmarkstreeitem.hpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/src/bookmarks/bookmarkstreeitem.hpp b/src/bookmarks/bookmarkstreeitem.hpp index 1f87ecad..05a71ce2 100644 --- a/src/bookmarks/bookmarkstreeitem.hpp +++ b/src/bookmarks/bookmarkstreeitem.hpp @@ -4,11 +4,13 @@ * SPDX-License-Identifier: GPL-3.0-only * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net> * ============================================================ - * Description: rekonq bookmarks model + * Description: rekonq bookmark tree item * ============================================================ */ #pragma once +#include "rekonq.hpp" +#include <QAction> #include <QDateTime> #include <QIcon> #include <QUrl> @@ -18,25 +20,6 @@ class BookmarksTreeItem { public: - enum BookmarkAction { - OPEN = 0, - OPEN_IN_TAB, - OPEN_IN_WINDOW, - OPEN_FOLDER, - BOOKMARK_PAGE, - NEW_FOLDER, - NEW_SEPARATOR, - COPY, - EDIT, -#ifdef HAVE_NEPOMUK - FANCYBOOKMARK, -#endif - DELETE, - NUM_ACTIONS, - SET_TOOLBAR_FOLDER, - UNSET_TOOLBAR_FOLDER - }; - enum Types { Root, Folder, Bookmark, Separator, Alias }; constexpr static int TypesCount = 5; @@ -55,6 +38,14 @@ public: explicit BookmarksTreeItem(Types type, Attributes_t &&args, BookmarksTreeItem *parent); ~BookmarksTreeItem(); + template <typename T> [[nodiscard]] QAction *action(T *sender, rekonq::OpenType type) const + { + auto *action = new QAction(m_data.title, sender); + QObject::connect(action, &QAction::triggered, sender, + [this, sender, type]() { emit sender->loadUrl(m_data.href, type); }); + return action; + }; + [[nodiscard]] BookmarksTreeItem *parent() const { return m_parent; } /** |