Skip to content

Commit a652deb

Browse files
author
Uwe Kindler
committed
Started inserting RootSplitter
1 parent 1cd1e7d commit a652deb

File tree

8 files changed

+135
-33
lines changed

8 files changed

+135
-33
lines changed

.settings/language.settings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
66
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
77
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="(g?cc)|([gc]\+\+)|(clang)" prefer-non-shared="true"/>
8-
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW" console="false" env-hash="-797032510223863550" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings MinGW" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
8+
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW" console="false" env-hash="1111767096691303650" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings MinGW" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
99
<language-scope id="org.eclipse.cdt.core.gcc"/>
1010
<language-scope id="org.eclipse.cdt.core.g++"/>
1111
</provider>

src/DockAreaWidget.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,8 @@ void CDockAreaWidget::onDockWidgetViewToggled(bool Open)
711711
void CDockAreaWidget::saveState(QDataStream& stream) const
712712
{
713713
stream << d->ContentsLayout->count() << d->ContentsLayout->currentIndex();
714+
std::cout << "CDockAreaWidget::saveState TabCount: " << d->ContentsLayout->count()
715+
<< " CurrentIndex: " << d->ContentsLayout->currentIndex() << std::endl;
714716
for (int i = 0; i < d->ContentsLayout->count(); ++i)
715717
{
716718
dockWidget(i)->saveState(stream);

src/DockAreaWidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class CDockManager;
3939
class CDockContainerWidget;
4040
class CDockWidget;
4141

42+
4243
/**
4344
* DockAreaWidget manages multiple instances of DckWidgets.
4445
* It displays a title tab, which is clickable and will switch to

src/DockContainerWidget.cpp

Lines changed: 61 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <QEvent>
3434
#include <QList>
3535
#include <QGridLayout>
36-
#include <QSplitter>
3736
#include <QPointer>
3837

3938
#include "DockManager.h"
@@ -43,6 +42,7 @@
4342
#include "DockOverlay.h"
4443
#include "DockStateSerialization.h"
4544
#include "ads_globals.h"
45+
#include "DockSplitter.h"
4646

4747
#include <iostream>
4848

@@ -75,6 +75,7 @@ struct DockContainerWidgetPrivate
7575
unsigned int zOrderIndex = 0;
7676
QList<CDockAreaWidget*> DockAreas;
7777
QGridLayout* Layout = nullptr;
78+
CDockSplitter* RootSplitter;
7879
bool isFloating = false;
7980

8081
/**
@@ -123,7 +124,7 @@ struct DockContainerWidgetPrivate
123124
/**
124125
* Restore state of child nodes
125126
*/
126-
void restoreChildNodes(QDataStream& Stream, QWidget* Parent);
127+
void restoreChildNodes(QDataStream& Stream, QWidget*& CreatedWidget);
127128
}; // struct DockContainerWidgetPrivate
128129

129130

@@ -310,28 +311,38 @@ void DockContainerWidgetPrivate::saveChildNodesState(QDataStream& stream, QWidge
310311
}
311312
else
312313
{
314+
stream << NodeDockArea;
313315
CDockAreaWidget* DockArea = dynamic_cast<CDockAreaWidget*>(Widget);
314316
if (DockArea)
315317
{
316-
std::cout << "NodeDockArea " << std::endl;
317318
DockArea->saveState(stream);
318319
}
319320
}
320321
}
321322

322323

