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.
This commit is contained in:
Klaus Basan
2014-09-14 00:00:32 +02:00
parent 1ce7b11988
commit 1cba31541b
2 changed files with 116 additions and 0 deletions

View File

@@ -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<CDockWidgetInfoArea *>(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

View File

@@ -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 <QWidget>
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