remove pre 4.3 layout restoration code

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2019-05-29 22:12:55 +00:00
parent d07f9949ba
commit faa778989e
5 changed files with 18 additions and 34 deletions

View file

@ -175,7 +175,6 @@ public:
protected:
int metric(PaintDeviceMetric) const;
private:
QExplicitlySharedDataPointer<QPixmapData> data;

View file

@ -611,12 +611,8 @@ static QList<T> findChildrenHelper(const QObject *o)
return result;
}
//pre4.3 tests the format that was used before 4.3
bool QMainWindowLayoutState::checkFormat(QDataStream &stream, bool pre43)
bool QMainWindowLayoutState::checkFormat(QDataStream &stream)
{
#ifdef QT_NO_TOOLBAR
Q_UNUSED(pre43);
#endif
while (!stream.atEnd()) {
uchar marker;
stream >> marker;
@ -628,7 +624,7 @@ bool QMainWindowLayoutState::checkFormat(QDataStream &stream, bool pre43)
{
QList<QToolBar *> toolBars = findChildrenHelper<QToolBar*>(mainWindow);
if (!toolBarAreaLayout.restoreState(stream, toolBars, marker,
pre43 /*testing 4.3 format*/, true /*testing*/)) {
true /*testing*/)) {
return false;
}
}
@ -669,14 +665,9 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
}
QDataStream ds(copy);
const bool oldFormat = !checkFormat(ds, false);
if (oldFormat) {
//we should try with the old format
QDataStream ds2(copy);
if (!checkFormat(ds2, true)) {
if (!checkFormat(ds)) {
return false; //format unknown
}
}
QDataStream stream(copy);
@ -716,7 +707,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
case QToolBarAreaLayout::ToolBarStateMarkerEx:
{
QList<QToolBar *> toolBars = findChildrenHelper<QToolBar*>(mainWindow);
if (!toolBarAreaLayout.restoreState(stream, toolBars, marker, oldFormat))
if (!toolBarAreaLayout.restoreState(stream, toolBars, marker))
return false;
for (int i = 0; i < toolBars.size(); ++i) {
@ -1474,7 +1465,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
#ifndef QT_NO_TOOLBAR
if (QToolBar *tb = qobject_cast<QToolBar*>(widget)) {
QToolBarLayout *tbl = qobject_cast<QToolBarLayout*>(tb->layout());
if (tbl->animating) {
if (tbl && tbl->animating) {
tbl->animating = false;
if (tbl->expanded)
tbl->layoutActions(tb->size());
@ -1503,7 +1494,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
#ifndef QT_NO_DOCKWIDGET
#ifndef QT_NO_TABBAR
if (qobject_cast<QDockWidget*>(widget) != 0) {
if (qobject_cast<QDockWidget*>(widget)) {
// info() might return null if the widget is destroyed while
// animating but before the animationFinished signal is received.
if (QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(widget))

View file

@ -138,7 +138,7 @@ public:
QLayoutItem *unplug(const QList<int> &path, QMainWindowLayoutState *savedState = 0);
void saveState(QDataStream &stream) const;
bool checkFormat(QDataStream &stream, bool pre43);
bool checkFormat(QDataStream &stream);
bool restoreState(QDataStream &stream, const QMainWindowLayoutState &oldState);
};

View file

@ -1291,21 +1291,15 @@ void QToolBarAreaLayout::saveState(QDataStream &stream) const
}
}
static inline int getInt(QDataStream &stream, Qt::Orientation o, bool pre43)
static inline int getInt(QDataStream &stream)
{
if (pre43) {
QPoint p;
stream >> p;
return pick(o, p);
} else {
int x;
stream >> x;
return x;
}
}
bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*> &_toolBars, uchar tmarker, bool pre43, bool testing)
bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*> &_toolBars, uchar tmarker, bool testing)
{
QList<QToolBar*> toolBars = _toolBars;
int lines;
@ -1330,8 +1324,8 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
stream >> objectName;
uchar shown;
stream >> shown;
item.pos = getInt(stream, dock.o, pre43);
item.size = getInt(stream, dock.o, pre43);
item.pos = getInt(stream);
item.size = getInt(stream);
/*
4.3.0 added floating toolbars, but failed to add the ability to restore them.
@ -1344,9 +1338,9 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
QRect rect;
bool floating = false;
uint geom0, geom1;
geom0 = getInt(stream, dock.o, pre43);
geom0 = getInt(stream);
if (tmarker == ToolBarStateMarkerEx) {
geom1 = getInt(stream, dock.o, pre43);
geom1 = getInt(stream);
rect = unpackRect(geom0, geom1, &floating);
}

View file

@ -238,7 +238,7 @@ public:
QLayoutItem *unplug(const QList<int> &path, QToolBarAreaLayout *other);
void saveState(QDataStream &stream) const;
bool restoreState(QDataStream &stream, const QList<QToolBar*> &toolBars, uchar tmarker, bool pre43, bool testing = false);
bool restoreState(QDataStream &stream, const QList<QToolBar*> &toolBars, uchar tmarker, bool testing = false);
bool isEmpty() const;
};