323324
//============================================================================
324-
void DockContainerWidgetPrivate::restoreChildNodes(QDataStream& stream, QWidget* Parent)
325+
void DockContainerWidgetPrivate::restoreChildNodes(QDataStream& stream,
326+
QWidget*& CreatedWidget)
325327
{
326328
int NodeType;
327329
stream >> NodeType;
328-
QSplitter* ParentSplitter = dynamic_cast<QSplitter*>(Parent);
329330
if (NodeSplitter == NodeType)
330331
{
331332
int Orientation;
332-
int Count;
333-
stream >> Orientation >> Count;
334-
std::cout << "Restore NodeSplitter " << Orientation << std::endl;
333+
int WidgetCount;
334+
stream >> Orientation >> WidgetCount;
335+
std::cout << "Restore NodeSplitter Orientation: " << Orientation <<
336+
" WidgetCount: " << WidgetCount << std::endl;
337+
for (int i = 0; i < WidgetCount; ++i)
338+
{
339+
QWidget* Widget;
340+
restoreChildNodes(stream, CreatedWidget);
341+
}
342+
343+
344+
345+
/*std::cout << "Restore NodeSplitter " << Orientation << std::endl;
335346
QSplitter* Splitter = internal::newSplitter((Qt::Orientation)Orientation);
336347
if (ParentSplitter)
337348
{
@@ -344,21 +355,37 @@ void DockContainerWidgetPrivate::restoreChildNodes(QDataStream& stream, QWidget*
344355
for (int i = 0; i < Count; ++i)
345356
{
346357
restoreChildNodes(stream, Splitter);
347-
}
358+
}*/
348359
}
349360
else
350361
{
351-
std::cout << "Restore NodeDockArea " << std::endl;
352-
CDockAreaWidget* DockArea = new CDockAreaWidget(DockManager, _this);
353-
if (ParentSplitter)
354-
{
355-
ParentSplitter->addWidget(DockArea);
356-
}
357-
else
362+
int Tabs;
363+
int CurrentIndex;
364+
stream >> Tabs >> CurrentIndex;
365+
std::cout << "Restore NodeDockArea Tabs: " << Tabs << " CurrentIndex: "
366+
<< CurrentIndex << std::endl;
367+
for (int i = 0; i < Tabs; ++i)
358368
{
359-
Parent->layout()->addWidget(DockArea);
369+
QString ObjectName;
370+
bool Closed;
371+
stream >> ObjectName >> Closed;
372+
std::cout << "Restore DockWidget " << ObjectName.toStdString() << " Closed: "
373+
<< Closed << std::endl;
374+
375+
CDockWidget* DockWidget = DockManager->findChild<CDockWidget*>(ObjectName);
376+
if (!DockWidget)
377+
{
378+
continue;
379+
}
380+
else
381+
{
382+
std::cout << "Dock Widget found - parent " << DockWidget->parent()
383+
<< std::endl;
384+
}
385+
386+
CDockAreaWidget* DockArea = new CDockAreaWidget(DockManager, _this);
387+
DockArea->addDockWidget(DockWidget);
360388
}
361-
DockAreas.append(DockArea);
362389
}
363390
}
364391

