From aa40680f66542c29742c8775982a549b1717e357 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 6 Feb 2019 09:37:12 +0100 Subject: Fix deprecation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Private/qquicktreemodeladaptor.cpp:744:52: warning: ‘void QList::swap(int, int) [with T = QQuickTreeModelAdaptor1::TreeItem]’ is deprecated: Use QList::swapItemsAt() [-Wdeprecated-declarations] Private/qquicktreemodeladaptor.cpp:750:52: warning: ‘void QList::swap(int, int) [with T = QQuickTreeModelAdaptor1::TreeItem]’ is deprecated: Use QList::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::swap(int, int) [with T = QQuickTreeModelAdaptor1::TreeItem]’ is deprecated: Use QList::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::swap(int, int) [with T = QQuickTreeModelAdaptor1::TreeItem]’ is deprecated: Use QList::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 --- src/controls/Private/qquickstyleitem.cpp | 11 ++++++----- src/controls/Private/qquicktreemodeladaptor.cpp | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src') 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(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(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(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; } -- cgit v1.2.1