3333#include < QMainWindow>
3434#include < QList>
3535#include < QMap>
36+ #include < QVariant>
3637
3738#include < iostream>
3839
4142#include " DockWidget.h"
4243#include " ads_globals.h"
4344#include " DockStateSerialization.h"
45+ #include " DockWidgetTitleBar.h"
4446
4547namespace ads
4648{
@@ -77,6 +79,11 @@ struct DockManagerPrivate
7779 * Restores the state
7880 */
7981 bool restoreState (const QByteArray &state, int version);
82+
83+ /* *
84+ * Restores the container with the given index
85+ */
86+ bool restoreContainer (int Index, QDataStream& stream, bool Testing);
8087};
8188// struct DockManagerPrivate
8289
@@ -135,6 +142,22 @@ bool DockManagerPrivate::checkFormat(const QByteArray &state, int version)
135142}
136143
137144
145+ // ============================================================================
146+ bool DockManagerPrivate::restoreContainer (int Index, QDataStream& stream, bool Testing)
147+ {
148+ if (Index >= Containers.count ())
149+ {
150+ CFloatingDockContainer* FloatingWidget = new CFloatingDockContainer (_this);
151+ return FloatingWidget->restoreState (stream, internal::Restore);
152+ }
153+ else
154+ {
155+ std::cout << " d->Containers[i]->restoreState " << Index << std::endl;
156+ return Containers[Index]->restoreState (stream, internal::Restore);
157+ }
158+ }
159+
160+
138161// ============================================================================
139162bool DockManagerPrivate::restoreState (const QByteArray &state, int version)
140163{
@@ -162,15 +185,9 @@ bool DockManagerPrivate::restoreState(const QByteArray &state, int version)
162185 int i;
163186 for (i = 0 ; i < ContainerCount; ++i)
164187 {
165- if (i >= Containers.count ())
188+ Result = restoreContainer (i, stream, internal::Restore);
189+ if (!Result)
166190 {
167- CFloatingDockContainer* FloatingWidget = new CFloatingDockContainer (_this);
168- }
169-
170- std::cout << " d->Containers[i]->restoreState " << i << std::endl;
171- if (!Containers[i]->restoreState (stream, internal::Restore))
172- {
173- Result = false ;
174191 break ;
175192 }
176193 }
@@ -180,7 +197,7 @@ bool DockManagerPrivate::restoreState(const QByteArray &state, int version)
180197 int DeleteCount = FloatingWidgets.count () - FloatingWidgetIndex;
181198 for (int i = 0 ; i < DeleteCount; ++i)
182199 {
183- delete FloatingWidgets[FloatingWidgetIndex];
200+ FloatingWidgets[FloatingWidgetIndex]-> deleteLater () ;
184201 }
185202
186203 return Result;
@@ -309,12 +326,29 @@ bool CDockManager::restoreState(const QByteArray &state, int version)
309326 return false ;
310327 }
311328
329+ for (auto DockWidget : d->DockWidgetsMap )
330+ {
331+ DockWidget->setProperty (" dirty" , true );
332+ }
333+
312334 if (!d->restoreState (state, version))
313335 {
314336 std::cout << " restoreState: Error restoring state!!!!!!!" << std::endl;
315337 return false ;
316338 }
317339
340+ // All dock widgets, that have not been processed in the restore state
341+ // function are invisible to the user now and have no assigned dock area
342+ // The do not belong to any dock container, until the user toggles the
343+ // toggle view action the next time
344+ for (auto DockWidget : d->DockWidgetsMap )
345+ {
346+ if (DockWidget->property (" dirty" ).toBool ())
347+ {
348+ DockWidget->flagAsUnassigned ();
349+ }
350+ }
351+
318352 return true ;
319353}
320354
0 commit comments