From 22ae03bd3be065bf922a601d0e1a4ca2c5bf9ea5 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 10 Feb 2019 17:24:10 +0100 Subject: [PATCH] Moved CEnableForDockWidgetInfoArea to ns BlackGui, was in BlackGui::Components for some reason Discovered during T536 --- src/blackgui/components/aircraftcomponent.h | 10 +- src/blackgui/components/atcstationcomponent.h | 6 +- src/blackgui/components/cockpitcomcomponent.h | 7 +- src/blackgui/components/cockpitcomponent.h | 2 +- .../components/dbaircraftcategorycomponent.h | 2 +- .../components/dbaircrafticaocomponent.h | 4 +- .../components/dbairlineicaocomponent.h | 4 +- src/blackgui/components/dbcountrycomponent.h | 4 +- .../components/dbdistributorcomponent.h | 4 +- src/blackgui/components/dbliverycomponent.h | 4 +- src/blackgui/components/dbmappingcomponent.h | 2 +- src/blackgui/components/dbmodelcomponent.h | 2 +- src/blackgui/components/dbstashcomponent.h | 4 +- .../enablefordockwidgetinfoarea.cpp | 104 ------------------ .../components/enablefordockwidgetinfoarea.h | 78 ------------- src/blackgui/components/mappingcomponent.h | 8 +- src/blackgui/components/radarcomponent.h | 6 +- src/blackgui/components/simulatorcomponent.h | 2 +- .../components/textmessagecomponent.h | 2 +- src/blackgui/components/usercomponent.h | 8 +- src/blackgui/dockwidgetinfoarea.cpp | 2 +- src/blackgui/dockwidgetinfoarea.h | 5 +- src/blackgui/enablefordockwidgetinfoarea.cpp | 100 +++++++++++++++++ src/blackgui/enablefordockwidgetinfoarea.h | 71 ++++++++++++ src/blackgui/overlaymessages.cpp | 8 +- src/blackgui/views/viewbase.h | 6 +- 26 files changed, 222 insertions(+), 233 deletions(-) delete mode 100644 src/blackgui/components/enablefordockwidgetinfoarea.cpp delete mode 100644 src/blackgui/components/enablefordockwidgetinfoarea.h create mode 100644 src/blackgui/enablefordockwidgetinfoarea.cpp create mode 100644 src/blackgui/enablefordockwidgetinfoarea.h diff --git a/src/blackgui/components/aircraftcomponent.h b/src/blackgui/components/aircraftcomponent.h index f5fd28d43..dc28bd7d6 100644 --- a/src/blackgui/components/aircraftcomponent.h +++ b/src/blackgui/components/aircraftcomponent.h @@ -9,13 +9,13 @@ //! \file -#ifndef BLACKGUI_AIRCRAFTCOMPONENT_H -#define BLACKGUI_AIRCRAFTCOMPONENT_H +#ifndef BLACKGUI_COMPONENTS_AIRCRAFTCOMPONENT_H +#define BLACKGUI_COMPONENTS_AIRCRAFTCOMPONENT_H -#include "blackcore/network.h" -#include "blackgui/blackguiexport.h" #include "blackgui/settings/viewupdatesettings.h" -#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackgui/enablefordockwidgetinfoarea.h" +#include "blackgui/blackguiexport.h" +#include "blackcore/network.h" #include #include diff --git a/src/blackgui/components/atcstationcomponent.h b/src/blackgui/components/atcstationcomponent.h index 040a5d0d4..977a8f6ab 100644 --- a/src/blackgui/components/atcstationcomponent.h +++ b/src/blackgui/components/atcstationcomponent.h @@ -9,12 +9,12 @@ //! \file -#ifndef BLACKGUI_ATCSTATIONCOMPONENT_H -#define BLACKGUI_ATCSTATIONCOMPONENT_H +#ifndef BLACKGUI_COMPONENTS_ATCSTATIONCOMPONENT_H +#define BLACKGUI_COMPONENTS_ATCSTATIONCOMPONENT_H -#include "blackgui/components/enablefordockwidgetinfoarea.h" #include "blackgui/settings/viewupdatesettings.h" #include "blackgui/settings/atcstationssettings.h" +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/overlaymessagesframe.h" #include "blackgui/blackguiexport.h" #include "blackcore/network.h" diff --git a/src/blackgui/components/cockpitcomcomponent.h b/src/blackgui/components/cockpitcomcomponent.h index 63eb42969..967639203 100644 --- a/src/blackgui/components/cockpitcomcomponent.h +++ b/src/blackgui/components/cockpitcomcomponent.h @@ -9,11 +9,12 @@ //! \file -#ifndef BLACKGUI_COCKPITCOMCOMPONENT_H -#define BLACKGUI_COCKPITCOMCOMPONENT_H +#ifndef BLACKGUI_COMPONENTS_COCKPITCOMCOMPONENT_H +#define BLACKGUI_COMPONENTS_COCKPITCOMCOMPONENT_H +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/blackguiexport.h" -#include "blackgui/components/enablefordockwidgetinfoarea.h" + #include "blackmisc/audio/voiceroomlist.h" #include "blackmisc/aviation/selcal.h" #include "blackmisc/aviation/transponder.h" diff --git a/src/blackgui/components/cockpitcomponent.h b/src/blackgui/components/cockpitcomponent.h index 5826f06f3..3ce8756f9 100644 --- a/src/blackgui/components/cockpitcomponent.h +++ b/src/blackgui/components/cockpitcomponent.h @@ -12,7 +12,7 @@ #ifndef BLACKGUI_COMPONENTS_COCKPITCOMPONENT_H #define BLACKGUI_COMPONENTS_COCKPITCOMPONENT_H -#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/overlaymessagesframe.h" #include "blackgui/blackguiexport.h" diff --git a/src/blackgui/components/dbaircraftcategorycomponent.h b/src/blackgui/components/dbaircraftcategorycomponent.h index 1a5dff342..f23a878f1 100644 --- a/src/blackgui/components/dbaircraftcategorycomponent.h +++ b/src/blackgui/components/dbaircraftcategorycomponent.h @@ -12,8 +12,8 @@ #ifndef BLACKGUI_COMPONENTS_DBAIRCRAFTCATEGORYCOMPONENT_H #define BLACKGUI_COMPONENTS_DBAIRCRAFTCATEGORYCOMPONENT_H -#include "blackgui/components/enablefordockwidgetinfoarea.h" #include "blackgui/overlaymessagesframe.h" +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/enableforviewbasedindicator.h" #include "blackgui/blackguiexport.h" #include "blackmisc/network/entityflags.h" diff --git a/src/blackgui/components/dbaircrafticaocomponent.h b/src/blackgui/components/dbaircrafticaocomponent.h index 7e8d7af42..81f5e0d52 100644 --- a/src/blackgui/components/dbaircrafticaocomponent.h +++ b/src/blackgui/components/dbaircrafticaocomponent.h @@ -12,9 +12,9 @@ #ifndef BLACKGUI_COMPONENTS_DBAIRCRAFTICAOCOMPONENT_H #define BLACKGUI_COMPONENTS_DBAIRCRAFTICAOCOMPONENT_H -#include "blackgui/components/enablefordockwidgetinfoarea.h" -#include "blackgui/overlaymessagesframe.h" +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/enableforviewbasedindicator.h" +#include "blackgui/overlaymessagesframe.h" #include "blackgui/blackguiexport.h" #include "blackmisc/network/entityflags.h" diff --git a/src/blackgui/components/dbairlineicaocomponent.h b/src/blackgui/components/dbairlineicaocomponent.h index ece80dd13..d41fdbc0b 100644 --- a/src/blackgui/components/dbairlineicaocomponent.h +++ b/src/blackgui/components/dbairlineicaocomponent.h @@ -12,9 +12,9 @@ #ifndef BLACKGUI_COMPONENTS_DBAIRLINEICAOCOMPONENT_H #define BLACKGUI_COMPONENTS_DBAIRLINEICAOCOMPONENT_H -#include "blackgui/components/enablefordockwidgetinfoarea.h" -#include "blackgui/overlaymessagesframe.h" +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/enableforviewbasedindicator.h" +#include "blackgui/overlaymessagesframe.h" #include "blackgui/blackguiexport.h" #include "blackmisc/network/entityflags.h" diff --git a/src/blackgui/components/dbcountrycomponent.h b/src/blackgui/components/dbcountrycomponent.h index d6a946fb2..b45c831b8 100644 --- a/src/blackgui/components/dbcountrycomponent.h +++ b/src/blackgui/components/dbcountrycomponent.h @@ -12,9 +12,9 @@ #ifndef BLACKGUI_COMPONENTS_DBCOUNTRYCOMPONENT_H #define BLACKGUI_COMPONENTS_DBCOUNTRYCOMPONENT_H -#include "blackgui/blackguiexport.h" -#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/enableforviewbasedindicator.h" +#include "blackgui/blackguiexport.h" #include "blackmisc/network/entityflags.h" #include diff --git a/src/blackgui/components/dbdistributorcomponent.h b/src/blackgui/components/dbdistributorcomponent.h index c01f741b6..2688a11bd 100644 --- a/src/blackgui/components/dbdistributorcomponent.h +++ b/src/blackgui/components/dbdistributorcomponent.h @@ -12,9 +12,9 @@ #ifndef BLACKGUI_COMPONENTS_DBDISTRIBUTORCOMPONENT_H #define BLACKGUI_COMPONENTS_DBDISTRIBUTORCOMPONENT_H -#include "blackgui/blackguiexport.h" -#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/enableforviewbasedindicator.h" +#include "blackgui/blackguiexport.h" #include "blackmisc/simulation/distributorlist.h" #include "blackmisc/network/entityflags.h" #include diff --git a/src/blackgui/components/dbliverycomponent.h b/src/blackgui/components/dbliverycomponent.h index 6627da0fe..7a993c305 100644 --- a/src/blackgui/components/dbliverycomponent.h +++ b/src/blackgui/components/dbliverycomponent.h @@ -12,9 +12,9 @@ #ifndef BLACKGUI_COMPONENTS_DBLIVERYCOMPONENT_H #define BLACKGUI_COMPONENTS_DBLIVERYCOMPONENT_H -#include "blackgui/components/enablefordockwidgetinfoarea.h" -#include "blackgui/overlaymessagesframe.h" +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/enableforviewbasedindicator.h" +#include "blackgui/overlaymessagesframe.h" #include "blackgui/blackguiexport.h" #include "blackmisc/aviation/airlineicaocode.h" #include "blackmisc/network/entityflags.h" diff --git a/src/blackgui/components/dbmappingcomponent.h b/src/blackgui/components/dbmappingcomponent.h index 383e32fc0..a7eccdb9b 100644 --- a/src/blackgui/components/dbmappingcomponent.h +++ b/src/blackgui/components/dbmappingcomponent.h @@ -12,10 +12,10 @@ #ifndef BLACKGUI_COMPONENTS_DBMAPPINGCOMPONENT_H #define BLACKGUI_COMPONENTS_DBMAPPINGCOMPONENT_H -#include "blackgui/components/enablefordockwidgetinfoarea.h" #include "blackgui/enableforviewbasedindicator.h" #include "blackgui/menus/menudelegate.h" #include "blackgui/overlaymessagesframe.h" +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/blackguiexport.h" #include "blackcore/data/authenticateduser.h" #include "blackmisc/aviation/airlineicaocode.h" diff --git a/src/blackgui/components/dbmodelcomponent.h b/src/blackgui/components/dbmodelcomponent.h index 43b49d738..78d10273a 100644 --- a/src/blackgui/components/dbmodelcomponent.h +++ b/src/blackgui/components/dbmodelcomponent.h @@ -13,7 +13,7 @@ #define BLACKUI_COMPONENTS_DBMODELCOMPONENT_H #include "blackgui/components/dbmappingcomponentaware.h" -#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/enableforviewbasedindicator.h" #include "blackgui/overlaymessagesframe.h" #include "blackgui/blackguiexport.h" diff --git a/src/blackgui/components/dbstashcomponent.h b/src/blackgui/components/dbstashcomponent.h index 308716faa..d2d7d34c0 100644 --- a/src/blackgui/components/dbstashcomponent.h +++ b/src/blackgui/components/dbstashcomponent.h @@ -12,9 +12,9 @@ #ifndef BLACKGUI_COMPONENTS_DBSTASHCOMPONENT_H #define BLACKGUI_COMPONENTS_DBSTASHCOMPONENT_H -#include "blackgui/blackguiexport.h" #include "blackgui/components/dbmappingcomponentaware.h" -#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackgui/enablefordockwidgetinfoarea.h" +#include "blackgui/blackguiexport.h" #include "blackcore/data/authenticateduser.h" #include "blackmisc/aviation/airlineicaocode.h" #include "blackmisc/propertyindexvariantmap.h" diff --git a/src/blackgui/components/enablefordockwidgetinfoarea.cpp b/src/blackgui/components/enablefordockwidgetinfoarea.cpp deleted file mode 100644 index 42f3ecc09..000000000 --- a/src/blackgui/components/enablefordockwidgetinfoarea.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* 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 "blackgui/components/enablefordockwidgetinfoarea.h" -#include "blackgui/dockwidgetinfoarea.h" -#include "blackgui/enableforframelesswindow.h" -#include "blackgui/guiutility.h" -#include "blackgui/infoarea.h" - -#include -#include -#include -#include -#include -#include - -using namespace BlackMisc::Aviation; -using namespace BlackGui; - -namespace BlackGui -{ - namespace Components - { - CEnableForDockWidgetInfoArea::CEnableForDockWidgetInfoArea(CDockWidgetInfoArea *parentInfoArea) - { - // it the parent is already an info area at this time, we keep it - // otherwise we expect the info area to set it later - m_parentDockableInfoArea = parentInfoArea; - } - - bool CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget) - { - // sanity check - if (m_parentDockableInfoArea) - { - // we already have a value - // changes should not happen - Q_ASSERT_X(m_parentDockableInfoArea == parentDockableWidget, Q_FUNC_INFO, "Reassigned parent dock widget area"); - return m_parentDockableInfoArea == parentDockableWidget; - } - - m_parentDockableInfoArea = parentDockableWidget; - QMetaObject::Connection con = QDockWidget::connect(parentDockableWidget, &QDockWidget::destroyed, [this] - { - // break dependency to dockable widget - m_parentDockableInfoArea = nullptr; - }); - Q_ASSERT_X(con, Q_FUNC_INFO, "Connection failed"); - m_connections.append(con); - return true; - } - - CInfoArea *CEnableForDockWidgetInfoArea::getParentInfoArea() const - { - Q_ASSERT(m_parentDockableInfoArea); - if (!m_parentDockableInfoArea) return nullptr; - return m_parentDockableInfoArea->getParentInfoArea(); - } - - bool CEnableForDockWidgetInfoArea::isParentDockWidgetFloating() const - { - Q_ASSERT(m_parentDockableInfoArea); - if (!m_parentDockableInfoArea) { return false; } - return m_parentDockableInfoArea->isFloating(); - } - - bool CEnableForDockWidgetInfoArea::isVisibleWidget() const - { - if (!m_parentDockableInfoArea) { return false; } // can happen function is used while dock widget not yet fully initialized - return m_parentDockableInfoArea->isVisibleWidget(); - } - - CEnableForFramelessWindow *CEnableForDockWidgetInfoArea::mainApplicationWindow() const - { - CEnableForFramelessWindow *mw = CGuiUtility::mainFramelessEnabledWindow(); - return mw; - } - - QWidget *CEnableForDockWidgetInfoArea::mainApplicationWindowWidget() const - { - CEnableForFramelessWindow *mw = this->mainApplicationWindow(); - return mw ? mw->getWidget() : nullptr; - } - - void CEnableForDockWidgetInfoArea::displayMyself() - { - // if we are already visible, we are done - if (this->isVisibleWidget()) { return; } - - // select myself - if (this->getParentInfoArea()) - { - this->getParentInfoArea()->selectArea(this->getDockWidgetInfoArea()); - } - } - - } // namespace -} // namespace diff --git a/src/blackgui/components/enablefordockwidgetinfoarea.h b/src/blackgui/components/enablefordockwidgetinfoarea.h deleted file mode 100644 index a7ac5a3fe..000000000 --- a/src/blackgui/components/enablefordockwidgetinfoarea.h +++ /dev/null @@ -1,78 +0,0 @@ -/* 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_ENABLEFORDOCKWIDGETINFOAREA_H -#define BLACKGUI_ENABLEFORDOCKWIDGETINFOAREA_H - -#include "blackgui/components/textmessagecomponenttab.h" -#include "blackgui/blackguiexport.h" -#include "blackmisc/aviation/callsign.h" -#include "blackmisc/connectionguard.h" - -class QWidget; - -namespace BlackGui -{ - class CDockWidgetInfoArea; - class CEnableForFramelessWindow; - class CInfoArea; - - namespace Components - { - //! Helper class: If a component is residing in an dockable widget. - //! This class provides access to its info area and dockable widget. - class BLACKGUI_EXPORT CEnableForDockWidgetInfoArea - { - public: - //! Corresponding dockable widget in info area - CDockWidgetInfoArea *getDockWidgetInfoArea() const { return m_parentDockableInfoArea; } - - //! Has dock area? - bool hasDockWidgetArea() const { return m_parentDockableInfoArea; } - - //! Corresponding dockable widget in info area - //! \remarks Usually set from CDockWidgetInfoArea when it is fully initialized - virtual bool setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget); - - //! The parent info area - CInfoArea *getParentInfoArea() const; - - //! Is the parent dockable widget floating? - bool isParentDockWidgetFloating() const; - - //! \copydoc CDockWidgetInfoArea::isVisibleWidget - bool isVisibleWidget() const; - - //! Main application window if any - CEnableForFramelessWindow *mainApplicationWindow() const; - - //! Main application window widget if any - QWidget *mainApplicationWindowWidget() const; - - //! Display myself - void displayMyself(); - - protected: - //! Constructor - //! \remarks Normally the info area will be provided later \sa setParentDockWidgetInfoArea - CEnableForDockWidgetInfoArea(CDockWidgetInfoArea *parentInfoArea = nullptr); - - //! Destructor - virtual ~CEnableForDockWidgetInfoArea() {} - - private: - CDockWidgetInfoArea *m_parentDockableInfoArea = nullptr; //!< my parent dockable widget - BlackMisc::CConnectionGuard m_connections; - }; - } -} // namespace - -#endif // guard diff --git a/src/blackgui/components/mappingcomponent.h b/src/blackgui/components/mappingcomponent.h index a2e907b72..830480388 100644 --- a/src/blackgui/components/mappingcomponent.h +++ b/src/blackgui/components/mappingcomponent.h @@ -12,11 +12,11 @@ #ifndef BLACKGUI_COMPONENTS_MAPPINGCOMPONENT_H #define BLACKGUI_COMPONENTS_MAPPINGCOMPONENT_H -#include "blackcore/network.h" -#include "blackgui/overlaymessagesframe.h" -#include "blackgui/blackguiexport.h" -#include "blackgui/components/enablefordockwidgetinfoarea.h" #include "blackgui/settings/viewupdatesettings.h" +#include "blackgui/overlaymessagesframe.h" +#include "blackgui/enablefordockwidgetinfoarea.h" +#include "blackgui/blackguiexport.h" +#include "blackcore/network.h" #include "blackmisc/tokenbucket.h" #include "blackmisc/identifiable.h" #include "blackmisc/identifier.h" diff --git a/src/blackgui/components/radarcomponent.h b/src/blackgui/components/radarcomponent.h index 816268cd8..08bb5abf8 100644 --- a/src/blackgui/components/radarcomponent.h +++ b/src/blackgui/components/radarcomponent.h @@ -9,11 +9,11 @@ //! \file -#ifndef BLACKGUI_RADARCOMPONENT_H -#define BLACKGUI_RADARCOMPONENT_H +#ifndef BLACKGUI_COMPONENTS_RADARCOMPONENT_H +#define BLACKGUI_COMPONENTS_RADARCOMPONENT_H +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/blackguiexport.h" -#include "blackgui/components/enablefordockwidgetinfoarea.h" #include #include diff --git a/src/blackgui/components/simulatorcomponent.h b/src/blackgui/components/simulatorcomponent.h index 810a144a8..4833acb77 100644 --- a/src/blackgui/components/simulatorcomponent.h +++ b/src/blackgui/components/simulatorcomponent.h @@ -12,7 +12,7 @@ #ifndef BLACKGUI_SIMULATORCOMPONENT_H #define BLACKGUI_SIMULATORCOMPONENT_H -#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/blackguiexport.h" #include "blackmisc/simulation/simulatorinfo.h" #include "blackmisc/logcategorylist.h" diff --git a/src/blackgui/components/textmessagecomponent.h b/src/blackgui/components/textmessagecomponent.h index d77c61833..3b6627404 100644 --- a/src/blackgui/components/textmessagecomponent.h +++ b/src/blackgui/components/textmessagecomponent.h @@ -14,7 +14,7 @@ #include "textmessagecomponenttab.h" #include "blackgui/settings/textmessagesettings.h" -#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/blackguiexport.h" #include "blackmisc/audio/audiosettings.h" #include "blackmisc/aviation/atcstation.h" diff --git a/src/blackgui/components/usercomponent.h b/src/blackgui/components/usercomponent.h index 9c03e220e..5eceda3c2 100644 --- a/src/blackgui/components/usercomponent.h +++ b/src/blackgui/components/usercomponent.h @@ -12,10 +12,10 @@ #ifndef BLACKGUI_USERCOMPONENT_H #define BLACKGUI_USERCOMPONENT_H -#include "blackcore/network.h" +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/blackguiexport.h" #include "blackgui/settings/viewupdatesettings.h" -#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackcore/network.h" #include #include @@ -69,6 +69,6 @@ namespace BlackGui QTimer m_updateTimer; BlackMisc::CSettingReadOnly m_settings { this, &CUserComponent::onSettingsChanged }; }; - } -} + } // ns +} // ns #endif // guard diff --git a/src/blackgui/dockwidgetinfoarea.cpp b/src/blackgui/dockwidgetinfoarea.cpp index 2f826c7e0..f34bbe5e3 100644 --- a/src/blackgui/dockwidgetinfoarea.cpp +++ b/src/blackgui/dockwidgetinfoarea.cpp @@ -8,7 +8,7 @@ */ #include "blackgui/dockwidgetinfoarea.h" -#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/infoarea.h" #include diff --git a/src/blackgui/dockwidgetinfoarea.h b/src/blackgui/dockwidgetinfoarea.h index 6b3ab973b..4d6ff1fbb 100644 --- a/src/blackgui/dockwidgetinfoarea.h +++ b/src/blackgui/dockwidgetinfoarea.h @@ -19,13 +19,12 @@ #include class QMenu; -class QWidget; namespace BlackGui { //! Forward declarations class CInfoArea; - namespace Components { class CEnableForDockWidgetInfoArea; } + class CEnableForDockWidgetInfoArea; //! Specialized class for dock widgets serving as info area. //! \sa CDockWidgetInfoBar @@ -61,7 +60,7 @@ namespace BlackGui private: //! Find all embedded dock widget components. These are components marked as CDockWidgetInfoAreaComponent //! \remarks Only directly embedded info area components, not those of nested info areas - QList findEmbeddedDockWidgetInfoAreaComponents(); + QList findEmbeddedDockWidgetInfoAreaComponents(); //! Nested info areas QList findNestedInfoAreas(); diff --git a/src/blackgui/enablefordockwidgetinfoarea.cpp b/src/blackgui/enablefordockwidgetinfoarea.cpp new file mode 100644 index 000000000..22daf7d80 --- /dev/null +++ b/src/blackgui/enablefordockwidgetinfoarea.cpp @@ -0,0 +1,100 @@ +/* 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 "blackgui/enablefordockwidgetinfoarea.h" +#include "blackgui/dockwidgetinfoarea.h" +#include "blackgui/enableforframelesswindow.h" +#include "blackgui/guiutility.h" +#include "blackgui/infoarea.h" + +#include +#include +#include +#include +#include +#include + +using namespace BlackMisc::Aviation; +using namespace BlackGui; + +namespace BlackGui +{ + CEnableForDockWidgetInfoArea::CEnableForDockWidgetInfoArea(CDockWidgetInfoArea *parentInfoArea) + { + // it the parent is already an info area at this time, we keep it + // otherwise we expect the info area to set it later + m_parentDockableInfoArea = parentInfoArea; + } + + bool CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget) + { + // sanity check + if (m_parentDockableInfoArea) + { + // we already have a value + // changes should not happen + Q_ASSERT_X(m_parentDockableInfoArea == parentDockableWidget, Q_FUNC_INFO, "Reassigned parent dock widget area"); + return m_parentDockableInfoArea == parentDockableWidget; + } + + m_parentDockableInfoArea = parentDockableWidget; + QMetaObject::Connection con = QDockWidget::connect(parentDockableWidget, &QDockWidget::destroyed, [this] + { + // break dependency to dockable widget + m_parentDockableInfoArea = nullptr; + }); + Q_ASSERT_X(con, Q_FUNC_INFO, "Connection failed"); + m_connections.append(con); + return true; + } + + CInfoArea *CEnableForDockWidgetInfoArea::getParentInfoArea() const + { + Q_ASSERT(m_parentDockableInfoArea); + if (!m_parentDockableInfoArea) return nullptr; + return m_parentDockableInfoArea->getParentInfoArea(); + } + + bool CEnableForDockWidgetInfoArea::isParentDockWidgetFloating() const + { + Q_ASSERT(m_parentDockableInfoArea); + if (!m_parentDockableInfoArea) { return false; } + return m_parentDockableInfoArea->isFloating(); + } + + bool CEnableForDockWidgetInfoArea::isVisibleWidget() const + { + if (!m_parentDockableInfoArea) { return false; } // can happen function is used while dock widget not yet fully initialized + return m_parentDockableInfoArea->isVisibleWidget(); + } + + CEnableForFramelessWindow *CEnableForDockWidgetInfoArea::mainApplicationWindow() const + { + CEnableForFramelessWindow *mw = CGuiUtility::mainFramelessEnabledWindow(); + return mw; + } + + QWidget *CEnableForDockWidgetInfoArea::mainApplicationWindowWidget() const + { + CEnableForFramelessWindow *mw = this->mainApplicationWindow(); + return mw ? mw->getWidget() : nullptr; + } + + void CEnableForDockWidgetInfoArea::displayMyself() + { + // if we are already visible, we are done + if (this->isVisibleWidget()) { return; } + + // select myself + if (this->getParentInfoArea()) + { + this->getParentInfoArea()->selectArea(this->getDockWidgetInfoArea()); + } + } +} // namespace diff --git a/src/blackgui/enablefordockwidgetinfoarea.h b/src/blackgui/enablefordockwidgetinfoarea.h new file mode 100644 index 000000000..ad1463c2a --- /dev/null +++ b/src/blackgui/enablefordockwidgetinfoarea.h @@ -0,0 +1,71 @@ +/* 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_ENABLEFORDOCKWIDGETINFOAREA_H +#define BLACKGUI_ENABLEFORDOCKWIDGETINFOAREA_H + +#include "blackgui/blackguiexport.h" +#include "blackmisc/connectionguard.h" + +namespace BlackGui +{ + class CDockWidgetInfoArea; + class CEnableForFramelessWindow; + class CInfoArea; + + //! Helper class: If a component is residing in an dockable widget. + //! This class provides access to its info area and dockable widget. + class BLACKGUI_EXPORT CEnableForDockWidgetInfoArea + { + public: + //! Corresponding dockable widget in info area + CDockWidgetInfoArea *getDockWidgetInfoArea() const { return m_parentDockableInfoArea; } + + //! Has dock area? + bool hasDockWidgetArea() const { return m_parentDockableInfoArea; } + + //! Corresponding dockable widget in info area + //! \remarks Usually set from CDockWidgetInfoArea when it is fully initialized + virtual bool setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget); + + //! The parent info area + CInfoArea *getParentInfoArea() const; + + //! Is the parent dockable widget floating? + bool isParentDockWidgetFloating() const; + + //! \copydoc CDockWidgetInfoArea::isVisibleWidget + bool isVisibleWidget() const; + + //! Main application window if any + CEnableForFramelessWindow *mainApplicationWindow() const; + + //! Main application window widget if any + QWidget *mainApplicationWindowWidget() const; + + //! Display myself + void displayMyself(); + + protected: + //! Constructor + //! \remarks Normally the info area will be provided later \sa setParentDockWidgetInfoArea + CEnableForDockWidgetInfoArea(CDockWidgetInfoArea *parentInfoArea = nullptr); + + //! Destructor + virtual ~CEnableForDockWidgetInfoArea() {} + + private: + CDockWidgetInfoArea *m_parentDockableInfoArea = nullptr; //!< my parent dockable widget + BlackMisc::CConnectionGuard m_connections; + }; +} // namespace + +#endif // guard diff --git a/src/blackgui/overlaymessages.cpp b/src/blackgui/overlaymessages.cpp index ae4b75be8..3d795393e 100644 --- a/src/blackgui/overlaymessages.cpp +++ b/src/blackgui/overlaymessages.cpp @@ -7,14 +7,14 @@ * contained in the LICENSE file. */ -#include "blackgui/overlaymessages.h" #include "blackgui/components/statusmessageform.h" #include "blackgui/components/statusmessageformsmall.h" -#include "blackgui/guiapplication.h" -#include "blackgui/models/statusmessagelistmodel.h" -#include "blackgui/stylesheetutility.h" #include "blackgui/views/statusmessageview.h" #include "blackgui/views/viewbase.h" +#include "blackgui/models/statusmessagelistmodel.h" +#include "blackgui/overlaymessages.h" +#include "blackgui/stylesheetutility.h" +#include "blackgui/guiapplication.h" #include "blackmisc/aviation/callsign.h" #include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/network/textmessage.h" diff --git a/src/blackgui/views/viewbase.h b/src/blackgui/views/viewbase.h index 7cfca4500..32ee0f617 100644 --- a/src/blackgui/views/viewbase.h +++ b/src/blackgui/views/viewbase.h @@ -12,12 +12,12 @@ #ifndef BLACKGUI_VIEWBASE_H #define BLACKGUI_VIEWBASE_H -#include "blackgui/components/enablefordockwidgetinfoarea.h" #include "blackgui/models/modelfilter.h" #include "blackgui/models/selectionmodel.h" #include "blackgui/settings/guisettings.h" #include "blackgui/menus/menuaction.h" #include "blackgui/overlaymessagesframe.h" +#include "blackgui/enablefordockwidgetinfoarea.h" #include "blackgui/blackguiexport.h" #include "blackmisc/namevariantpairlist.h" #include "blackmisc/directories.h" @@ -85,7 +85,7 @@ namespace BlackGui //! Non templated base class, allows Q_OBJECT and signals / slots to be used class BLACKGUI_EXPORT CViewBaseNonTemplate : public COverlayMessagesTableView, - public Components::CEnableForDockWidgetInfoArea + public CEnableForDockWidgetInfoArea { Q_OBJECT @@ -199,7 +199,7 @@ namespace BlackGui //! Accept drop data? virtual bool acceptDrop(const QMimeData *mimeData) const = 0; - //! \copydoc Components::CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea + //! \copydoc CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea virtual bool setParentDockWidgetInfoArea(BlackGui::CDockWidgetInfoArea *parentDockableWidget) override; //! Resize mode