Skip to content

Commit 653f475

Browse files
author
Uwe Kindler
committed
Removed wrong visibility initialisation of titlebar close button, added hideEmptyParentSplitters() function to properly hide tree of empty parent splitters if DockArea or DockWidget is removed,
1 parent 87e3777 commit 653f475

9 files changed

+51
-35
lines changed

src/DockAreaTitleBar.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@ void DockAreaTitleBarPrivate::createButtons()
158158
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
159159
TopLayout->addWidget(CloseButton, 0);
160160
_this->connect(CloseButton, SIGNAL(clicked()), SLOT(onCloseButtonClicked()));
161-
162-
CloseButton->setEnabled(testConfigFlag(CDockManager::DockAreaHasCloseButton));
163-
CloseButton->setVisible(CloseButton->isEnabled());
164161
}
165162

166163

src/DockAreaWidget.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -458,16 +458,9 @@ void CDockAreaWidget::hideAreaWithNoVisibleContent()
458458
{
459459
this->toggleView(false);
460460

461-
// Hide empty parent splitter
461+
// Hide empty parent splitters
462462
auto Splitter = internal::findParent<CDockSplitter*>(this);
463-
while (Splitter && Splitter->isVisible())
464-
{
465-
if (!Splitter->hasVisibleContent())
466-
{
467-
Splitter->hide();
468-
}
469-
Splitter = internal::findParent<CDockSplitter*>(Splitter);
470-
}
463+
internal::hideEmptyParentSplitters(Splitter);
471464

472465
//Hide empty floating widget
473466
CDockContainerWidget* Container = this->dockContainer();

src/DockContainerWidget.cpp

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#include "ads_globals.h"
4949
#include "DockSplitter.h"
5050

51-
#include <QElapsedTimer>
51+
#include <iostream>
5252

5353

5454
namespace ads
@@ -755,9 +755,13 @@ void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget* widget)
755755
{
756756
qDebug("%sSplitter %s v: %s c: %s",
757757
(const char*)buf,
758-
(Splitter->orientation() == Qt::Vertical) ? "-" : "|",
759-
Splitter->isVisibleTo(Splitter->parentWidget()) ? "1" : "0",
758+
(Splitter->orientation() == Qt::Vertical) ? "--" : "|",
759+
Splitter->isHidden() ? " " : "v",
760760
QString::number(Splitter->count()).toStdString().c_str());
761+
std::cout << (const char*)buf << "Splitter "
762+
<< ((Splitter->orientation() == Qt::Vertical) ? "--" : "|") << " "
763+
<< (Splitter->isHidden() ? " " : "v") << " "
764+
<< QString::number(Splitter->count()).toStdString() << std::endl;
761765
for (int i = 0; i < Splitter->count(); ++i)
762766
{
763767
dumpRecursive(level + 1, Splitter->widget(i));
@@ -771,6 +775,19 @@ void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget* widget)
771775
return;
772776
}
773777
qDebug("%sDockArea", (const char*)buf);
778+
std::cout << (const char*)buf
779+
<< (DockArea->isHidden() ? " " : "v")
780+
<< (DockArea->openDockWidgetsCount() > 0 ? " " : "c")
781+
<< " DockArea" << std::endl;
782+
buf.fill(' ', (level + 1) * 4);
783+
for (int i = 0; i < DockArea->dockWidgetsCount(); ++i)
784+
{
785+
std::cout << (const char*)buf << (i == DockArea->currentIndex() ? "*" : " ");
786+
CDockWidget* DockWidget = DockArea->dockWidget(i);
787+
std::cout << (DockWidget->isHidden() ? " " : "v");
788+
std::cout << (DockWidget->isClosed() ? "c" : " ") << " ";
789+
std::cout << DockWidget->windowTitle().toStdString() << std::endl;
790+
}
774791
}
775792
#else
776793
Q_UNUSED(level);
@@ -922,10 +939,10 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
922939
d->DockAreas.removeAll(area);
923940
CDockSplitter* Splitter = internal::findParent<CDockSplitter*>(area);
924941

925-
// Remove are from parent splitter and hide splitter if it has no visible
926-
// content
942+
// Remove are from parent splitter and recursively hide tree of parent
943+
// splitters if it has no visible content
927944
area->setParent(0);
928-
Splitter->setVisible(Splitter->hasVisibleContent());
945+
internal::hideEmptyParentSplitters(Splitter);
929946

