From c0dca2d9784b3fdee903e81e7747317de4ae10c9 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 17 Aug 2018 16:27:51 +0200 Subject: [PATCH] DockAccess: add lookup-by-Type function to PanelManager ...now the mess multiplies --- src/gui/workspace/dock-area.cpp | 10 +++++++--- src/gui/workspace/dock-area.hpp | 28 ++++++++++++++++++++++++++-- src/gui/workspace/panel-manager.cpp | 2 +- src/gui/workspace/panel-manager.hpp | 21 ++++++++++++++++++++- wiki/thinkPad.ichthyo.mm | 28 ++++++++++++++++++++++++++-- 5 files changed, 80 insertions(+), 9 deletions(-) diff --git a/src/gui/workspace/dock-area.cpp b/src/gui/workspace/dock-area.cpp index 54df374aa..67918d2fc 100644 --- a/src/gui/workspace/dock-area.cpp +++ b/src/gui/workspace/dock-area.cpp @@ -143,7 +143,7 @@ namespace workspace { } - void + panel::Panel& DockArea::showPanel (const int description_index) { // Try and find the panel and present it if possible @@ -158,7 +158,8 @@ namespace workspace { Gdl::DockItem &dock_item = panel->getDockItem(); // ENSURE(dock_item); dock_item.present(dock_); - return; + ENSURE (panel); + return *panel; } } @@ -167,6 +168,9 @@ namespace workspace { // Dock the item dock_.add_item(new_panel->getDockItem(), Gdl::DOCK_FLOATING); + + ENSURE (new_panel); + return *new_panel; } @@ -256,7 +260,7 @@ namespace workspace { int - DockArea::findPanelDescription (const char* class_name) const + DockArea::findPanelDescription (const char* class_name) { REQUIRE(class_name); diff --git a/src/gui/workspace/dock-area.hpp b/src/gui/workspace/dock-area.hpp index eb4b50f84..aaf63275d 100644 --- a/src/gui/workspace/dock-area.hpp +++ b/src/gui/workspace/dock-area.hpp @@ -28,6 +28,10 @@ ** @todo 2017 need to clarify the intended behaviour of panels ** ///////////////////////////////////////////////////////////////////////////TICKET #1097 clarify the role and behaviour of Panels ** @todo will be transformed into a Dock entity as of 6/2018 /////////////////////////////////////////////TICKET #1144 refactor dock handling + ** @todo as of 8/2018 this is a copy of the (still actively used) PanelManager; + ** the intention was to do a clean rewrite and then throw away + ** the old messy PanelManager implementation. Meanwhile I was forced to add + ** yet more cruft to PanelManager, just to keep it going. Beware! ** ** @see actions.hpp */ @@ -117,8 +121,9 @@ namespace workspace { /** * Shows a panel given a description index. * @param description_index The index of the panel type to show. + * @return existing or new Panel, docked within the realm of this PanelManager. */ - void showPanel (const int description_index); + panel::Panel& showPanel (const int description_index); /** * Switches a panel from one type to another, @@ -138,6 +143,14 @@ namespace workspace { public: + /** + * retrieve the internal type-ID corresponding to the given panel implementation type. + * @return internal index into the #panelDescriptionList, or `-1` if not found. + * @deprecated the whole concept of panel identification needs overhaul 8/2018 + */ + template + static int findPanelID(); + /** Gets the number of panel descriptions. */ static int getPanelDescriptionCount(); @@ -166,7 +179,7 @@ namespace workspace { * @return Returns the index of the panel description found, or -1 * if no description was found for this type. */ - int findPanelDescription (const char* class_name) const; + static int findPanelDescription (const char* class_name); /** * Creates a panel by description index. @@ -338,5 +351,16 @@ namespace workspace { }; + + + template + inline int + DockArea::findPanelID() + { + return DockArea::findPanelDescription (typeid(P).name()); + } + + + }}// namespace gui::workspace #endif /*GUI_WORKSPACE_DOCK_AREA_H*/ diff --git a/src/gui/workspace/panel-manager.cpp b/src/gui/workspace/panel-manager.cpp index 6d5ab5bc9..73a2619fb 100644 --- a/src/gui/workspace/panel-manager.cpp +++ b/src/gui/workspace/panel-manager.cpp @@ -252,7 +252,7 @@ namespace workspace { int - PanelManager::findPanelDescription (const char* class_name) const + PanelManager::findPanelDescription (const char* class_name) { REQUIRE(class_name); diff --git a/src/gui/workspace/panel-manager.hpp b/src/gui/workspace/panel-manager.hpp index e78a87716..d1ed12fce 100644 --- a/src/gui/workspace/panel-manager.hpp +++ b/src/gui/workspace/panel-manager.hpp @@ -136,6 +136,14 @@ namespace workspace { public: + /** + * retrieve the internal type-ID corresponding to the given panel implementation type. + * @return internal index into the #panelDescriptionList, or `-1` if not found. + * @deprecated the whole concept of panel identification needs overhaul 8/2018 + */ + template + static int findPanelID(); + /** Gets the number of panel descriptions. */ static int getPanelDescriptionCount(); @@ -164,7 +172,7 @@ namespace workspace { * @return Returns the index of the panel description found, or -1 * if no description was found for this type. */ - int findPanelDescription (const char* class_name) const; + static int findPanelDescription (const char* class_name); /** * Creates a panel by description index. @@ -335,5 +343,16 @@ namespace workspace { }; + + + template + inline int + PanelManager::findPanelID() + { + return PanelManager::findPanelDescription (typeid(P).name()); + } + + + }}// namespace gui::workspace #endif /*GUI_WORKSPACE_PANEL_MANAGER_H*/ diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 7699076f0..b3d7cff79 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -1668,9 +1668,15 @@ - + + - + + + + + + @@ -14378,6 +14384,24 @@ + + + + + + + + + + + + + + + + + +