Warning, file /network/falkon/src/lib/tabwidget/tabmodel.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 <QPointer> 0021 #include <QMimeData> 0022 #include <QAbstractListModel> 0023 0024 #include "qzcommon.h" 0025 0026 class WebTab; 0027 class BrowserWindow; 0028 0029 class FALKON_EXPORT TabModelMimeData : public QMimeData 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 explicit TabModelMimeData(); 0035 0036 WebTab *tab() const; 0037 void setTab(WebTab *tab); 0038 0039 bool hasFormat(const QString &format) const override; 0040 QStringList formats() const override; 0041 0042 static QString mimeType(); 0043 0044 private: 0045 QPointer<WebTab> m_tab; 0046 }; 0047 0048 class FALKON_EXPORT TabModel : public QAbstractListModel 0049 { 0050 Q_OBJECT 0051 0052 public: 0053 enum Roles { 0054 WebTabRole = Qt::UserRole + 1, 0055 TitleRole = Qt::UserRole + 2, 0056 IconRole = Qt::UserRole + 3, 0057 PinnedRole = Qt::UserRole + 4, 0058 RestoredRole = Qt::UserRole + 5, 0059 CurrentTabRole = Qt::UserRole + 6, 0060 LoadingRole = Qt::UserRole + 7, 0061 AudioPlayingRole = Qt::UserRole + 8, 0062 AudioMutedRole = Qt::UserRole + 9, 0063 BackgroundActivityRole = Qt::UserRole + 10 0064 }; 0065 0066 explicit TabModel(BrowserWindow *window, QObject *parent = nullptr); 0067 0068 QModelIndex tabIndex(WebTab *tab) const; 0069 WebTab *tab(const QModelIndex &index) const; 0070 0071 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0072 Qt::ItemFlags flags(const QModelIndex &index) const override; 0073 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0074 0075 Qt::DropActions supportedDropActions() const override; 0076 QStringList mimeTypes() const override; 0077 QMimeData *mimeData(const QModelIndexList &indexes) const override; 0078 bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override; 0079 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; 0080 0081 private: 0082 void init(); 0083 void tabInserted(int index); 0084 void tabRemoved(int index); 0085 void tabMoved(int from, int to); 0086 0087 BrowserWindow *m_window; 0088 QVector<WebTab*> m_tabs; 0089 };