summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qstackedwidget.cpp46
-rw-r--r--src/widgets/widgets/qtabbar.cpp20
-rw-r--r--src/widgets/widgets/qtabbar.h1
-rw-r--r--src/widgets/widgets/qtabbar_p.h2
4 files changed, 15 insertions, 54 deletions
diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp
index 9617d6de58..5406f5dcf5 100644
--- a/src/widgets/widgets/qstackedwidget.cpp
+++ b/src/widgets/widgets/qstackedwidget.cpp
@@ -49,54 +49,12 @@
QT_BEGIN_NAMESPACE
-/**
- QStackedLayout does not support height for width (simply because it does not reimplement
- heightForWidth() and hasHeightForWidth()). That is not possible to fix without breaking
- binary compatibility. (QLayout is subject to multiple inheritance).
- However, we can fix QStackedWidget by simply using a modified version of QStackedLayout
- that reimplements the hfw-related functions:
- */
-class QStackedLayoutHFW : public QStackedLayout
-{
-public:
- QStackedLayoutHFW(QWidget *parent = 0) : QStackedLayout(parent) {}
- bool hasHeightForWidth() const;
- int heightForWidth(int width) const;
-};
-
-bool QStackedLayoutHFW::hasHeightForWidth() const
-{
- const int n = count();
-
- for (int i = 0; i < n; ++i) {
- if (QLayoutItem *item = itemAt(i)) {
- if (item->hasHeightForWidth())
- return true;
- }
- }
- return false;
-}
-
-int QStackedLayoutHFW::heightForWidth(int width) const
-{
- const int n = count();
-
- int hfw = 0;
- for (int i = 0; i < n; ++i) {
- if (QLayoutItem *item = itemAt(i)) {
- hfw = qMax(hfw, item->heightForWidth(width));
- }
- }
- return hfw;
-}
-
-
class QStackedWidgetPrivate : public QFramePrivate
{
Q_DECLARE_PUBLIC(QStackedWidget)
public:
QStackedWidgetPrivate():layout(0){}
- QStackedLayoutHFW *layout;
+ QStackedLayout *layout;
bool blockChildAdd;
};
@@ -180,7 +138,7 @@ QStackedWidget::QStackedWidget(QWidget *parent)
: QFrame(*new QStackedWidgetPrivate, parent)
{
Q_D(QStackedWidget);
- d->layout = new QStackedLayoutHFW(this);
+ d->layout = new QStackedLayout(this);
connect(d->layout, SIGNAL(widgetRemoved(int)), this, SIGNAL(widgetRemoved(int)));
connect(d->layout, SIGNAL(currentChanged(int)), this, SIGNAL(currentChanged(int)));
}
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<QTabBarPrivate::Tab&>(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