Falkon Develop
Cross-platform Qt-based web browser
tablistview.h
Go to the documentation of this file.
1/* ============================================================
2* VerticalTabs plugin for Falkon
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 <QListView>
21
22class BrowserWindow;
23
24class TabListDelegate;
25
26class TabListView : public QListView
27{
28 Q_OBJECT
29
30public:
31 explicit TabListView(BrowserWindow *window, QWidget *parent = nullptr);
32
33 bool isHidingWhenEmpty() const;
34 void setHideWhenEmpty(bool enable);
35
36 void updateIndex(const QModelIndex &index);
37 void adjustStyleOption(QStyleOptionViewItem *option);
38
39 QModelIndex indexAfter(const QModelIndex &index) const;
40 QModelIndex indexBefore(const QModelIndex &index) const;
41
42private:
43 void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
44 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) override;
45 void rowsInserted(const QModelIndex &parent, int start, int end) override;
46 void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override;
47 bool viewportEvent(QEvent *event) override;
48
49 enum DelegateButton {
50 NoButton,
51 AudioButton
52 };
53
54 DelegateButton buttonAt(const QPoint &pos, const QModelIndex &index) const;
55 void updateVisibility();
56 void updateHeight();
57
58 BrowserWindow *m_window;
59 TabListDelegate *m_delegate;
60 DelegateButton m_pressedButton = NoButton;
61 QModelIndex m_pressedIndex;
62 bool m_hideWhenEmpty = false;
63};
void adjustStyleOption(QStyleOptionViewItem *option)
Definition: tablistview.cpp:75
TabListView(BrowserWindow *window, QWidget *parent=nullptr)
Definition: tablistview.cpp:30
QModelIndex indexBefore(const QModelIndex &index) const
void updateIndex(const QModelIndex &index)
Definition: tablistview.cpp:63
bool isHidingWhenEmpty() const
Definition: tablistview.cpp:52
QModelIndex indexAfter(const QModelIndex &index) const
Definition: tablistview.cpp:98
void setHideWhenEmpty(bool enable)
Definition: tablistview.cpp:57