summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorDmitry Trofimov <dmitry.trofimov@nokia.com>2011-03-22 11:05:25 (GMT)
committerDmitry Trofimov <dmitry.trofimov@nokia.com>2011-03-22 11:21:02 (GMT)
commit7e26a493ecd1d77b1637a4c86b6f47fcce67a92c (patch)
tree66d69fdc84d2b2a0fcec2807371dcb50ad34d060 /src/gui/widgets
parente37d500cb1da388fbd53ae9e58548a59df29f598 (diff)
downloadQt-7e26a493ecd1d77b1637a4c86b6f47fcce67a92c.zip
Qt-7e26a493ecd1d77b1637a4c86b6f47fcce67a92c.tar.gz
Qt-7e26a493ecd1d77b1637a4c86b6f47fcce67a92c.tar.bz2
Revert "QComboBox fix for QTBUG-16985"
The commit has to be reverted due to introduced build break for non-Symbian platforms. This reverts commit 89660713717dcbd6126d6a38f911b7a90dff7ba7.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/qcombobox.cpp83
1 files changed, 46 insertions, 37 deletions
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index 0bfc03d..b5dda5a 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -7,11 +7,11 @@
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
-** Commercial Usage
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -25,16 +25,16 @@
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -116,7 +116,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
QPalette resolvedpalette = option.palette.resolve(QApplication::palette("QMenu"));
QVariant value = index.data(Qt::ForegroundRole);
- if (qVariantCanConvert<QBrush>(value)) {
+ if (value.canConvert<QBrush>()) {
resolvedpalette.setBrush(QPalette::WindowText, qvariant_cast<QBrush>(value));
resolvedpalette.setBrush(QPalette::ButtonText, qvariant_cast<QBrush>(value));
resolvedpalette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value));
@@ -152,7 +152,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
menuOption.icon = qvariant_cast<QPixmap>(variant);
break;
}
- if (qVariantCanConvert<QBrush>(index.data(Qt::BackgroundRole))) {
+ if (index.data(Qt::BackgroundRole).canConvert<QBrush>()) {
menuOption.palette.setBrush(QPalette::All, QPalette::Background,
qvariant_cast<QBrush>(index.data(Qt::BackgroundRole)));
}
@@ -369,6 +369,7 @@ void QComboBoxPrivateContainer::timerEvent(QTimerEvent *timerEvent)
if (timerEvent->timerId() == adjustSizeTimer.timerId()) {
adjustSizeTimer.stop();
if (combo->sizeAdjustPolicy() == QComboBox::AdjustToContents) {
+ combo->updateGeometry();
combo->adjustSize();
combo->update();
}
@@ -1088,6 +1089,8 @@ void QComboBoxPrivate::updateViewContainerPaletteAndOpacity()
container->setPalette(q->palette());
container->setWindowOpacity(1.0);
}
+ if (lineEdit)
+ lineEdit->setPalette(q->palette());
}
/*!
@@ -1298,7 +1301,7 @@ QComboBox::~QComboBox()
By default, this property has a value of 10.
\note This property is ignored for non-editable comboboxes in styles that returns
- false for QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style.
+ true for QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style.
*/
int QComboBox::maxVisibleItems() const
{
@@ -2008,11 +2011,18 @@ void QComboBox::setCurrentIndex(int index)
void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi)
{
Q_Q(QComboBox);
- bool indexChanged = (mi != currentIndex);
+
+ QModelIndex normalized;
+ if (mi.column() != modelColumn)
+ normalized = model->index(mi.row(), modelColumn, mi.parent());
+ if (!normalized.isValid())
+ normalized = mi; // Fallback to passed index.
+
+ bool indexChanged = (normalized != currentIndex);
if (indexChanged)
- currentIndex = QPersistentModelIndex(mi);
+ currentIndex = QPersistentModelIndex(normalized);
if (lineEdit) {
- QString newText = q->itemText(currentIndex.row());
+ QString newText = q->itemText(normalized.row());
if (lineEdit->text() != newText)
lineEdit->setText(newText);
updateLineEditGeometry();
@@ -2348,9 +2358,7 @@ void QComboBox::showPopup()
initStyleOption(&opt);
QRect listRect(style->subControlRect(QStyle::CC_ComboBox, &opt,
QStyle::SC_ComboBoxListBoxPopup, this));
- //QRect screen = d->popupGeometry(QApplication::desktop()->screenNumber(this));
- QRect screen = qt_TRect2QRect(static_cast<CEikAppUi*>(S60->appUi())->ClientRect());
-
+ QRect screen = d->popupGeometry(QApplication::desktop()->screenNumber(this));
QPoint below = mapToGlobal(listRect.bottomLeft());
int belowHeight = screen.bottom() - below.y();
QPoint above = mapToGlobal(listRect.topLeft());
@@ -2478,10 +2486,18 @@ void QComboBox::showPopup()
listRect.setWidth(listRect.height());
//by default popup is centered on screen in landscape
listRect.moveCenter(screen.center());
- if (staConTopRect.IsEmpty() && AknLayoutUtils::CbaLocation() != AknLayoutUtils::EAknCbaLocationBottom) {
- // landscape without stacon, menu should be at the right
- (opt.direction == Qt::LeftToRight) ? listRect.setRight(screen.right()) :
- listRect.setLeft(screen.left());
+ if (staConTopRect.IsEmpty()) {
+ TRect cbaRect = TRect();
+ AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane, cbaRect);
+ AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation();
+ switch (cbaLocation) {
+ case AknLayoutUtils::EAknCbaLocationRight:
+ listRect.setRight(screen.right());
+ break;
+ case AknLayoutUtils::EAknCbaLocationLeft:
+ listRect.setLeft(screen.left());
+ break;
+ }
}
}
#endif
@@ -2700,9 +2716,8 @@ void QComboBox::changeEvent(QEvent *e)
initStyleOption(&opt);
if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) {
- //const QRect screen = d->popupGeometry(QApplication::desktop()->screenNumber(this));
- QRect screen = qt_TRect2QRect(static_cast<CEikAppUi*>(S60->appUi())->ClientRect());
-
+ const QRect screen = d->popupGeometry(QApplication::desktop()->screenNumber(this));
+
QRect listRect(style()->subControlRect(QStyle::CC_ComboBox, &opt,
QStyle::SC_ComboBoxListBoxPopup, this));
listRect.setHeight(qMin(screen.height(), screen.width()));
@@ -2716,15 +2731,13 @@ void QComboBox::changeEvent(QEvent *e)
listRect.setWidth(listRect.height());
//by default popup is centered on screen in landscape
listRect.moveCenter(screen.center());
- if (staConTopRect.IsEmpty() && AknLayoutUtils::CbaLocation() != AknLayoutUtils::EAknCbaLocationBottom) {
+ if (staConTopRect.IsEmpty()) {
// landscape without stacon, menu should be at the right
(opt.direction == Qt::LeftToRight) ? listRect.setRight(screen.right()) :
listRect.setLeft(screen.left());
}
- //d->container->setGeometry(listRect);
+ d->container->setGeometry(listRect);
}
-
- d->container->setGeometry(listRect);
}
}
#endif
@@ -2757,10 +2770,6 @@ void QComboBox::changeEvent(QEvent *e)
void QComboBox::resizeEvent(QResizeEvent *)
{
Q_D(QComboBox);
-#ifdef Q_WS_S60
- if (d->viewContainer() && d->viewContainer()->isVisible())
- showPopup();
-#endif
d->updateLineEditGeometry();
}