QtWidgets: Fix deprecation warnings

Fix deprecation warnings where possible or add warnings scopes, fixing:

dialogs/qdialog.cpp:783:41: warning: ‘void QDialog::showExtension(bool)’ is deprecated [-Wdeprecated-declarations]                        ^~~~~~~~~~~~~
widgets/qcombobox.cpp:1386:37: warning: ‘void
QComboBox::currentIndexChanged(const QString&)’ is deprecated: Use currentTextChanged() instead [-Wdeprecated-declarations]=
dialogs/qfiledialog_p.h:168:38: warning: ‘DirectoryOnly’ is deprecated: Use setOption(ShowDirsOnly, true) instead [-Wdeprecated-declarations]
dialogs/qfiledialog.cpp:590:38: warning: ‘DirectoryOnly’ is deprecated: Use setOption(ShowDirsOnly, true) instead [-Wdeprecated-declarations]
dialogs/qfiledialog.cpp:617:27: warning: ‘DirectoryOnly’ is deprecated: Use setOption(ShowDirsOnly, true) instead [-Wdeprecated-declarations]
dialogs/qfiledialog.cpp:617:27: warning: ‘DirectoryOnly’ is deprecated: Use setOption(ShowDirsOnly, true) instead [-Wdeprecated-declarations]
dialogs/qfiledialog.cpp:645:27: warning: ‘DirectoryOnly’ is deprecated: Use setOption(ShowDirsOnly, true) instead [-Wdeprecated-declarations]
dialogs/qfiledialog.cpp:1730:17: warning: ‘DirectoryOnly’ is deprecated: Use setOption(ShowDirsOnly, true) instead [-Wdeprecated-declarations]
dialogs/qfiledialog.cpp:2637:43: warning: ‘DirectoryOnly’ is deprecated: Use setOption(ShowDirsOnly, true) instead [-Wdeprecated-declarations]
dialogs/qfiledialog.cpp:2750:10: warning: ‘DirectoryOnly’ is deprecated: Use setOption(ShowDirsOnly, true) instead [-Wdeprecated-declarations]
dialogs/qfiledialog.cpp:2786:49: warning: ‘bool QFileDialog::confirmOverwrite() const’ is deprecated: Use !testOption(DontConfirmOverwrite) instead [-Wdeprecated-declarations]
dialogs/qfiledialog.cpp:3654:27: warning: ‘DirectoryOnly’ is deprecated: Use setOption(ShowDirsOnly, true) instead [-Wdeprecated-declarations]
dialogs/qfiledialog.cpp:3843:48: warning: ‘DirectoryOnly’ is deprecated: Use setOption(ShowDirsOnly, true) instead [-Wdeprecated-declarations]
dialogs/qfiledialog.cpp:3895:72: warning: ‘DirectoryOnly’ is deprecated: Use setOption(ShowDirsOnly, true) instead [-Wdeprecated-declarations]
styles/qwindowsstyle.cpp:836:19: warning: ‘PE_IndicatorViewItemCheck’ is deprecated [-Wdeprecated-declarations]
graphicsview/qgraphicswidget.cpp:2309:51: warning: ‘PM_MDIFrameWidth’ is deprecated [-Wdeprecated-declarations]
styles/qstylesheetstyle.cpp:4302:10: warning: ‘PE_FrameStatusBar’ is deprecated [-Wdeprecated-declarations]
styles/qfusionstyle.cpp:3676:10: warning: ‘SH_ScrollBar_StopMouseOverSlider’ is deprecated [-Wdeprecated-declarations]

Change-Id: I9e15f4a0996476ec88d8823b72f0c537dce97b9c
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
Friedemann Kleint 2019-02-27 14:33:10 +01:00
parent 2065bc070d
commit f58e47c2f3
10 changed files with 53 additions and 18 deletions

View File

@ -780,7 +780,10 @@ void QDialog::setVisible(bool visible)
QWidget::setVisible(visible);
#if QT_DEPRECATED_SINCE(5, 13)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
showExtension(d->doShowExtension);
QT_WARNING_POP
#endif
QWidget *fw = window()->focusWidget();
if (!fw)

View File

