2014-02-08 18:14:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
|
|
|
* Copyright (C) 2014 David Rosca <nowrep@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
|
|
|
#ifndef BOOKMARKSTREEVIEW_H
|
|
|
|
#define BOOKMARKSTREEVIEW_H
|
|
|
|
|
|
|
|
#include <QTreeView>
|
|
|
|
|
|
|
|
#include "qz_namespace.h"
|
|
|
|
|
|
|
|
class Bookmarks;
|
|
|
|
class BookmarkItem;
|
|
|
|
class BookmarksModel;
|
2014-02-09 15:44:38 +01:00
|
|
|
class BookmarksFilterModel;
|
2014-02-08 18:14:20 +01:00
|
|
|
|
|
|
|
class QT_QUPZILLA_EXPORT BookmarksTreeView : public QTreeView
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2014-02-09 11:02:51 +01:00
|
|
|
|
2014-02-08 18:14:20 +01:00
|
|
|
public:
|
2014-02-09 11:02:51 +01:00
|
|
|
enum ViewType {
|
|
|
|
BookmarksManagerViewType,
|
|
|
|
BookmarksSidebarViewType
|
|
|
|
};
|
|
|
|
|
2014-02-08 18:14:20 +01:00
|
|
|
explicit BookmarksTreeView(QWidget* parent = 0);
|
|
|
|
|
2014-02-09 11:02:51 +01:00
|
|
|
ViewType viewType() const;
|
|
|
|
void setViewType(ViewType type);
|
|
|
|
|
|
|
|
// Returns null if more than one (or zero) bookmarks are selected
|
|
|
|
BookmarkItem* selectedBookmark() const;
|
|
|
|
// Returns all selected bookmarks
|
2014-02-08 18:14:20 +01:00
|
|
|
QList<BookmarkItem*> selectedBookmarks() const;
|
|
|
|
|
2014-02-09 15:07:19 +01:00
|
|
|
void selectBookmark(BookmarkItem* item);
|
|
|
|
// Expand up to root item
|
|
|
|
void ensureBookmarkVisible(BookmarkItem* item);
|
|
|
|
|
2014-02-09 15:44:38 +01:00
|
|
|
public slots:
|
|
|
|
void search(const QString &string);
|
|
|
|
|
2014-02-08 18:14:20 +01:00
|
|
|
signals:
|
|
|
|
// Open bookmark in current tab
|
|
|
|
void bookmarkActivated(BookmarkItem* item);
|
|
|
|
// Open bookmark in new tab
|
|
|
|
void bookmarkCtrlActivated(BookmarkItem* item);
|
|
|
|
// Open bookmark in new window
|
|
|
|
void bookmarkShiftActivated(BookmarkItem* item);
|
2014-02-08 20:01:07 +01:00
|
|
|
// Context menu signal with point mapped to global
|
|
|
|
void contextMenuRequested(const QPoint &point);
|
|
|
|
// If all bookmarks have been deselected, items is empty
|
2014-02-08 18:14:20 +01:00
|
|
|
void bookmarksSelected(QList<BookmarkItem*> items);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void indexExpanded(const QModelIndex &parent);
|
|
|
|
void indexCollapsed(const QModelIndex &parent);
|
|
|
|
|
|
|
|
void selectionChanged();
|
|
|
|
void createContextMenu(const QPoint &point);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void restoreExpandedState(const QModelIndex &parent);
|
|
|
|
void rowsInserted(const QModelIndex &parent, int start, int end);
|
|
|
|
|
2014-02-09 18:53:21 +01:00
|
|
|
void mouseMoveEvent(QMouseEvent* event);
|
2014-02-08 18:14:20 +01:00
|
|
|
void mousePressEvent(QMouseEvent* event);
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent* event);
|
|
|
|
void keyPressEvent(QKeyEvent* event);
|
|
|
|
|
|
|
|
Bookmarks* m_bookmarks;
|
|
|
|
BookmarksModel* m_model;
|
2014-02-09 15:44:38 +01:00
|
|
|
BookmarksFilterModel* m_filter;
|
2014-02-09 11:02:51 +01:00
|
|
|
ViewType m_type;
|
2014-02-08 18:14:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BOOKMARKSTREEVIEW_H
|