From 1cba31541b61748bb7d793175bc098c5d609887c Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 14 Sep 2014 00:00:32 +0200 Subject: [PATCH] refs #325, supporting class to make parent dock widget and info area available to a component. By that, the component has access to "isWidgetVisible", "isFloating" etc. --- .../dockwidgetinfoareacomponent.cpp | 56 +++++++++++++++++ .../components/dockwidgetinfoareacomponent.h | 60 +++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 src/blackgui/components/dockwidgetinfoareacomponent.cpp create mode 100644 src/blackgui/components/dockwidgetinfoareacomponent.h diff --git a/src/blackgui/components/dockwidgetinfoareacomponent.cpp b/src/blackgui/components/dockwidgetinfoareacomponent.cpp new file mode 100644 index 000000000..8f0e61b9f --- /dev/null +++ b/src/blackgui/components/dockwidgetinfoareacomponent.cpp @@ -0,0 +1,56 @@ +/* Copyright (C) 2013 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "dockwidgetinfoareacomponent.h" + +namespace BlackGui +{ + namespace Components + { + + CDockWidgetInfoAreaComponent::CDockWidgetInfoAreaComponent(QWidget *parent) + { + // it the parent is already an info area at this time, we keep it + CDockWidgetInfoArea *ia = dynamic_cast(parent); + if (ia) + { + this->m_parentDockableInfoArea = ia; + } + } + + const CInfoArea *CDockWidgetInfoAreaComponent::getParentInfoArea() const + { + Q_ASSERT(this->m_parentDockableInfoArea); + if (!this->m_parentDockableInfoArea) return nullptr; + return this->m_parentDockableInfoArea->getParentInfoArea(); + } + + CInfoArea *CDockWidgetInfoAreaComponent::getParentInfoArea() + { + Q_ASSERT(this->m_parentDockableInfoArea); + if (!this->m_parentDockableInfoArea) return nullptr; + return this->m_parentDockableInfoArea->getParentInfoArea(); + } + + bool CDockWidgetInfoAreaComponent::isParentDockWidgetFloating() const + { + Q_ASSERT(this->m_parentDockableInfoArea); + if (!this->m_parentDockableInfoArea) return false; + return this->m_parentDockableInfoArea->isFloating(); + } + + bool CDockWidgetInfoAreaComponent::isVisibleWidget() const + { + Q_ASSERT(this->m_parentDockableInfoArea); + if (!this->m_parentDockableInfoArea) return false; + return this->m_parentDockableInfoArea->isVisibleWidget(); + } + + } // namespace +} // namespace diff --git a/src/blackgui/components/dockwidgetinfoareacomponent.h b/src/blackgui/components/dockwidgetinfoareacomponent.h new file mode 100644 index 000000000..dad0b303f --- /dev/null +++ b/src/blackgui/components/dockwidgetinfoareacomponent.h @@ -0,0 +1,60 @@ +/* Copyright (C) 2013 + * swift project Community / Contributors + * + * This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_DOCKWIDGETINFOAREACOMPONENT_H +#define BLACKGUI_DOCKWIDGETINFOAREACOMPONENT_H + +#include "../dockwidgetinfoarea.h" +#include "../infoarea.h" +#include + +namespace BlackGui +{ + namespace Components + { + + //! Component is residing in an dockable widget. This helper class provides access to + //! to its info area and dockable widget. + class CDockWidgetInfoAreaComponent + { + public: + //! Corresponding dockable widget in info area + BlackGui::CDockWidgetInfoArea *getDockWidget() { return m_parentDockableInfoArea; } + + //! Corresponding dockable widget in info area + const BlackGui::CDockWidgetInfoArea *getDockWidget() const { return m_parentDockableInfoArea; } + + //! Corresponding dockable widget in info area + void setParentDockableWidget(BlackGui::CDockWidgetInfoArea *parentDockableWidget) { m_parentDockableInfoArea = parentDockableWidget; } + + //! The parent info area + const CInfoArea *getParentInfoArea() const; + + //! The parent info area + CInfoArea *getParentInfoArea(); + + //! Is the parent dockable widget floating? + bool isParentDockWidgetFloating() const; + + //! \copydoc CDockWidgetInfoArea::isVisibleWidget + bool isVisibleWidget() const; + + protected: + //! Constructor + CDockWidgetInfoAreaComponent(QWidget *parent); + + private: + BlackGui::CDockWidgetInfoArea *m_parentDockableInfoArea = nullptr; //!< my parent dockable widget + }; + } +} // namespace + +#endif // guard