summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
diff options
context:
space:
mode:
authorThorbjørn Lund Martsum <tmartsum@gmail.com>2012-03-16 07:00:45 +0100
committerQt by Nokia <qt-info@nokia.com>2012-04-13 10:17:44 +0200
commit03dbba9a62ea6391639c54ccc89ea75d4a872597 (patch)
treef006bc6f19e616d585a0966ac8d84c8bc439c91e /src/widgets/kernel
parentaec8bac3130c3c11333978b89c9fc5cf586c9bd0 (diff)
QLayoutItem - make controlTypes a virtual function.
Just implementing the ### Qt5 suggestion about making controlTypes a virtual function. Change-Id: Ic1db47fe488f089de965438e456e9b48e0b96f32 Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r--src/widgets/kernel/qlayout.cpp13
-rw-r--r--src/widgets/kernel/qlayout.h1
-rw-r--r--src/widgets/kernel/qlayoutitem.cpp16
-rw-r--r--src/widgets/kernel/qlayoutitem.h4
4 files changed, 21 insertions, 13 deletions
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index 541350c35c..8c4e988411 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -527,6 +527,19 @@ bool QLayout::isEmpty() const
/*!
\reimp
*/
+QSizePolicy::ControlTypes QLayout::controlTypes() const
+{
+ if (count() == 0)
+ return QSizePolicy::DefaultType;
+ QSizePolicy::ControlTypes types;
+ for (int i = count() - 1; i >= 0; --i)
+ types |= itemAt(i)->controlTypes();
+ return types;
+}
+
+/*!
+ \reimp
+*/
void QLayout::setGeometry(const QRect &r)
{
Q_D(QLayout);
diff --git a/src/widgets/kernel/qlayout.h b/src/widgets/kernel/qlayout.h
index 5524443ab1..9a13922cb1 100644
--- a/src/widgets/kernel/qlayout.h
+++ b/src/widgets/kernel/qlayout.h
@@ -131,6 +131,7 @@ public:
virtual int indexOf(QWidget *) const;
virtual int count() const = 0;
bool isEmpty() const;
+ QSizePolicy::ControlTypes controlTypes() const;
int totalHeightForWidth(int w) const;
QSize totalMinimumSize() const;
diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp
index 814b807b82..8e08f5f39f 100644
--- a/src/widgets/kernel/qlayoutitem.cpp
+++ b/src/widgets/kernel/qlayoutitem.cpp
@@ -414,17 +414,6 @@ int QLayoutItem::heightForWidth(int /* w */) const
*/
QSizePolicy::ControlTypes QLayoutItem::controlTypes() const
{
- // ### Qt 5: This function should probably be virtual instead
- if (const QWidget *widget = const_cast<QLayoutItem*>(this)->widget()) {
- return widget->sizePolicy().controlType();
- } else if (const QLayout *layout = const_cast<QLayoutItem*>(this)->layout()) {
- if (layout->count() == 0)
- return QSizePolicy::DefaultType;
- QSizePolicy::ControlTypes types;
- for (int i = layout->count() - 1; i >= 0; --i)
- types |= layout->itemAt(i)->controlTypes();
- return types;
- }
return QSizePolicy::DefaultType;
}
@@ -688,6 +677,11 @@ bool QWidgetItem::isEmpty() const
return wid->isHidden() || wid->isWindow();
}
+QSizePolicy::ControlTypes QWidgetItem::controlTypes() const
+{
+ return wid->sizePolicy().controlType();
+}
+
/*!
\class QWidgetItemV2
\internal
diff --git a/src/widgets/kernel/qlayoutitem.h b/src/widgets/kernel/qlayoutitem.h
index 76aae6f794..dacbf1ea68 100644
--- a/src/widgets/kernel/qlayoutitem.h
+++ b/src/widgets/kernel/qlayoutitem.h
@@ -83,7 +83,7 @@ public:
Qt::Alignment alignment() const { return align; }
void setAlignment(Qt::Alignment a);
- QSizePolicy::ControlTypes controlTypes() const;
+ virtual QSizePolicy::ControlTypes controlTypes() const;
protected:
Qt::Alignment align;
@@ -135,7 +135,7 @@ public:
bool hasHeightForWidth() const;
int heightForWidth(int) const;
-
+ QSizePolicy::ControlTypes controlTypes() const;
protected:
QWidget *wid;
};