mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-26 08:01:32 +08:00
Started implementing VisibleDockAreaCount cache
This commit is contained in:
parent
268f8655a1
commit
5e6c82b68d
@ -410,7 +410,7 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaWidget::hideAreaWithNoVisibleContent()
|
void CDockAreaWidget::hideAreaWithNoVisibleContent()
|
||||||
{
|
{
|
||||||
this->hide();
|
this->toggleView(false);
|
||||||
|
|
||||||
// Hide empty parent splitter
|
// Hide empty parent splitter
|
||||||
auto Splitter = internal::findParent<CDockSplitter*>(this);
|
auto Splitter = internal::findParent<CDockSplitter*>(this);
|
||||||
@ -433,16 +433,6 @@ void CDockAreaWidget::hideAreaWithNoVisibleContent()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
|
||||||
void CDockAreaWidget::hideAreaIfNoVisibleContent()
|
|
||||||
{
|
|
||||||
if (openedDockWidgets().isEmpty())
|
|
||||||
{
|
|
||||||
hideAreaIfNoVisibleContent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaWidget::onTabCloseRequested(int Index)
|
void CDockAreaWidget::onTabCloseRequested(int Index)
|
||||||
{
|
{
|
||||||
@ -668,18 +658,11 @@ CDockWidget::DockWidgetFeatures CDockAreaWidget::features() const
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaWidget::setVisible(bool visible)
|
void CDockAreaWidget::toggleView(bool Open)
|
||||||
{
|
{
|
||||||
Super::setVisible(visible);
|
setVisible(Open);
|
||||||
QString FirstDockWidgetLabel;
|
emit viewToggled(Open);
|
||||||
if (dockWidgetsCount())
|
|
||||||
{
|
|
||||||
FirstDockWidgetLabel = dockWidget(0)->windowTitle();
|
|
||||||
}
|
|
||||||
qDebug() << "CDockAreaWidget::setVisible " << visible << " " << FirstDockWidgetLabel
|
|
||||||
<< " count: " << dockWidgetsCount() << " open count: " << openDockWidgetsCount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -116,13 +116,6 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void hideAreaWithNoVisibleContent();
|
void hideAreaWithNoVisibleContent();
|
||||||
|
|
||||||
/**
|
|
||||||
* This function checks, if the dock area has visible content, that means
|
|
||||||
* if any dock widget is open, and then calls hideAreaWithNoVisibleContent()
|
|
||||||
* if it does not find any visible content
|
|
||||||
*/
|
|
||||||
void hideAreaIfNoVisibleContent();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the dock area layout and components visibility
|
* Updates the dock area layout and components visibility
|
||||||
*/
|
*/
|
||||||
@ -226,9 +219,10 @@ public slots:
|
|||||||
void setCurrentIndex(int index);
|
void setCurrentIndex(int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is required for debugging purposes
|
* This property controls whether the dock area is open or closed.
|
||||||
|
* The toogleViewAction triggers this slot.
|
||||||
*/
|
*/
|
||||||
virtual void setVisible(bool visible) override;
|
void toggleView(bool Open);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
@ -249,6 +243,12 @@ signals:
|
|||||||
* @param index
|
* @param index
|
||||||
*/
|
*/
|
||||||
void currentChanged(int index);
|
void currentChanged(int index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This signal is emitted if the visibility of this dock area is toggled
|
||||||
|
* via toggle view function
|
||||||
|
*/
|
||||||
|
void viewToggled(bool Open);
|
||||||
}; // class DockAreaWidget
|
}; // class DockAreaWidget
|
||||||
}
|
}
|
||||||
// namespace ads
|
// namespace ads
|
||||||
|
@ -93,8 +93,9 @@ static void insertWidgetIntoSplitter(QSplitter* Splitter, QWidget* widget, bool
|
|||||||
/**
|
/**
|
||||||
* Private data class of CDockContainerWidget class (pimpl)
|
* Private data class of CDockContainerWidget class (pimpl)
|
||||||
*/
|
*/
|
||||||
struct DockContainerWidgetPrivate
|
class DockContainerWidgetPrivate
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
CDockContainerWidget* _this;
|
CDockContainerWidget* _this;
|
||||||
QPointer<CDockManager> DockManager;
|
QPointer<CDockManager> DockManager;
|
||||||
unsigned int zOrderIndex = 0;
|
unsigned int zOrderIndex = 0;
|
||||||
@ -103,6 +104,7 @@ struct DockContainerWidgetPrivate
|
|||||||
QSplitter* RootSplitter;
|
QSplitter* RootSplitter;
|
||||||
bool isFloating = false;
|
bool isFloating = false;
|
||||||
CDockAreaWidget* LastAddedAreaCache[5]{0, 0, 0, 0, 0};
|
CDockAreaWidget* LastAddedAreaCache[5]{0, 0, 0, 0, 0};
|
||||||
|
int VisibleDockAreaCount = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data constructor
|
* Private data constructor
|
||||||
@ -176,6 +178,42 @@ struct DockContainerWidgetPrivate
|
|||||||
* Helper function for recursive dumping of layout
|
* Helper function for recursive dumping of layout
|
||||||
*/
|
*/
|
||||||
void dumpRecursive(int level, QWidget* widget);
|
void dumpRecursive(int level, QWidget* widget);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the visible dock area count variable if it is not initialized
|
||||||
|
* yet
|
||||||
|
*/
|
||||||
|
void initVisibleDockAreaCount()
|
||||||
|
{
|
||||||
|
if (VisibleDockAreaCount > -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VisibleDockAreaCount = 0;
|
||||||
|
for (auto DockArea : DockAreas)
|
||||||
|
{
|
||||||
|
VisibleDockAreaCount += DockArea->isHidden() ? 0 : 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Access function for the visible dock area counter
|
||||||
|
*/
|
||||||
|
int& visibleDockAreaCount()
|
||||||
|
{
|
||||||
|
// Lazy initialisation - we initialize the VisibleDockAreaCount variable
|
||||||
|
// on first use
|
||||||
|
initVisibleDockAreaCount();
|
||||||
|
return VisibleDockAreaCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
// private slots: ------------------------------------------------------------
|
||||||
|
void onDockAreaViewToggled(bool Visible)
|
||||||
|
{
|
||||||
|
std::cout << "onDockAreaViewToggled " << Visible << std::endl;
|
||||||
|
VisibleDockAreaCount += Visible ? 1 : -1;
|
||||||
|
}
|
||||||
}; // struct DockContainerWidgetPrivate
|
}; // struct DockContainerWidgetPrivate
|
||||||
|
|
||||||
|
|
||||||
@ -922,8 +960,6 @@ int CDockContainerWidget::dockAreaCount() const
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
int CDockContainerWidget::visibleDockAreaCount() const
|
int CDockContainerWidget::visibleDockAreaCount() const
|
||||||
{
|
{
|
||||||
// TODO Cache or precalculate this to speed it up because it is used during
|
|
||||||
// movement of floating widget
|
|
||||||
int Result = 0;
|
int Result = 0;
|
||||||
for (auto DockArea : d->DockAreas)
|
for (auto DockArea : d->DockAreas)
|
||||||
{
|
{
|
||||||
@ -931,6 +967,10 @@ int CDockContainerWidget::visibleDockAreaCount() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
|
// TODO Cache or precalculate this to speed it up because it is used during
|
||||||
|
// movement of floating widget
|
||||||
|
//return d->visibleDockAreaCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1029,6 +1069,7 @@ bool CDockContainerWidget::restoreState(QXmlStreamReader& s, bool Testing)
|
|||||||
QWidget*NewRootSplitter {};
|
QWidget*NewRootSplitter {};
|
||||||
if (!Testing)
|
if (!Testing)
|
||||||
{
|
{
|
||||||
|
d->VisibleDockAreaCount = -1;// invalidate the dock area count
|
||||||
d->DockAreas.clear();
|
d->DockAreas.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1162,9 +1203,8 @@ CDockWidget::DockWidgetFeatures CDockContainerWidget::features() const
|
|||||||
return Features;
|
return Features;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
|
#include "moc_DockContainerWidget.cpp"
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// EOF DockContainerWidget.cpp
|
// EOF DockContainerWidget.cpp
|
||||||
|
@ -40,7 +40,7 @@ class QXmlStreamReader;
|
|||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
struct DockContainerWidgetPrivate;
|
class DockContainerWidgetPrivate;
|
||||||
class CDockAreaWidget;
|
class CDockAreaWidget;
|
||||||
class CDockWidget;
|
class CDockWidget;
|
||||||
class CDockManager;
|
class CDockManager;
|
||||||
@ -65,6 +65,7 @@ private:
|
|||||||
friend class CFloatingDockContainer;
|
friend class CFloatingDockContainer;
|
||||||
friend struct FloatingDockContainerPrivate;
|
friend struct FloatingDockContainerPrivate;
|
||||||
friend class CDockWidget;
|
friend class CDockWidget;
|
||||||
|
Q_PRIVATE_SLOT(d, void onDockAreaViewToggled(bool Visible))
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
@ -130,7 +130,7 @@ void DockWidgetPrivate::showDockWidget()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DockArea->show();
|
DockArea->toggleView(true);
|
||||||
DockArea->setCurrentDockWidget(_this);
|
DockArea->setCurrentDockWidget(_this);
|
||||||
TabWidget->show();
|
TabWidget->show();
|
||||||
QSplitter* Splitter = internal::findParent<QSplitter*>(DockArea);
|
QSplitter* Splitter = internal::findParent<QSplitter*>(DockArea);
|
||||||
|
@ -350,14 +350,6 @@ void CFloatingDockContainer::showEvent(QShowEvent *event)
|
|||||||
{
|
{
|
||||||
std::cout << "CFloatingDockContainer showEvent" << std::endl;
|
std::cout << "CFloatingDockContainer showEvent" << std::endl;
|
||||||
QWidget::showEvent(event);
|
QWidget::showEvent(event);
|
||||||
/*for (int i = 0; i < DockContainer->dockAreaCount(); ++i)
|
|
||||||
{
|
|
||||||
auto DockArea = DockContainer->dockArea(i);
|
|
||||||
for (auto DockWidget : DockArea->openedDockWidgets())
|
|
||||||
{
|
|
||||||
DockWidget->setToggleViewActionChecked(true);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
for (auto DockArea : d->DockContainer->openedDockAreas())
|
for (auto DockArea : d->DockContainer->openedDockAreas())
|
||||||
{
|
{
|
||||||
for (auto DockWidget : DockArea->openedDockWidgets())
|
for (auto DockWidget : DockArea->openedDockWidgets())
|
||||||
|
Loading…
Reference in New Issue
Block a user