930947
// If splitter has more than 1 widgets, we are finished and can leave
931948
if (Splitter->count() > 1)
@@ -1040,9 +1057,6 @@ int CDockContainerWidget::visibleDockAreaCount() const
10401057
void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWidget,
10411058
const QPoint& TargetPos)
10421059
{
1043-
QElapsedTimer Timer;
1044-
Timer.start();
1045-
10461060
qDebug() << "CDockContainerWidget::dropFloatingWidget";
10471061
CDockAreaWidget* DockArea = dockAreaAt(TargetPos);
10481062
auto dropArea = InvalidDockWidgetArea;
@@ -1203,8 +1217,10 @@ void CDockContainerWidget::dumpLayout()
12031217
{
12041218
#if (ADS_DEBUG_LEVEL > 0)
12051219
qDebug("\n\nDumping layout --------------------------");
1220+
std::cout << "\n\nDumping layout --------------------------" << std::endl;
12061221
d->dumpRecursive(0, d->RootSplitter);
12071222
qDebug("--------------------------\n\n");
1223+
std::cout << "--------------------------\n\n" << std::endl;
12081224
#endif
12091225
}
12101226

src/DockManager.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "DockManager.h"
3333

3434
#include <algorithm>
35+
#include <iostream>
3536

3637
#include <QMainWindow>
3738
#include <QList>
@@ -53,8 +54,6 @@
5354
#include "DockStateSerialization.h"
5455
#include "DockAreaWidget.h"
5556

56-
#include <QElapsedTimer>
57-
#include <iostream>
5857

5958
namespace ads
6059
{
@@ -515,10 +514,6 @@ QByteArray CDockManager::saveState(eXmlMode XmlMode, int version) const
515514
//============================================================================
516515
bool CDockManager::restoreState(const QByteArray &state, int version)
517516
{
518-
std::cout << "CDockManager::restoreState-----------------------" << std::endl;
519-
QElapsedTimer Timer;
520-
Timer.start();
521-
522517
// Prevent multiple calls as long as state is not restore. This may
523518
// happen, if QApplication::processEvents() is called somewhere
524519
if (d->RestoringState)

src/DockSplitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ bool CDockSplitter::hasVisibleContent() const
7878
// TODO Cache or precalculate this to speed up
7979
for (int i = 0; i < count(); ++i)
8080
{
81-
if (widget(i)->isVisibleTo(this))
81+
if (!widget(i)->isHidden())
8282
{
8383
return true;
8484
}

src/DockWidgetTab.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ bool DockWidgetTabPrivate::startFloating()
224224
}
225225
else
226226
{
227-
qDebug() << "DockWidgetTabPrivate::startFloating DockArea";
228227
// If section widget has only one content widget, we can move the complete
229228
// dock area into floating widget
230229
FloatingWidget = new CFloatingDockContainer(DockArea);

src/FloatingDockContainer.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,6 @@ void FloatingDockContainerPrivate::titleMouseReleaseEvent()
150150
//============================================================================
151151
void FloatingDockContainerPrivate::updateDropOverlays(const QPoint& GlobalPos)
152152
{
153-
static QElapsedTimer MsSinceLastCallTimer;
154-
QElapsedTimer PerformanceTimer;
155-
PerformanceTimer.start();
156-
157153
if (!_this->isVisible() || !DockManager)
158154
{
159155
return;
@@ -225,8 +221,6 @@ void FloatingDockContainerPrivate::updateDropOverlays(const QPoint& GlobalPos)
225221
{
226222
DockAreaOverlay->hideOverlay();
227223
}
228-
229-
std::cout << "updateDropOverlays us: " << PerformanceTimer.nsecsElapsed() / 1000 << std::endl;
230224
}
231225

232226

src/ads_globals.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,20 @@ QPixmap createTransparentPixmap(const QPixmap& Source, qreal Opacity)
8787
}
8888

8989

90+
//============================================================================
91+
void hideEmptyParentSplitters(CDockSplitter* Splitter)
92+
{
93+
while (Splitter && Splitter->isVisible())
94+
{
95+
if (!Splitter->hasVisibleContent())
96+
{
97+
Splitter->hide();
98+
}
99+
Splitter = internal::findParent<CDockSplitter*>(Splitter);
100+
}
101+
}
102+
103+
90104
} // namespace internal
91105
} // namespace ads
92106

src/ads_globals.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class QSplitter;
4646

4747
namespace ads
4848
{
49+
class CDockSplitter;
50+
4951
enum DockWidgetArea
5052
{
5153
NoDockWidgetArea = 0x00,
@@ -83,6 +85,12 @@ QSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent = 0);
8385
*/
8486
void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To);
8587

88+
/**
89+
* This function walks the splitter tree upwards to hides all splitters
90+
* that do not have visible content
91+
*/
92+
void hideEmptyParentSplitters(CDockSplitter* FirstParentSplitter);
93+
8694
/**
8795
* Convenience class for QPair to provide better naming than first and
8896
* second

0 commit comments

Comments
 (0)