From cc5ea94c0172645741e9a5601d13ff500d2332ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Wed, 8 Feb 2012 15:49:28 +0100 Subject: QTabBar - add minimumTabSizeHint as virtual function. Just implements what the note states (and removes the private function) Change-Id: Ida009e1836ded5816218372edb8c178523242a9e Reviewed-by: Girish Ramakrishnan Reviewed-by: Robin Burchell --- src/widgets/widgets/qtabbar.cpp | 20 ++++++++++++-------- src/widgets/widgets/qtabbar.h | 1 + src/widgets/widgets/qtabbar_p.h | 2 -- 3 files changed, 13 insertions(+), 10 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index ce25a22847..ecb0ef84e0 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -427,7 +427,7 @@ void QTabBarPrivate::layoutTabs() tabList[i].maxRect = QRect(x, 0, sz.width(), sz.height()); x += sz.width(); maxHeight = qMax(maxHeight, sz.height()); - sz = minimumTabSizeHint(i); + sz = q->minimumTabSizeHint(i); tabList[i].minRect = QRect(minx, 0, sz.width(), sz.height()); minx += sz.width(); tabChain[tabChainIndex].init(); @@ -452,7 +452,7 @@ void QTabBarPrivate::layoutTabs() tabList[i].maxRect = QRect(0, y, sz.width(), sz.height()); y += sz.height(); maxWidth = qMax(maxWidth, sz.width()); - sz = minimumTabSizeHint(i); + sz = q->minimumTabSizeHint(i); tabList[i].minRect = QRect(0, miny, sz.width(), sz.height()); miny += sz.height(); tabChain[tabChainIndex].init(); @@ -1290,14 +1290,18 @@ static QString computeElidedText(Qt::TextElideMode mode, const QString &text) return ret; } -QSize QTabBarPrivate::minimumTabSizeHint(int index) +/*! + Returns the minimum tab size hint for the tab at position \a index. + \since Qt 5.0 +*/ + +QSize QTabBar::minimumTabSizeHint(int index) const { - Q_Q(QTabBar); - // ### Qt 5: make this a protected virtual function in QTabBar - Tab &tab = tabList[index]; + Q_D(const QTabBar); + QTabBarPrivate::Tab &tab = const_cast(d->tabList[index]); QString oldText = tab.text; - tab.text = computeElidedText(elideMode, oldText); - QSize size = q->tabSizeHint(index); + tab.text = computeElidedText(d->elideMode, oldText); + QSize size = tabSizeHint(index); tab.text = oldText; return size; } diff --git a/src/widgets/widgets/qtabbar.h b/src/widgets/widgets/qtabbar.h index 3a4b9198d3..13ed3bc6d2 100644 --- a/src/widgets/widgets/qtabbar.h +++ b/src/widgets/widgets/qtabbar.h @@ -178,6 +178,7 @@ Q_SIGNALS: protected: virtual QSize tabSizeHint(int index) const; + virtual QSize minimumTabSizeHint(int index) const; virtual void tabInserted(int index); virtual void tabRemoved(int index); virtual void tabLayoutChange(); diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index c907b48eeb..aa9db38677 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -165,8 +165,6 @@ public: inline bool validIndex(int index) const { return index >= 0 && index < tabList.count(); } void setCurrentNextEnabledIndex(int offset); - QSize minimumTabSizeHint(int index); - QToolButton* rightB; // right or bottom QToolButton* leftB; // left or top -- cgit v1.2.3