Falkon Develop
Cross-platform Qt-based web browser
bookmarkstreeview.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2014 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#ifndef BOOKMARKSTREEVIEW_H
19#define BOOKMARKSTREEVIEW_H
20
21#include <QTreeView>
22
23#include "qzcommon.h"
24
25class Bookmarks;
26class BookmarkItem;
27class BookmarksModel;
29
30class FALKON_EXPORT BookmarksTreeView : public QTreeView
31{
32 Q_OBJECT
33
34public:
35 enum ViewType {
37 BookmarksSidebarViewType
38 };
39
40 explicit BookmarksTreeView(QWidget* parent = nullptr);
41
42 ViewType viewType() const;
43 void setViewType(ViewType type);
44
45 // Returns null if more than one (or zero) bookmarks are selected
46 BookmarkItem* selectedBookmark() const;
47 // Returns all selected bookmarks
48 QList<BookmarkItem*> selectedBookmarks() const;
49
50 void selectBookmark(BookmarkItem* item);
51 // Expand up to root item
52 void ensureBookmarkVisible(BookmarkItem* item);
53
54public Q_SLOTS:
55 void search(const QString &string);
56
57Q_SIGNALS:
58 // Open bookmark in current tab
60 // Open bookmark in new tab
62 // Open bookmark in new window
64 // Context menu signal with point mapped to global
65 void contextMenuRequested(const QPoint &point);
66 // If all bookmarks have been deselected, items is empty
67 void bookmarksSelected(const QList<BookmarkItem*> &items);
68
69private Q_SLOTS:
70 void indexExpanded(const QModelIndex &parent);
71 void indexCollapsed(const QModelIndex &parent);
72
73private:
74 void restoreExpandedState(const QModelIndex &parent);
75 void rowsInserted(const QModelIndex &parent, int start, int end) override;
76 void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override;
77
78 void contextMenuEvent(QContextMenuEvent* event) override;
79 void mouseMoveEvent(QMouseEvent* event) override;
80 void mousePressEvent(QMouseEvent* event) override;
81 void mouseReleaseEvent(QMouseEvent* event) override;
82 void mouseDoubleClickEvent(QMouseEvent* event) override;
83 void keyPressEvent(QKeyEvent* event) override;
84
85 Bookmarks* m_bookmarks;
86 BookmarksModel* m_model;
87 BookmarksFilterModel* m_filter;
88 ViewType m_type;
89};
90
91#endif // BOOKMARKSTREEVIEW_H
void bookmarkShiftActivated(BookmarkItem *item)
void bookmarkCtrlActivated(BookmarkItem *item)
void bookmarkActivated(BookmarkItem *item)
void bookmarksSelected(const QList< BookmarkItem * > &items)
void contextMenuRequested(const QPoint &point)
#define FALKON_EXPORT
Definition: qzcommon.h:28