[LyX/master] Fix a few deprecation warnings in Qt 5.14.1
Scott Kostyshak
skostysh at lyx.org
Thu Mar 5 16:04:52 UTC 2020
commit 24926b2e2399624ca6a1290349e9070a0d880dee
Author: Scott Kostyshak <skostysh at lyx.org>
Date: Thu Mar 5 11:11:09 2020 -0500
Fix a few deprecation warnings in Qt 5.14.1
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 5cbca09..ef21bd9 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<QListWidget *>(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 ab91587..b1ef8be 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 7c7a610..5e145f5 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 91aa3f6..7d269bc 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 0c6b12d..6f3a342 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;
More information about the lyx-cvs
mailing list