Warning, file /network/falkon/src/lib/tabwidget/tabtreemodel.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* ============================================================
0002 * Falkon - Qt web browser
0003 * Copyright (C) 2018 David Rosca <nowrep@gmail.com>
0004 *
0005 * This program is free software: you can redistribute it and/or modify
0006 * it under the terms of the GNU General Public License as published by
0007 * the Free Software Foundation, either version 3 of the License, or
0008 * (at your option) any later version.
0009 *
0010 * This program is distributed in the hope that it will be useful,
0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013 * GNU General Public License for more details.
0014 *
0015 * You should have received a copy of the GNU General Public License
0016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0017 * ============================================================ */
0018 #pragma once
0019 
0020 #include <QAbstractProxyModel>
0021 
0022 #include "qzcommon.h"
0023 
0024 class QTimer;
0025 
0026 class WebTab;
0027 class BrowserWindow;
0028 class TabTreeModelItem;
0029 
0030 class FALKON_EXPORT TabTreeModel : public QAbstractProxyModel
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035     explicit TabTreeModel(BrowserWindow *window, QObject *parent = nullptr);
0036     ~TabTreeModel() override;
0037 
0038     QModelIndex tabIndex(WebTab *tab) const;
0039     WebTab *tab(const QModelIndex &index) const;
0040 
0041     Qt::ItemFlags flags(const QModelIndex &index) const override;
0042     QVariant data(const QModelIndex &index, int role) const override;
0043     int rowCount(const QModelIndex &parent) const override;
0044     int columnCount(const QModelIndex &parent) const override;
0045     bool hasChildren(const QModelIndex &parent) const override;
0046     QModelIndex parent(const QModelIndex &child) const override;
0047     QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
0048 
0049     QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
0050     QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
0051 
0052     bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
0053     bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
0054 
0055 private:
0056     void init();
0057     QModelIndex index(TabTreeModelItem *item) const;
0058     TabTreeModelItem *item(const QModelIndex &index) const;
0059     TabTreeModelItem *createItems(TabTreeModelItem *root);
0060 
0061     void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
0062     void sourceRowsInserted(const QModelIndex &parent, int start, int end);
0063     void sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
0064     void sourceReset();
0065 
0066     void insertIndex(const QModelIndex &sourceIndex);
0067     void removeIndex(const QModelIndex &sourceIndex);
0068     void connectTab(WebTab *tab);
0069     void syncTopLevelTabs();
0070 
0071     BrowserWindow *m_window;
0072     TabTreeModelItem *m_root = nullptr;
0073     QHash<WebTab*, TabTreeModelItem*> m_items;
0074 };