From 17e5b577b0a18d0612ddce3d8f26a09049b38a15 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 28 Mar 2014 13:54:13 +0100 Subject: [PATCH] Cleanup: Remove some obsolete code supporting a pre-4.3 format Loading a dock window state saved by a Qt 4.2 app is not something we need to support anymore. Change-Id: I9ee6e2c742b31114081852e7236cfc8696b9b270 Reviewed-by: Paul Olav Tvete --- src/widgets/widgets/qmainwindowlayout.cpp | 20 +++++------------- src/widgets/widgets/qmainwindowlayout_p.h | 2 +- src/widgets/widgets/qtoolbararealayout.cpp | 24 ++++++++-------------- src/widgets/widgets/qtoolbararealayout_p.h | 2 +- 4 files changed, 16 insertions(+), 32 deletions(-) diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 43f168ecd8..1cc7f201ba 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -615,11 +615,8 @@ static QList findChildrenHelper(const QObject *o) } //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; @@ -630,8 +627,7 @@ bool QMainWindowLayoutState::checkFormat(QDataStream &stream, bool pre43) case QToolBarAreaLayout::ToolBarStateMarkerEx: { QList toolBars = findChildrenHelper(mainWindow); - if (!toolBarAreaLayout.restoreState(stream, toolBars, marker, - pre43 /*testing 4.3 format*/, true /*testing*/)) { + if (!toolBarAreaLayout.restoreState(stream, toolBars, marker, true /*testing*/)) { return false; } } @@ -672,14 +668,8 @@ 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)) { - return false; //format unknown - } - } + if (!checkFormat(ds)) + return false; QDataStream stream(copy); @@ -719,7 +709,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream, case QToolBarAreaLayout::ToolBarStateMarkerEx: { QList toolBars = findChildrenHelper(mainWindow); - if (!toolBarAreaLayout.restoreState(stream, toolBars, marker, oldFormat)) + if (!toolBarAreaLayout.restoreState(stream, toolBars, marker)) return false; for (int i = 0; i < toolBars.size(); ++i) { diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index abec34af14..d9e18b03f4 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -133,7 +133,7 @@ public: QLayoutItem *unplug(const QList &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); }; diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp index 5494d49232..1dd39174ac 100644 --- a/src/widgets/widgets/qtoolbararealayout.cpp +++ b/src/widgets/widgets/qtoolbararealayout.cpp @@ -1286,21 +1286,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; - } + int x; + stream >> x; + return x; } -bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList &_toolBars, uchar tmarker, bool pre43, bool testing) +bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList &_toolBars, uchar tmarker, bool testing) { QList toolBars = _toolBars; int lines; @@ -1325,8 +1319,8 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList> 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. @@ -1339,9 +1333,9 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList &path, QToolBarAreaLayout *other); void saveState(QDataStream &stream) const; - bool restoreState(QDataStream &stream, const QList &toolBars, uchar tmarker, bool pre43, bool testing = false); + bool restoreState(QDataStream &stream, const QList &toolBars, uchar tmarker, bool testing = false); bool isEmpty() const; };