@ -587,10 +587,13 @@ void QFileDialogPrivate::retranslateWindowTitle()
return;
if (q->acceptMode() == QFileDialog::AcceptOpen) {
const QFileDialog::FileMode fileMode = q->fileMode();
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
if (fileMode == QFileDialog::DirectoryOnly || fileMode == QFileDialog::Directory)
q->setWindowTitle(QFileDialog::tr("Find Directory"));
else
q->setWindowTitle(QFileDialog::tr("Open"));
QT_WARNING_POP
} else
q->setWindowTitle(QFileDialog::tr("Save As"));
@ -614,7 +617,10 @@ void QFileDialogPrivate::updateFileNameLabel()
setLabelTextControl(QFileDialog::FileName, options->labelText(QFileDialogOptions::FileName));
} else {
switch (q_func()->fileMode()) {
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
case QFileDialog::DirectoryOnly:
QT_WARNING_POP
case QFileDialog::Directory:
setLabelTextControl(QFileDialog::FileName, QFileDialog::tr("Directory:"));
break;
@ -642,7 +648,10 @@ void QFileDialogPrivate::updateOkButtonText(bool saveAsOnFolder)
return;
} else {
switch (q->fileMode()) {
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
case QFileDialog::DirectoryOnly:
QT_WARNING_POP
case QFileDialog::Directory:
setLabelTextControl(QFileDialog::Accept, QFileDialog::tr("&Choose"));
break;
@ -1709,7 +1718,10 @@ void QFileDialog::setFileMode(QFileDialog::FileMode mode)
d->options->setFileMode(static_cast<QFileDialogOptions::FileMode>(mode));
// keep ShowDirsOnly option in sync with fileMode (BTW, DirectoryOnly is obsolete)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
setOption(ShowDirsOnly, mode == DirectoryOnly);
QT_WARNING_POP
if (!d->usingWidgets())
return;
@ -1727,11 +1739,14 @@ void QFileDialog::setFileMode(QFileDialog::FileMode mode)
// set filter
d->model->setFilter(d->filterForMode(filter()));
// setup file type for directory
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
if (mode == DirectoryOnly || mode == Directory) {
d->qFileDialogUi->fileTypeCombo->clear();
d->qFileDialogUi->fileTypeCombo->addItem(tr("Directories"));
d->qFileDialogUi->fileTypeCombo->setEnabled(false);
}
QT_WARNING_POP
d->updateFileNameLabel();
d->updateOkButtonText();
d->qFileDialogUi->fileTypeCombo->setEnabled(!testOption(ShowDirsOnly));
@ -2634,7 +2649,10 @@ QUrl QFileDialog::getExistingDirectoryUrl(QWidget *parent,
args.parent = parent;
args.caption = caption;
args.directory = QFileDialogPrivate::workingDirectory(dir);
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
args.mode = (options & ShowDirsOnly ? DirectoryOnly : Directory);
QT_WARNING_POP
args.options = options;
QFileDialog dialog(args);
@ -2747,7 +2765,10 @@ void QFileDialog::accept()
}
switch (fileMode()) {
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
case DirectoryOnly:
QT_WARNING_POP
case Directory: {
QString fn = files.first();
QFileInfo info(fn);
@ -2783,7 +2804,7 @@ void QFileDialog::accept()
}
// check if we have to ask for permission to overwrite the file
if (!info.exists() || !confirmOverwrite() || acceptMode() == AcceptOpen) {
if (!info.exists() || testOption(DontConfirmOverwrite) || acceptMode() == AcceptOpen) {
d->emitFilesSelected(QStringList(fn));
QDialog::accept();
#if QT_CONFIG(messagebox)
@ -3651,7 +3672,10 @@ void QFileDialogPrivate::_q_updateOkButton()
isOpenDirectory = true;
} else {
switch (fileMode) {
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
case QFileDialog::DirectoryOnly:
QT_WARNING_POP
case QFileDialog::Directory: {
QString fn = files.first();
QModelIndex idx = model->index(fn);
@ -3743,12 +3767,15 @@ void QFileDialogPrivate::_q_enterDirectory(const QModelIndex &index)
const QFileDialog::FileMode fileMode = q->fileMode();
q->setDirectory(path);
emit q->directoryEntered(path);
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
if (fileMode == QFileDialog::Directory
|| fileMode == QFileDialog::DirectoryOnly) {
// ### find out why you have to do both of these.
lineEdit()->setText(QString());
lineEdit()->clear();
}
QT_WARNING_POP
} else {
// Do not accept when shift-clicking to multi-select a file in environments with single-click-activation (KDE)
if (!q->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, nullptr, qFileDialogUi->treeView)
@ -3840,7 +3867,10 @@ void QFileDialogPrivate::_q_selectionChanged()
{
const QFileDialog::FileMode fileMode = q_func()->fileMode();
const QModelIndexList indexes = qFileDialogUi->listView->selectionModel()->selectedRows();
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
bool stripDirs = (fileMode != QFileDialog::DirectoryOnly && fileMode != QFileDialog::Directory);
QT_WARNING_POP
QStringList allFiles;
for (const auto &index : indexes) {
@ -3892,10 +3922,13 @@ void QFileDialogPrivate::_q_rowsInserted(const QModelIndex &parent)
void QFileDialogPrivate::_q_fileRenamed(const QString &path, const QString &oldName, const QString &newName)
{
const QFileDialog::FileMode fileMode = q_func()->fileMode();
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
if (fileMode == QFileDialog::Directory || fileMode == QFileDialog::DirectoryOnly) {
if (path == rootPath() && lineEdit()->text() == oldName)
lineEdit()->setText(newName);
}
QT_WARNING_POP
}
void QFileDialogPrivate::_q_emitUrlSelected(const QUrl &file)

View File

@ -164,13 +164,9 @@ public:
QDir::Filters filterForMode(QDir::Filters filters) const
{
const QFileDialog::FileMode fileMode = q_func()->fileMode();
if (fileMode == QFileDialog::DirectoryOnly) {
filters |= QDir::Drives | QDir::AllDirs | QDir::Dirs;
filters |= QDir::Drives | QDir::AllDirs | QDir::Dirs | QDir::Files;
if (q_func()->testOption(QFileDialog::ShowDirsOnly))
filters &= ~QDir::Files;
} else {
filters |= QDir::Drives | QDir::AllDirs | QDir::Files | QDir::Dirs;
}
return filters;
}

View File

@ -2306,7 +2306,7 @@ void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGrap
QStyleHintReturnMask mask;
bool setMask = style()->styleHint(QStyle::SH_WindowFrame_Mask, &bar, widget, &mask) && !mask.region.isEmpty();
bool hasBorder = !style()->styleHint(QStyle::SH_TitleBar_NoBorder, &bar, widget);
int frameWidth = style()->pixelMetric(QStyle::PM_MDIFrameWidth, &bar, widget);
int frameWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, &bar, widget);
if (setMask) {
painter->save();
painter->setClipRegion(mask.region, Qt::IntersectClip);

View File

@ -789,7 +789,7 @@ void QItemDelegate::drawCheck(QPainter *painter,
const QWidget *widget = d->widget(option);
QStyle *style = widget ? widget->style() : QApplication::style();
style->drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &opt, painter, widget);
style->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck, &opt, painter, widget);
}
/*!

View File

@ -194,7 +194,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
opt->state & (State_Sunken | State_On), 1,
&opt->palette.brush(QPalette::Button));
break;
case PE_IndicatorViewItemCheck:
case PE_IndicatorItemViewItemCheck:
proxy()->drawPrimitive(PE_IndicatorCheckBox, opt, p, widget);
break;
case PE_IndicatorCheckBox:
@ -2283,7 +2283,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
option.state |= QStyle::State_On;
break;
}
proxy()->drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, p, widget);
proxy()->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck, &option, p, widget);
}
// draw the icon

View File

@ -558,7 +558,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem,
qt_fusion_draw_arrow(arrow, painter, option, option->rect, arrowColor);
}
break;
case PE_IndicatorViewItemCheck:
case PE_IndicatorItemViewItemCheck:
{
QStyleOptionButton button;
button.QStyleOption::operator=(*option);
@ -3673,7 +3673,7 @@ int QFusionStyle::styleHint(StyleHint hint, const QStyleOption *option, const QW
case SH_FontDialog_SelectAssociatedText:
case SH_MenuBar_AltKeyNavigation:
case SH_ComboBox_ListMouseTracking:
case SH_ScrollBar_StopMouseOverSlider:
case SH_Slider_StopMouseOverSlider:
case SH_ScrollBar_MiddleClickAbsolutePosition:
case SH_EtchDisabledText:
case SH_TitleBar_AutoRaise:

View File

@ -4299,7 +4299,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
switch (pe) {
case PE_FrameStatusBar: {
case PE_FrameStatusBarItem: {
QRenderRule subRule = renderRule(w ? w->parentWidget() : nullptr, opt, PseudoElement_Item);
if (subRule.hasDrawable()) {
subRule.drawRule(p, opt->rect);
@ -4320,7 +4320,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
pseudoElement = PseudoElement_ExclusiveIndicator;
break;
case PE_IndicatorViewItemCheck:
case PE_IndicatorItemViewItemCheck:
pseudoElement = PseudoElement_ViewItemIndicator;
break;

View File

@ -554,7 +554,7 @@ int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWid
case SH_MenuBar_MouseTracking:
case SH_Menu_MouseTracking:
case SH_ComboBox_ListMouseTracking:
case SH_ScrollBar_StopMouseOverSlider:
case SH_Slider_StopMouseOverSlider:
case SH_MainWindow_SpaceBelowMenuBar:
ret = 1;
@ -827,13 +827,13 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
p->setPen(opt->palette.text().color());
}
Q_FALLTHROUGH();
case PE_IndicatorViewItemCheck:
case PE_IndicatorItemViewItemCheck:
if (!doRestore) {
p->save();
doRestore = true;
}
#if QT_CONFIG(itemviews)
if (pe == PE_IndicatorViewItemCheck) {
if (pe == PE_IndicatorItemViewItemCheck) {
const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt);
p->setPen(itemViewOpt
&& itemViewOpt->showDecorationSelected

View File

@ -1383,7 +1383,10 @@ void QComboBoxPrivate::_q_emitCurrentIndexChanged(const QModelIndex &index)
const QString text = itemText(index);
emit q->currentIndexChanged(index.row());
#if QT_DEPRECATED_SINCE(5, 13)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
emit q->currentIndexChanged(text);
QT_WARNING_POP
#endif
// signal lineEdit.textChanged already connected to signal currentTextChanged, so don't emit double here
if (!lineEdit)