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 <paul.tvete@digia.com>
This commit is contained in:
parent
6336ae831d
commit
17e5b577b0
@ -615,11 +615,8 @@ static QList<T> 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<QToolBar *> toolBars = findChildrenHelper<QToolBar*>(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<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) {
|
||||
|
@ -133,7 +133,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);
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@ -1325,8 +1319,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.
|
||||
@ -1339,9 +1333,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);
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user