File indexing completed on 2024-05-19 04:59:21
0001 /* ============================================================ 0002 * VerticalTabs plugin for Falkon 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 <QListView> 0021 0022 class BrowserWindow; 0023 0024 class TabListDelegate; 0025 0026 class TabListView : public QListView 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 explicit TabListView(BrowserWindow *window, QWidget *parent = nullptr); 0032 0033 bool isHidingWhenEmpty() const; 0034 void setHideWhenEmpty(bool enable); 0035 0036 void updateIndex(const QModelIndex &index); 0037 void adjustStyleOption(QStyleOptionViewItem *option); 0038 0039 QModelIndex indexAfter(const QModelIndex &index) const; 0040 QModelIndex indexBefore(const QModelIndex &index) const; 0041 0042 private: 0043 void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override; 0044 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) override; 0045 void rowsInserted(const QModelIndex &parent, int start, int end) override; 0046 void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override; 0047 bool viewportEvent(QEvent *event) override; 0048 0049 enum DelegateButton { 0050 NoButton, 0051 AudioButton 0052 }; 0053 0054 DelegateButton buttonAt(const QPoint &pos, const QModelIndex &index) const; 0055 void updateVisibility(); 0056 void updateHeight(); 0057 0058 BrowserWindow *m_window; 0059 TabListDelegate *m_delegate; 0060 DelegateButton m_pressedButton = NoButton; 0061 QModelIndex m_pressedIndex; 0062 bool m_hideWhenEmpty = false; 0063 };