Falkon Develop
Cross-platform Qt-based web browser
tabmrumodel.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2018 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#pragma once
19
20#include <QAbstractProxyModel>
21
22#include "qzcommon.h"
23
24class WebTab;
25class BrowserWindow;
26
27class TabMruModelItem;
28
29class FALKON_EXPORT TabMruModel : public QAbstractProxyModel
30{
31 Q_OBJECT
32
33public:
34 explicit TabMruModel(BrowserWindow *window, QObject *parent = nullptr);
35 ~TabMruModel() override;
36
37 QModelIndex tabIndex(WebTab *tab) const;
38 WebTab *tab(const QModelIndex &index) const;
39
40 Qt::ItemFlags flags(const QModelIndex &index) const override;
41 int rowCount(const QModelIndex &parent) const override;
42 int columnCount(const QModelIndex &parent) const override;
43 QModelIndex parent(const QModelIndex &index) const override;
44 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
45
46 QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
47 QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
48
49private:
50 void init();
51 QModelIndex index(TabMruModelItem *item) const;
52 TabMruModelItem *item(const QModelIndex &index) const;
53
54 void currentTabChanged(int index);
55 void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
56 void sourceRowsInserted(const QModelIndex &parent, int start, int end);
57 void sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
58 void sourceReset();
59
60 BrowserWindow *m_window;
61 TabMruModelItem *m_root = nullptr;
62 QHash<WebTab*, TabMruModelItem*> m_items;
63};
Definition: webtab.h:40
#define FALKON_EXPORT
Definition: qzcommon.h:28