Skip to content

Commit

Permalink
QtWidgets: mark obsolete functions as deprecated
Browse files Browse the repository at this point in the history
Mark some long obsolete functions as deprecated so the can be removed
with Qt6:
 - QLayout::margin()/setMargin()
 - QComboBox::autoCompletion()/setAutoCompletion()
 - QComboBox::autoCompletionCaseSensitivity()
 - QComboBox::setAutoCompletionCaseSensitivity()
 - QTextStream& operator<<(QTextStream&, const QSplitter&)
 - QTextStream& operator>>(QTextStream&, QSplitter&);

Change-Id: Ic16b36bf647413b5b3ea2d9105981b95370b3178
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
  • Loading branch information
chehrlic authored and liangqi committed Feb 6, 2019
1 parent 4715ca7 commit d6d33f0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
18 changes: 10 additions & 8 deletions src/widgets/kernel/qlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ bool QLayout::setAlignment(QLayout *l, Qt::Alignment alignment)
return false;
}

#if QT_DEPRECATED_SINCE(5, 13)
/*!
\property QLayout::margin
\brief the width of the outside border of the layout
Expand All @@ -306,6 +307,15 @@ int QLayout::margin() const
}
}

/*!
\obsolete
*/
void QLayout::setMargin(int margin)
{
setContentsMargins(margin, margin, margin, margin);
}

#endif
/*!
\property QLayout::spacing
\brief the spacing between widgets inside the layout
Expand Down Expand Up @@ -344,14 +354,6 @@ int QLayout::spacing() const
}
}

/*!
\obsolete
*/
void QLayout::setMargin(int margin)
{
setContentsMargins(margin, margin, margin, margin);
}

void QLayout::setSpacing(int spacing)
{
if (QBoxLayout* boxlayout = qobject_cast<QBoxLayout*>(this)) {
Expand Down
8 changes: 6 additions & 2 deletions src/widgets/kernel/qlayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ class Q_WIDGETS_EXPORT QLayout : public QObject, public QLayoutItem
Q_OBJECT
Q_DECLARE_PRIVATE(QLayout)

#if QT_DEPRECATED_SINCE(5, 13)
Q_PROPERTY(int margin READ margin WRITE setMargin)
#endif
Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
Q_PROPERTY(SizeConstraint sizeConstraint READ sizeConstraint WRITE setSizeConstraint)
public:
Expand All @@ -81,10 +83,12 @@ class Q_WIDGETS_EXPORT QLayout : public QObject, public QLayoutItem
QLayout();
~QLayout();

#if QT_DEPRECATED_SINCE(5, 13)
int margin() const;
int spacing() const;

void setMargin(int);
#endif

int spacing() const;
void setSpacing(int);

void setContentsMargins(int left, int top, int right, int bottom);
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/widgets/qcombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,7 @@ int QComboBox::maxCount() const
}

#if QT_CONFIG(completer)
#if QT_DEPRECATED_SINCE(5, 13)

/*!
\property QComboBox::autoCompletion
Expand Down Expand Up @@ -1576,6 +1577,7 @@ void QComboBox::setAutoCompletionCaseSensitivity(Qt::CaseSensitivity sensitivity
if (d->lineEdit && d->lineEdit->completer())
d->lineEdit->completer()->setCaseSensitivity(sensitivity);
}
#endif // QT_DEPRECATED_SINCE(5, 13)

#endif // QT_CONFIG(completer)

Expand Down
4 changes: 4 additions & 0 deletions src/widgets/widgets/qcombobox.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ class Q_WIDGETS_EXPORT QComboBox : public QWidget
Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)

#if QT_CONFIG(completer)
#if QT_DEPRECATED_SINCE(5, 13)
Q_PROPERTY(bool autoCompletion READ autoCompletion WRITE setAutoCompletion DESIGNABLE false)
Q_PROPERTY(Qt::CaseSensitivity autoCompletionCaseSensitivity READ autoCompletionCaseSensitivity WRITE setAutoCompletionCaseSensitivity DESIGNABLE false)
#endif
#endif // QT_CONFIG(completer)

Q_PROPERTY(bool duplicatesEnabled READ duplicatesEnabled WRITE setDuplicatesEnabled)
Expand All @@ -93,11 +95,13 @@ class Q_WIDGETS_EXPORT QComboBox : public QWidget
int maxCount() const;

#if QT_CONFIG(completer)
#if QT_DEPRECATED_SINCE(5, 13)
bool autoCompletion() const;
void setAutoCompletion(bool enable);

Qt::CaseSensitivity autoCompletionCaseSensitivity() const;
void setAutoCompletionCaseSensitivity(Qt::CaseSensitivity sensitivity);
#endif
#endif

bool duplicatesEnabled() const;
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/widgets/qsplitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,7 @@ void QSplitter::setStretchFactor(int index, int stretch)
}


#if QT_DEPRECATED_SINCE(5, 13)
/*!
\relates QSplitter
\obsolete
Expand Down Expand Up @@ -1813,6 +1814,7 @@ QTextStream& operator>>(QTextStream& ts, QSplitter& splitter)
splitter.restoreState(std::move(line).toLatin1());
return ts;
}
#endif

QT_END_NAMESPACE

Expand Down
4 changes: 4 additions & 0 deletions src/widgets/widgets/qsplitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,12 @@ class Q_WIDGETS_EXPORT QSplitter : public QFrame
friend class QSplitterHandle;
};

#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use QSplitter::saveState() instead")
Q_WIDGETS_EXPORT QTextStream& operator<<(QTextStream&, const QSplitter&);
QT_DEPRECATED_X("Use QSplitter::restoreState() instead")
Q_WIDGETS_EXPORT QTextStream& operator>>(QTextStream&, QSplitter&);
#endif

class QSplitterHandlePrivate;
class Q_WIDGETS_EXPORT QSplitterHandle : public QWidget
Expand Down

0 comments on commit d6d33f0

Please sign in to comment.