mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-06 02:16:04 +08:00
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:
56
src/blackgui/components/dockwidgetinfoareacomponent.cpp
Normal file
56
src/blackgui/components/dockwidgetinfoareacomponent.cpp
Normal 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
|
||||||
60
src/blackgui/components/dockwidgetinfoareacomponent.h
Normal file
60
src/blackgui/components/dockwidgetinfoareacomponent.h
Normal 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
|
||||||
Reference in New Issue
Block a user