From 24926b2e2399624ca6a1290349e9070a0d880dee Mon Sep 17 00:00:00 2001 From: Scott Kostyshak Date: Thu, 5 Mar 2020 11:11:09 -0500 Subject: [PATCH] Fix a few deprecation warnings in Qt 5.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit These changes fix a few instances of the following type of warning: error: ‘void QListWidget::setItemSelected(const QListWidgetItem*, bool)’ is deprecated: Use QListWidgetItem::setSelected() instead [-Werror=deprecated-declarations] as well as similar warnings for setItemHidden() and setItemExpanded(). These are just warnings now, but it is planned to remove the methods for Qt 6: https://bugreports.qt.io/browse/QTBUG-73048 I tested that LyX can still be built against Qt 4.8.7 with this commit. Indeed, these methods have been deprecated for a while (it is just that QT_DEPRECATED_WARNINGS was only turned on by default starting with 5.13.0). See, e.g., https://doc.qt.io/archives/qt-4.7/qlistwidget-obsolete.html --- src/frontends/qt/BulletsModule.cpp | 2 +- src/frontends/qt/GuiBranches.cpp | 2 +- src/frontends/qt/GuiIndices.cpp | 2 +- src/frontends/qt/GuiPrefs.cpp | 8 ++++---- src/frontends/qt/GuiRef.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/frontends/qt/BulletsModule.cpp b/src/frontends/qt/BulletsModule.cpp index 5cbca093e8..ef21bd9723 100644 --- a/src/frontends/qt/BulletsModule.cpp +++ b/src/frontends/qt/BulletsModule.cpp @@ -159,7 +159,7 @@ void BulletsModule::selectItem(int font, int character, bool select) return; QListWidget * lw = static_cast(bulletpaneSW->widget(font)); - lw->setItemSelected(lw->item(character), select); + lw->item(character)->setSelected(select); } diff --git a/src/frontends/qt/GuiBranches.cpp b/src/frontends/qt/GuiBranches.cpp index ab91587098..b1ef8be307 100644 --- a/src/frontends/qt/GuiBranches.cpp +++ b/src/frontends/qt/GuiBranches.cpp @@ -144,7 +144,7 @@ void GuiBranches::updateView() // restore selected branch if (bname == sel_branch) { branchesTW->setCurrentItem(newItem); - branchesTW->setItemSelected(newItem, true); + newItem->setSelected(true); } } unknownPB->setEnabled(!unknown_branches_.isEmpty()); diff --git a/src/frontends/qt/GuiIndices.cpp b/src/frontends/qt/GuiIndices.cpp index 7c7a61014a..5e145f56eb 100644 --- a/src/frontends/qt/GuiIndices.cpp +++ b/src/frontends/qt/GuiIndices.cpp @@ -146,7 +146,7 @@ void GuiIndices::updateView() // restore selected index if (iname == sel_index) { indicesTW->setCurrentItem(newItem); - indicesTW->setItemSelected(newItem, true); + newItem->setSelected(true); } } indicesTW->resizeColumnToContents(0); diff --git a/src/frontends/qt/GuiPrefs.cpp b/src/frontends/qt/GuiPrefs.cpp index 91aa3f67f9..7d269bc104 100644 --- a/src/frontends/qt/GuiPrefs.cpp +++ b/src/frontends/qt/GuiPrefs.cpp @@ -3245,7 +3245,7 @@ void PrefShortcuts::on_searchLE_textEdited() // show all hidden items QTreeWidgetItemIterator it(shortcutsTW, QTreeWidgetItemIterator::Hidden); for (; *it; ++it) - shortcutsTW->setItemHidden(*it, isAlwaysHidden(**it)); + (*it)->setHidden(isAlwaysHidden(**it)); // close all categories for (int i = 0; i < shortcutsTW->topLevelItemCount(); ++i) shortcutsTW->collapseItem(shortcutsTW->topLevelItem(i)); @@ -3264,8 +3264,8 @@ void PrefShortcuts::on_searchLE_textEdited() // show matched items for (int i = 0; i < matched.size(); ++i) if (!isAlwaysHidden(*matched[i])) { - shortcutsTW->setItemHidden(matched[i], false); - shortcutsTW->setItemExpanded(matched[i]->parent(), true); + matched[i]->setHidden(false); + matched[i]->parent()->setExpanded(true); } } @@ -3372,7 +3372,7 @@ void PrefShortcuts::shortcutOkPressed() if (item) { user_bind_.bind(&k, func); shortcutsTW->sortItems(0, Qt::AscendingOrder); - shortcutsTW->setItemExpanded(item->parent(), true); + item->parent()->setExpanded(true); shortcutsTW->setCurrentItem(item); shortcutsTW->scrollToItem(item); } else { diff --git a/src/frontends/qt/GuiRef.cpp b/src/frontends/qt/GuiRef.cpp index 0c6b12d462..6f3a34258e 100644 --- a/src/frontends/qt/GuiRef.cpp +++ b/src/frontends/qt/GuiRef.cpp @@ -545,7 +545,7 @@ void GuiRef::redoRefs() while (*it) { if ((*it)->text(0) == textToFind) { refsTW->setCurrentItem(*it); - refsTW->setItemSelected(*it, true); + (*it)->setSelected(true); //Make sure selected item is visible refsTW->scrollToItem(*it); last_reference_ = textToFind; -- 2.39.2