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
This commit is contained in:
Scott Kostyshak 2020-03-05 11:11:09 -05:00
parent c1357cbd01
commit 24926b2e23
5 changed files with 8 additions and 8 deletions

View File

@ -159,7 +159,7 @@ void BulletsModule::selectItem(int font, int character, bool select)
return; return;
QListWidget * lw = static_cast<QListWidget *>(bulletpaneSW->widget(font)); QListWidget * lw = static_cast<QListWidget *>(bulletpaneSW->widget(font));
lw->setItemSelected(lw->item(character), select); lw->item(character)->setSelected(select);
} }

View File

@ -144,7 +144,7 @@ void GuiBranches::updateView()
// restore selected branch // restore selected branch
if (bname == sel_branch) { if (bname == sel_branch) {
branchesTW->setCurrentItem(newItem); branchesTW->setCurrentItem(newItem);
branchesTW->setItemSelected(newItem, true); newItem->setSelected(true);
} }
} }
unknownPB->setEnabled(!unknown_branches_.isEmpty()); unknownPB->setEnabled(!unknown_branches_.isEmpty());

View File

@ -146,7 +146,7 @@ void GuiIndices::updateView()
// restore selected index // restore selected index
if (iname == sel_index) { if (iname == sel_index) {
indicesTW->setCurrentItem(newItem); indicesTW->setCurrentItem(newItem);
indicesTW->setItemSelected(newItem, true); newItem->setSelected(true);
} }
} }
indicesTW->resizeColumnToContents(0); indicesTW->resizeColumnToContents(0);

View File

@ -3245,7 +3245,7 @@ void PrefShortcuts::on_searchLE_textEdited()
// show all hidden items // show all hidden items
QTreeWidgetItemIterator it(shortcutsTW, QTreeWidgetItemIterator::Hidden); QTreeWidgetItemIterator it(shortcutsTW, QTreeWidgetItemIterator::Hidden);
for (; *it; ++it) for (; *it; ++it)
shortcutsTW->setItemHidden(*it, isAlwaysHidden(**it)); (*it)->setHidden(isAlwaysHidden(**it));
// close all categories // close all categories
for (int i = 0; i < shortcutsTW->topLevelItemCount(); ++i) for (int i = 0; i < shortcutsTW->topLevelItemCount(); ++i)
shortcutsTW->collapseItem(shortcutsTW->topLevelItem(i)); shortcutsTW->collapseItem(shortcutsTW->topLevelItem(i));
@ -3264,8 +3264,8 @@ void PrefShortcuts::on_searchLE_textEdited()
// show matched items // show matched items
for (int i = 0; i < matched.size(); ++i) for (int i = 0; i < matched.size(); ++i)
if (!isAlwaysHidden(*matched[i])) { if (!isAlwaysHidden(*matched[i])) {
shortcutsTW->setItemHidden(matched[i], false); matched[i]->setHidden(false);
shortcutsTW->setItemExpanded(matched[i]->parent(), true); matched[i]->parent()->setExpanded(true);
} }
} }
@ -3372,7 +3372,7 @@ void PrefShortcuts::shortcutOkPressed()
if (item) { if (item) {
user_bind_.bind(&k, func); user_bind_.bind(&k, func);
shortcutsTW->sortItems(0, Qt::AscendingOrder); shortcutsTW->sortItems(0, Qt::AscendingOrder);
shortcutsTW->setItemExpanded(item->parent(), true); item->parent()->setExpanded(true);
shortcutsTW->setCurrentItem(item); shortcutsTW->setCurrentItem(item);
shortcutsTW->scrollToItem(item); shortcutsTW->scrollToItem(item);
} else { } else {

View File

@ -545,7 +545,7 @@ void GuiRef::redoRefs()
while (*it) { while (*it) {
if ((*it)->text(0) == textToFind) { if ((*it)->text(0) == textToFind) {
refsTW->setCurrentItem(*it); refsTW->setCurrentItem(*it);
refsTW->setItemSelected(*it, true); (*it)->setSelected(true);
//Make sure selected item is visible //Make sure selected item is visible
refsTW->scrollToItem(*it); refsTW->scrollToItem(*it);
last_reference_ = textToFind; last_reference_ = textToFind;