QTabBar - add minimumTabSizeHint as virtual function.

Just implements what the note states (and removes the private function)

Change-Id: Ida009e1836ded5816218372edb8c178523242a9e
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
This commit is contained in:
Thorbjørn Lund Martsum 2012-02-08 15:49:28 +01:00 committed by Qt by Nokia
parent d20efc18ff
commit cc5ea94c01
3 changed files with 13 additions and 10 deletions

View File

@ -427,7 +427,7 @@ void QTabBarPrivate::layoutTabs()
tabList[i].maxRect = QRect(x, 0, sz.width(), sz.height()); tabList[i].maxRect = QRect(x, 0, sz.width(), sz.height());
x += sz.width(); x += sz.width();
maxHeight = qMax(maxHeight, sz.height()); maxHeight = qMax(maxHeight, sz.height());
sz = minimumTabSizeHint(i); sz = q->minimumTabSizeHint(i);
tabList[i].minRect = QRect(minx, 0, sz.width(), sz.height()); tabList[i].minRect = QRect(minx, 0, sz.width(), sz.height());
minx += sz.width(); minx += sz.width();
tabChain[tabChainIndex].init(); tabChain[tabChainIndex].init();
@ -452,7 +452,7 @@ void QTabBarPrivate::layoutTabs()
tabList[i].maxRect = QRect(0, y, sz.width(), sz.height()); tabList[i].maxRect = QRect(0, y, sz.width(), sz.height());
y += sz.height(); y += sz.height();
maxWidth = qMax(maxWidth, sz.width()); maxWidth = qMax(maxWidth, sz.width());
sz = minimumTabSizeHint(i); sz = q->minimumTabSizeHint(i);
tabList[i].minRect = QRect(0, miny, sz.width(), sz.height()); tabList[i].minRect = QRect(0, miny, sz.width(), sz.height());
miny += sz.height(); miny += sz.height();
tabChain[tabChainIndex].init(); tabChain[tabChainIndex].init();
@ -1290,14 +1290,18 @@ static QString computeElidedText(Qt::TextElideMode mode, const QString &text)
return ret; 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); Q_D(const QTabBar);
// ### Qt 5: make this a protected virtual function in QTabBar QTabBarPrivate::Tab &tab = const_cast<QTabBarPrivate::Tab&>(d->tabList[index]);
Tab &tab = tabList[index];
QString oldText = tab.text; QString oldText = tab.text;
tab.text = computeElidedText(elideMode, oldText); tab.text = computeElidedText(d->elideMode, oldText);
QSize size = q->tabSizeHint(index); QSize size = tabSizeHint(index);
tab.text = oldText; tab.text = oldText;
return size; return size;
} }

View File

@ -178,6 +178,7 @@ Q_SIGNALS:
protected: protected:
virtual QSize tabSizeHint(int index) const; virtual QSize tabSizeHint(int index) const;
virtual QSize minimumTabSizeHint(int index) const;
virtual void tabInserted(int index); virtual void tabInserted(int index);
virtual void tabRemoved(int index); virtual void tabRemoved(int index);
virtual void tabLayoutChange(); virtual void tabLayoutChange();

View File

@ -165,8 +165,6 @@ public:
inline bool validIndex(int index) const { return index >= 0 && index < tabList.count(); } inline bool validIndex(int index) const { return index >= 0 && index < tabList.count(); }
void setCurrentNextEnabledIndex(int offset); void setCurrentNextEnabledIndex(int offset);
QSize minimumTabSizeHint(int index);
QToolButton* rightB; // right or bottom QToolButton* rightB; // right or bottom
QToolButton* leftB; // left or top QToolButton* leftB; // left or top