summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-02-06 09:37:12 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-02-06 16:05:32 +0000
commitaa40680f66542c29742c8775982a549b1717e357 (patch)
treea92ce67c598aaa1353780de03a777b72cc882afe
parent352aeb96a52590aff91e3f6a1e03c65418d596d3 (diff)
downloadqtquickcontrols-aa40680f66542c29742c8775982a549b1717e357.tar.gz
Fix deprecation warnings
Private/qquicktreemodeladaptor.cpp:744:52: warning: ‘void QList<T>::swap(int, int) [with T = QQuickTreeModelAdaptor1::TreeItem]’ is deprecated: Use QList<T>::swapItemsAt() [-Wdeprecated-declarations] Private/qquicktreemodeladaptor.cpp:750:52: warning: ‘void QList<T>::swap(int, int) [with T = QQuickTreeModelAdaptor1::TreeItem]’ is deprecated: Use QList<T>::swapItemsAt() [-Wdeprecated-declarations] Private/qquickstyleitem.cpp:922:89: warning: ‘int QFontMetrics::width(QChar) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations] In file included from /data1/frkleint/qt-513/qtbase/include/QtGui/qfontmetrics.h:1:0, Private/qquickstyleitem.cpp:942:60: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations] Private/qquickstyleitem.cpp:961:75: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations] Private/qquickstyleitem.cpp:1010:52: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations] Private/qquickstyleitem.cpp:1010:86: warning: ‘int QFontMetrics::width(QChar) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations] Private/qquickstyleitem.cpp:1469:46: warning: ‘static bool QPixmapCache::find(const QString&, QPixmap&)’ is deprecated: Use bool find(const QString &, QPixmap *) instead [-Wdeprecated-declarations] ../../../src/controls/Private/qquicktreemodeladaptor.cpp:744:52: warning: ‘void QList<T>::swap(int, int) [with T = QQuickTreeModelAdaptor1::TreeItem]’ is deprecated: Use QList<T>::swapItemsAt() [-Wdeprecated-declarations]/data1/frkleint/qt-513/qtbase/include/QtCore/../../src/corelib/tools/qlist.h:227:10: note: declared here ../../../src/controls/Private/qquicktreemodeladaptor.cpp:750:52: warning: ‘void QList<T>::swap(int, int) [with T = QQuickTreeModelAdaptor1::TreeItem]’ is deprecated: Use QList<T>::swapItemsAt() [-Wdeprecated-declarations] tst_qquicktreemodeladaptor.cpp:1387:39: warning: ‘QModelIndex QModelIndex::child(int, int) const’ is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations] Change-Id: I213d7ffd2cb329b542f9273e3a566a813d1cc24f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/controls/Private/qquickstyleitem.cpp11
-rw-r--r--src/controls/Private/qquicktreemodeladaptor.cpp4
-rw-r--r--tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp2
3 files changed, 9 insertions, 8 deletions
diff --git a/src/controls/Private/qquickstyleitem.cpp b/src/controls/Private/qquickstyleitem.cpp
index 1e53fa69..f9596d35 100644
--- a/src/controls/Private/qquickstyleitem.cpp
+++ b/src/controls/Private/qquickstyleitem.cpp
@@ -919,7 +919,7 @@ QSize QQuickStyleItem1::sizeFromContents(int width, int height)
}
if (btn->toolButtonStyle != Qt::ToolButtonIconOnly) {
QSize textSize = btn->fontMetrics.size(Qt::TextShowMnemonic, btn->text);
- textSize.setWidth(textSize.width() + btn->fontMetrics.width(QLatin1Char(' '))*2);
+ textSize.setWidth(textSize.width() + btn->fontMetrics.horizontalAdvance(QLatin1Char(' '))*2);
if (btn->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
h += 4 + textSize.height();
if (textSize.width() > w)
@@ -939,7 +939,7 @@ QSize QQuickStyleItem1::sizeFromContents(int width, int height)
case Button: {
QStyleOptionButton *btn = qstyleoption_cast<QStyleOptionButton*>(m_styleoption);
- int contentWidth = btn->fontMetrics.width(btn->text);
+ int contentWidth = btn->fontMetrics.horizontalAdvance(btn->text);
int contentHeight = btn->fontMetrics.height();
if (!btn->icon.isNull()) {
//+4 matches a hardcoded value in QStyle and acts as a margin between the icon and the text.
@@ -958,7 +958,7 @@ QSize QQuickStyleItem1::sizeFromContents(int width, int height)
break;
case ComboBox: {
QStyleOptionComboBox *btn = qstyleoption_cast<QStyleOptionComboBox*>(m_styleoption);
- int newWidth = qMax(width, btn->fontMetrics.width(btn->currentText));
+ int newWidth = qMax(width, btn->fontMetrics.horizontalAdvance(btn->currentText));
int newHeight = qMax(height, btn->fontMetrics.height());
size = qApp->style()->sizeFromContents(QStyle::CT_ComboBox, m_styleoption, QSize(newWidth, newHeight)); }
break;
@@ -1007,7 +1007,8 @@ QSize QQuickStyleItem1::sizeFromContents(int width, int height)
case GroupBox: {
QStyleOptionGroupBox *box = qstyleoption_cast<QStyleOptionGroupBox*>(m_styleoption);
QFontMetrics metrics(box->fontMetrics);
- int baseWidth = metrics.width(box->text) + metrics.width(QLatin1Char(' '));
+ int baseWidth = metrics.horizontalAdvance(box->text)
+ + metrics.horizontalAdvance(QLatin1Char(' '));
int baseHeight = metrics.height() + m_contentHeight;
if (box->subControls & QStyle::SC_GroupBoxCheckBox) {
baseWidth += qApp->style()->pixelMetric(QStyle::PM_IndicatorWidth);
@@ -1466,7 +1467,7 @@ void QQuickStyleItem1::paint(QPainter *painter)
QPixmap pixmap;
// Only draw through style once
const QString pmKey = QLatin1Literal("itemrow") % QString::number(m_styleoption->state,16) % activeControl();
- if (!QPixmapCache::find(pmKey, pixmap) || pixmap.width() < width() || height() != pixmap.height()) {
+ if (!QPixmapCache::find(pmKey, &pixmap) || pixmap.width() < width() || height() != pixmap.height()) {
int newSize = width();
pixmap = QPixmap(newSize, height());
pixmap.fill(Qt::transparent);
diff --git a/src/controls/Private/qquicktreemodeladaptor.cpp b/src/controls/Private/qquicktreemodeladaptor.cpp
index 287b388f..c2c36494 100644
--- a/src/controls/Private/qquicktreemodeladaptor.cpp
+++ b/src/controls/Private/qquicktreemodeladaptor.cpp
@@ -741,13 +741,13 @@ void QQuickTreeModelAdaptor1::modelRowsAboutToBeMoved(const QModelIndex & source
int bufferCopyOffset;
if (destIndex > endIndex) {
for (int i = endIndex + 1; i < destIndex; i++) {
- m_items.swap(i, i - totalMovedCount); // Fast move from 1st to 2nd position
+ m_items.swapItemsAt(i, i - totalMovedCount); // Fast move from 1st to 2nd position
}
bufferCopyOffset = destIndex - totalMovedCount;
} else {
// NOTE: we will not enter this loop if startIndex == destIndex
for (int i = startIndex - 1; i >= destIndex; i--) {
- m_items.swap(i, i + totalMovedCount); // Fast move from 1st to 2nd position
+ m_items.swapItemsAt(i, i + totalMovedCount); // Fast move from 1st to 2nd position
}
bufferCopyOffset = destIndex;
}
diff --git a/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp b/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp
index 96659a2c..0fec548d 100644
--- a/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp
+++ b/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp
@@ -1384,7 +1384,7 @@ void tst_QQuickTreeModelAdaptor::hasChildrenEmit()
QModelIndex root = model.index(0,0);
QVERIFY(root.isValid());
- QModelIndex child = root.child(0,0);
+ QModelIndex child = model.index(0, 0, root);
QVERIFY(child.isValid());
// Root not expanded , child not expanded, insert in child, expect no datachanged