20 #include "TabBarQuick_p.h"
22 #include <QMetaObject>
23 #include <QMouseEvent>
27 TabBarQuick::TabBarQuick(TabWidget *parent)
28 : QWidgetAdapter(parent->asWidget())
29 , TabBar(this, parent)
33 int TabBarQuick::tabAt(
QPoint p)
const
38 if (!m_tabBarQmlItem) {
39 qWarning() << Q_FUNC_INFO <<
"No visual tab bar item yet";
43 if (QQuickItem *internalListView = listView()) {
46 Q_ARG(
double, p.
x()), Q_ARG(
double, p.
y()));
50 qWarning() << Q_FUNC_INFO <<
"Couldn't find the internal ListView";
56 QQuickItem *TabBarQuick::tabBarQmlItem()
const
58 return m_tabBarQmlItem;
61 void TabBarQuick::setTabBarQmlItem(QQuickItem *item)
63 m_tabBarQmlItem = item;
66 QString TabBarQuick::text(
int index)
const
68 if (QQuickItem *item = tabAt(index))
69 return item->property(
"text").toString();
74 QRect TabBarQuick::rectForTab(
int index)
const
76 if (QQuickItem *item = tabAt(index))
77 return item->boundingRect().toRect();
82 bool TabBarQuick::event(
QEvent *ev)
87 if (m_tabBarQmlItem) {
89 m_tabBarQmlItem->setProperty(
"currentIndex", tabAt(me->pos()));
91 TabBar::onMousePress(me->pos());
93 TabBar::onMouseDoubleClick(me->pos());
102 return QWidgetAdapter::event(ev);
105 QQuickItem *TabBarQuick::tabAt(
int index)
const
107 QQuickItem *view = listView();
111 QQuickItem *item =
nullptr;
118 QQuickItem *TabBarQuick::listView()
const
122 if (!m_tabBarQmlItem)
126 for (QQuickItem *child : children) {
127 if (qstrcmp(child->metaObject()->className(),
"QQuickListView") == 0)
134 void TabBarQuick::moveTabTo(
int from,
int to)