KDDockWidgets API Documentation 2.1
Loading...
Searching...
No Matches
qtquick/views/TabBar.h
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5 Author: SĂ©rgio Martins <sergio.martins@kdab.com>
6
7 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
8
9 Contact KDAB at <info@kdab.com> for commercial licensing options.
10*/
11
20#ifndef KD_TABBAR_QUICK_P_H
21#define KD_TABBAR_QUICK_P_H
22#pragma once
23
24#include "View.h"
25#include "kddockwidgets/core/views/TabBarViewInterface.h"
26
27#include <QAbstractListModel>
28#include <QPointer>
29#include <QHash>
30
31namespace KDDockWidgets {
32
33class DockWidgetInstantiator;
34
35namespace Core {
36class TabBar;
37}
38
39namespace QtQuick {
40
41class Stack;
42class DockWidgetModel;
43
44class DOCKS_EXPORT TabBar : public QtQuick::View, public Core::TabBarViewInterface
45{
46 Q_OBJECT
47 Q_PROPERTY(QQuickItem *tabBarQmlItem READ tabBarQmlItem WRITE setTabBarQmlItem NOTIFY
48 tabBarQmlItemChanged)
49 Q_PROPERTY(bool tabBarAutoHide READ tabBarAutoHide NOTIFY tabBarAutoHideChanged)
50 Q_PROPERTY(DockWidgetModel *dockWidgetModel READ dockWidgetModel CONSTANT)
51 Q_PROPERTY(int hoveredTabIndex READ hoveredTabIndex NOTIFY hoveredTabIndexChanged)
52public:
53 explicit TabBar(Core::TabBar *controller, QQuickItem *parent = nullptr);
54 ~TabBar() override;
55
56 DockWidgetModel *dockWidgetModel() const;
57
58 int tabAt(QPoint localPos) const override;
59 QQuickItem *tabBarQmlItem() const;
60 void setTabBarQmlItem(QQuickItem *);
61
62 QString text(int index) const override;
63 QRect rectForTab(int index) const override;
64 QRect globalRectForTab(int index) const;
65 int indexForTabPos(QPoint) const;
66
67 void moveTabTo(int from, int to) override;
68 Q_INVOKABLE void setCurrentIndex(int index) override;
69
72
73 Q_INVOKABLE bool closeAtIndex(int index);
74
75 Stack *stackView() const;
76 void renameTab(int index, const QString &) override;
77 void changeTabIcon(int index, const QIcon &icon) override;
80 bool tabBarAutoHide() const;
81
82 void removeDockWidget(Core::DockWidget *) override;
83 void insertDockWidget(int index, Core::DockWidget *, const QIcon &,
84 const QString &title) override;
85
88 int hoveredTabIndex() const;
89
90 Q_INVOKABLE void addDockWidgetAsTab(QQuickItem *other,
92
93Q_SIGNALS:
96
99 void hoveredTabIndexChanged(int index);
100
101protected:
102 bool event(QEvent *ev) override;
103 void init() override final;
104 void onHoverEvent(QHoverEvent *, QPoint globalPos) override;
105
106private:
107 QQuickItem *tabAt(int index) const;
108 void setHoveredTabIndex(int);
109
110 class Private;
111 Private *const d;
112};
113
115{
116 Q_OBJECT
117 Q_PROPERTY(int count READ count NOTIFY countChanged)
118public:
119 enum Role {
120 Role_Title = Qt::UserRole
121 };
122
123 explicit DockWidgetModel(Core::TabBar *, QObject *parent);
124 ~DockWidgetModel() override;
125
126 int count() const;
127 int rowCount(const QModelIndex &parent) const override;
128 QVariant data(const QModelIndex &index, int role) const override;
129 Core::DockWidget *dockWidgetAt(int index) const;
130 Core::DockWidget *currentDockWidget() const;
131 void setCurrentDockWidget(Core::DockWidget *);
132 void remove(Core::DockWidget *);
133 int indexOf(const Core::DockWidget *);
134 bool insert(Core::DockWidget *dw, int index);
135 bool contains(Core::DockWidget *dw) const;
136 int currentIndex() const;
137 void setCurrentIndex(int index);
138
139protected:
140 QHash<int, QByteArray> roleNames() const override;
141
142Q_SIGNALS:
145
146private:
147 void emitDataChangedFor(Core::DockWidget *);
148
149 class Private;
150 Private *const d;
151};
152
153}
154
155}
156
157#endif
The DockWidget base-class. DockWidget and Core::DockWidget are only split in two so we can share some...
The interface that TabBar views should implement.
void hoveredTabIndexChanged(int index)
Emitted when the hovered tab changes In case you want to style it differently.
Class to abstract QAction, so code still works with QtQuick and Flutter.
UserRole

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDDockWidgets
Advanced Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets/
Generated by doxygen 1.9.8