@@ -380,7 +407,10 @@ void DockContainerWidgetPrivate::addDockArea(CDockAreaWidget* NewDockArea, DockW
380407
auto InsertParam = internal::dockAreaInsertParameters(area);
381408
if (DockAreas.isEmpty())
382409
{
383-
_this->layout()->addWidget(NewDockArea);
410+
QSplitter* Splitter = internal::newSplitter(Qt::Horizontal);
411+
Splitter->addWidget(NewDockArea);
412+
insertWidgetIntoSplitter(Splitter, NewDockArea, InsertParam.append());
413+
_this->layout()->addWidget(Splitter);
384414
}
385415
else if (DockAreas.count() == 1)
386416
{
@@ -707,23 +737,26 @@ bool CDockContainerWidget::restoreState(QDataStream& stream)
707737
{
708738
bool IsFloating;
709739
stream >> IsFloating;
710-
if (isFloating())
740+
std::cout << "Restore CDockContainerWidget Floating" << IsFloating << std::endl;
741+
QWidget* RootChild = d->Layout->itemAt(0)->widget();
742+
if (RootChild)
743+
{
744+
d->DockAreas.clear();
745+
delete RootChild;
746+
}
747+
QWidget* Widget;
748+
d->restoreChildNodes(stream, Widget);
749+
750+
/*if (isFloating())
711751
{
712752
std::cout << "Restore floating widget" << std::endl;
713753
CFloatingDockContainer* FloatingWidget = internal::findParent<CFloatingDockContainer*>(this);
714754
QByteArray Geometry;
715755
stream >> Geometry;
716756
FloatingWidget->restoreGeometry(Geometry);
717757
FloatingWidget->show();
718-
}
758+
}*/
719759

720-
QWidget* RootChild = d->Layout->itemAt(0)->widget();
721-
if (RootChild)
722-
{
723-
d->DockAreas.clear();
724-
delete RootChild;
725-
}
726-
d->restoreChildNodes(stream, this);
727760
return true;
728761
}
729762

src/DockSplitter.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//============================================================================
2+
/// \file DockSplitter.cpp
3+
/// \author Uwe Kindler
4+
/// \date 24.03.2017
5+
/// \brief Implementation of CDockSplitter
6+
//============================================================================
7+
8+
//============================================================================
9+
// INCLUDES
10+
//============================================================================
11+
#include <DockSplitter.h>
12+
13+
#include <iostream>
14+
15+
namespace ads
16+
{
17+
18+
//============================================================================
19+
CDockSplitter::~CDockSplitter()
20+
{
21+
std::cout << "~CDockSplitter" << std::endl;
22+
}
23+
24+
} // namespace ads
25+
26+
//---------------------------------------------------------------------------
27+
// EOF DockSplitter.cpp

src/DockSplitter.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#ifndef DockSplitterH
2+
#define DockSplitterH
3+
//============================================================================
4+
/// \file DockSplitter.h
5+
/// \author Uwe Kindler
6+
/// \date 24.03.2017
7+
/// \brief Declaration of CDockSplitter
8+
//============================================================================
9+
10+
//============================================================================
11+
// INCLUDES
12+
//============================================================================
13+
#include <QSplitter>
14+
15+
namespace ads
16+
{
17+
18+
/**
19+
* Splitter used internally instead of QSplitter
20+
*/
21+
class CDockSplitter : public QSplitter
22+
{
23+
Q_OBJECT
24+
public:
25+
using QSplitter::QSplitter;
26+
27+
/**
28+
* Prints debug info
29+
*/
30+
virtual ~CDockSplitter();
31+
}; // class CDockSplitter
32+
33+
} // namespace ads
34+
35+
//---------------------------------------------------------------------------
36+
#endif // DockSplitterH

src/ads_globals.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
//============================================================================
2929
// INCLUDES
3030
//============================================================================
31-
#include <QSplitter>
3231
#include <QVariant>
3332

33+
#include "DockSplitter.h"
3434
#include "ads_globals.h"
3535

36+
3637
namespace ads
3738
{
3839

@@ -41,7 +42,7 @@ namespace internal
4142
//============================================================================
4243
QSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent)
4344
{
44-
QSplitter* s = new QSplitter(orientation, parent);
45+
QSplitter* s = new CDockSplitter(orientation, parent);
4546
s->setProperty("ads-splitter", QVariant(true));
4647
s->setChildrenCollapsible(false);
4748
s->setOpaqueResize(false);

src/src.pro

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ HEADERS += \
3939
DockWidget.h \
4040
DockWidgetTitleBar.h \
4141
FloatingDockContainer.h \
42-
DockOverlay.h
42+
DockOverlay.h \
43+
DockSplitter.h
4344

4445

4546

@@ -51,4 +52,5 @@ SOURCES += \
5152
DockWidget.cpp \
5253
DockWidgetTitleBar.cpp \
5354
FloatingDockContainer.cpp \
54-
DockOverlay.cpp
55+
DockOverlay.cpp \
56+
DockSplitter.cpp

0 commit comments

Comments
 (0)