OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ot::WidgetViewManager Class Reference

The widget view manager is used to manage widget views. More...

#include "WidgetViewManager.h"

+ Inheritance diagram for ot::WidgetViewManager:

Public Types

enum  ManagerConfigFlag : uint32_t {
  NoFlags = 0 << 0 , InputFocusCentralViewOnFocusChange = 1 << 0 , InputFocusSideViewOnFocusChange = 1 << 1 , InputFocusToolViewOnFocusChange = 1 << 2 ,
  IgnoreInputFocusOnViewInsert = 1 << 3 , InputFocusOnAnyViewFocusChange = InputFocusCentralViewOnFocusChange | InputFocusSideViewOnFocusChange | InputFocusToolViewOnFocusChange , InputFocusOnFocusChangeMask = ~InputFocusOnAnyViewFocusChange , UseBestAreaFinderOnViewInsert = 1 << 4
}
 
typedef std::pair< std::string, WidgetViewBase::ViewTypeViewNameTypeListEntry
 
typedef std::list< ViewNameTypeListEntryViewNameTypeList
 
typedef std::pair< BasicServiceInformation, ot::WidgetView * > ViewEntry
 
typedef Flags< ManagerConfigFlagManagerConfigFlags
 

Public Slots

void slotViewFocused (ads::CDockWidget *_oldFocus, ads::CDockWidget *_newFocus)
 

Signals

void viewAdded (WidgetView *_view)
 
void viewFocusChanged (WidgetView *_focusedView, WidgetView *_previousView)
 
void viewCloseRequested (WidgetView *_view)
 
void viewTabClicked (WidgetView *_view)
 
void viewDataModifiedChanged (ot::WidgetView *_view)
 

Public Member Functions

 WidgetViewManager ()
 
 ~WidgetViewManager ()
 
void initialize (WidgetViewDockManager *_dockManager=nullptr)
 Must be called upon startup, if no dock manager is provided a new one will be created.
 
ads::CDockManager * getDockManager () const
 Returns the dock manager that is managed by this widget view manager.
 
bool addView (const BasicServiceInformation &_owner, WidgetView *_view, const WidgetView::InsertFlags &_insertFlags=WidgetView::InsertFlags(WidgetView::NoInsertFlags), WidgetView *_parentView=(WidgetView *) nullptr)
 Add the provided widget view. If a central widget view is set the provided view will be added to its dock area by taking the initial dock location into account.
 
WidgetViewfindView (const std::string &_entityName, WidgetViewBase::ViewType _type) const
 Returns the widget view with the specified name. If the view does not exists return 0.
 
WidgetViewfindViewFromTitle (const std::string &_viewTitle) const
 Returns the widget view that matches the title. Will log and assert if more than one view with the same title were found. Checks the view title and the current view title.
 
bool findViewAndOwner (const std::string &_entityName, WidgetViewBase::ViewType _type, WidgetView *&_view, BasicServiceInformation &_owner) const
 Searches for the view and owner of the view. Returns true if the view was found.
 
WidgetViewgetViewFromDockWidget (ads::CDockWidget *_dock) const
 Returns the widget view that owns this dock.
 
void closeView (WidgetView *_view)
 Close and destroy the provided view.
 
void closeView (const std::string &_entityName, WidgetViewBase::ViewType _type)
 Close the widget view with the specified name. Widget views that are protected will be ignored.
 
void closeViews (const BasicServiceInformation &_owner)
 Close all widget views that belong to the given owner. Widget views that are protected will be ignored.
 
void closeViews ()
 Close all widget views. Widget views that are protected will be ignored.
 
void requestCloseUnpinnedViews (const WidgetViewBase::ViewFlags &_flags, const SelectionInformation &_activeSelection, bool _ignoreCurrent)
 Emits a close request for all unpinned views that match the criteria.
 
void forgetView (WidgetView *_view)
 Removes the provided widget view from the manager. The caller takes ownership.
 
WidgetViewforgetView (const std::string &_entityName, WidgetViewBase::ViewType _type)
 Remove the widget view with the given name from the manager. The caller takes ownership of the view.
 
void renameView (const std::string &_oldEntityName, const std::string _newEntityName)
 Renames the view with the given name.
 
void setCurrentView (const std::string &_entityName, WidgetViewBase::ViewType _type)
 Sets the specified widget view as the current tab in its tab area.
 
void setCurrentViewFromTitle (const std::string &_viewTitle)
 Sets the current view title.
 
std::string saveState (int _version=0)
 Saves the current state that can be restored later.
 
bool restoreState (std::string _state, int _version=0)
 Restores the state.
 
void applyInitialState ()
 Restore the stored initial state. An initial state is save the first time a state is saved or restored.
 
void setConfigFlag (ManagerConfigFlag _flag, bool _active=true)
 
void setConfigFlags (const ManagerConfigFlags &_flags)
 
const ManagerConfigFlagsgetConfigFlags () const
 
BasicServiceInformation getOwnerFromView (WidgetView *_view) const
 Returns the owner for the given view. Returns default BasicServiceInformation if the view is not stored in this manager.
 
WidgetViewfindViewFromWidget (QWidget *_widget) const
 Returns the widget view from the provided widget. This only works if the view was registered.
 
bool getViewExists (const std::string &_entityName, WidgetViewBase::ViewType _type) const
 Returns true if a view with the given name exists.
 
bool getViewTitleExists (const std::string &_title) const
 Returns true if a view with the given title (or current title) exists.
 
ViewNameTypeList getViewNamesFromOwner (const BasicServiceInformation &_owner) const
 Returns all view names that belong to the given owner.
 
std::list< std::string > getViewNamesFromOwner (const BasicServiceInformation &_owner, WidgetViewBase::ViewType _type) const
 Returns all view names with the given type that belong to the given owner.
 
bool getAnyViewContentModified ()
 Returns true if the content of any of the views is modified.
 
QAction * getDockToggleAction () const
 Return the dock toggle action.
 
WidgetViewgetCurrentlyFocusedView () const
 
WidgetViewgetLastFocusedView () const
 
WidgetViewgetLastFocusedSideView () const
 
WidgetViewgetLastFocusedToolView () const
 
WidgetViewgetLastFocusedCentralView () const
 
void getDebugInformation (JsonObject &_object, JsonAllocator &_allocator) const
 

Detailed Description

The widget view manager is used to manage widget views.

Member Typedef Documentation

◆ ManagerConfigFlags

◆ ViewEntry

◆ ViewNameTypeList

◆ ViewNameTypeListEntry

Member Enumeration Documentation

◆ ManagerConfigFlag

Enumerator
NoFlags 
InputFocusCentralViewOnFocusChange 

No manager flags.

InputFocusSideViewOnFocusChange 

Central views will get widget input focus when their view tab was focused.

InputFocusToolViewOnFocusChange 

Side views will get widget input focus when their view tab was focused.

IgnoreInputFocusOnViewInsert 

Tool views will get widget input focus when their view tab was focused.

InputFocusOnAnyViewFocusChange 

View widgets won't get input focus when a view is added.

Same as setting InputFocusCentralViewOnFocusChange | InputFocusSideViewOnFocusChange | InputFocusToolViewOnFocusChange

InputFocusOnFocusChangeMask 

Mask used to unset any input focus on focus changed.

UseBestAreaFinderOnViewInsert 

If enabled the manager will try to determine the best parent dock when inserting a new view. The last focused view of the same category will be used as the main source for the parent dock area.
If no view of the same category was ever focused the "oldest" view of the same category will be used.
If there does not exist any view in the same category the next higher category will be checked (Tool < Side < Central).

Constructor & Destructor Documentation

◆ WidgetViewManager()

ot::WidgetViewManager::WidgetViewManager ( )

References ot::NoFlags.

◆ ~WidgetViewManager()

ot::WidgetViewManager::~WidgetViewManager ( )

Member Function Documentation

◆ addView()

bool ot::WidgetViewManager::addView ( const BasicServiceInformation & _owner,
WidgetView * _view,
const WidgetView::InsertFlags & _insertFlags = WidgetView::InsertFlags(WidgetView::NoInsertFlags),
WidgetView * _parentView = (WidgetView*)nullptr )

Add the provided widget view. If a central widget view is set the provided view will be added to its dock area by taking the initial dock location into account.

Parameters
_ownerWidget view owner.
_viewWidget view to add.
_insertAreaThe relative area to add the view.

◆ applyInitialState()

void ot::WidgetViewManager::applyInitialState ( )

Restore the stored initial state. An initial state is save the first time a state is saved or restored.

References OT_LOG_D.

◆ closeView() [1/2]

void ot::WidgetViewManager::closeView ( const std::string & _entityName,
WidgetViewBase::ViewType _type )

Close the widget view with the specified name. Widget views that are protected will be ignored.

Parameters
_entityNameWidget view name.

References OTAssertNullptr.

◆ closeView() [2/2]

◆ closeViews() [1/2]

void ot::WidgetViewManager::closeViews ( )

Close all widget views. Widget views that are protected will be ignored.

References OTAssertNullptr.

◆ closeViews() [2/2]

void ot::WidgetViewManager::closeViews ( const BasicServiceInformation & _owner)

Close all widget views that belong to the given owner. Widget views that are protected will be ignored.

Parameters
_ownerWidget view owner.

References OTAssertNullptr.

◆ findView()

ot::WidgetView * ot::WidgetViewManager::findView ( const std::string & _entityName,
WidgetViewBase::ViewType _type ) const

Returns the widget view with the specified name. If the view does not exists return 0.

Parameters
_entityNameWidget view name.

◆ findViewAndOwner()

bool ot::WidgetViewManager::findViewAndOwner ( const std::string & _entityName,
WidgetViewBase::ViewType _type,
WidgetView *& _view,
BasicServiceInformation & _owner ) const

Searches for the view and owner of the view. Returns true if the view was found.

◆ findViewFromTitle()

ot::WidgetView * ot::WidgetViewManager::findViewFromTitle ( const std::string & _viewTitle) const

Returns the widget view that matches the title. Will log and assert if more than one view with the same title were found. Checks the view title and the current view title.

◆ findViewFromWidget()

ot::WidgetView * ot::WidgetViewManager::findViewFromWidget ( QWidget * _widget) const

Returns the widget view from the provided widget. This only works if the view was registered.

◆ forgetView() [1/2]

ot::WidgetView * ot::WidgetViewManager::forgetView ( const std::string & _entityName,
WidgetViewBase::ViewType _type )

Remove the widget view with the given name from the manager. The caller takes ownership of the view.

Parameters
_entityNameWidget view name.

References ot::WidgetView::closeRequested(), OT_LOG_EA, OT_LOG_EAS, OTAssert, OTAssertNullptr, ot::WidgetView::pinnedChanged(), and ot::WidgetView::viewDataModifiedChanged().

◆ forgetView() [2/2]

void ot::WidgetViewManager::forgetView ( WidgetView * _view)

Removes the provided widget view from the manager. The caller takes ownership.

Parameters
_viewView to forget.

References ot::BasicEntityInformation::getEntityName(), ot::WidgetView::getViewData(), ot::WidgetViewBase::getViewType(), and OTAssertNullptr.

◆ getAnyViewContentModified()

bool ot::WidgetViewManager::getAnyViewContentModified ( )

Returns true if the content of any of the views is modified.

◆ getConfigFlags()

const ManagerConfigFlags & ot::WidgetViewManager::getConfigFlags ( ) const
inline

◆ getCurrentlyFocusedView()

ot::WidgetView * ot::WidgetViewManager::getCurrentlyFocusedView ( ) const

◆ getDebugInformation()

void ot::WidgetViewManager::getDebugInformation ( JsonObject & _object,
JsonAllocator & _allocator ) const

◆ getDockManager()

ads::CDockManager * ot::WidgetViewManager::getDockManager ( ) const
inline

Returns the dock manager that is managed by this widget view manager.

◆ getDockToggleAction()

QAction * ot::WidgetViewManager::getDockToggleAction ( ) const
inline

Return the dock toggle action.

◆ getLastFocusedCentralView()

WidgetView * ot::WidgetViewManager::getLastFocusedCentralView ( ) const
inline

◆ getLastFocusedSideView()

WidgetView * ot::WidgetViewManager::getLastFocusedSideView ( ) const
inline

◆ getLastFocusedToolView()

WidgetView * ot::WidgetViewManager::getLastFocusedToolView ( ) const
inline

◆ getLastFocusedView()

WidgetView * ot::WidgetViewManager::getLastFocusedView ( ) const
inline

◆ getOwnerFromView()

ot::BasicServiceInformation ot::WidgetViewManager::getOwnerFromView ( WidgetView * _view) const

Returns the owner for the given view. Returns default BasicServiceInformation if the view is not stored in this manager.

References OT_LOG_EA.

◆ getViewExists()

bool ot::WidgetViewManager::getViewExists ( const std::string & _entityName,
WidgetViewBase::ViewType _type ) const

Returns true if a view with the given name exists.

Parameters
_entityNameName to check

◆ getViewFromDockWidget()

ot::WidgetView * ot::WidgetViewManager::getViewFromDockWidget ( ads::CDockWidget * _dock) const

Returns the widget view that owns this dock.

◆ getViewNamesFromOwner() [1/2]

ot::WidgetViewManager::ViewNameTypeList ot::WidgetViewManager::getViewNamesFromOwner ( const BasicServiceInformation & _owner) const

Returns all view names that belong to the given owner.

◆ getViewNamesFromOwner() [2/2]

std::list< std::string > ot::WidgetViewManager::getViewNamesFromOwner ( const BasicServiceInformation & _owner,
WidgetViewBase::ViewType _type ) const

Returns all view names with the given type that belong to the given owner.

References result.

◆ getViewTitleExists()

bool ot::WidgetViewManager::getViewTitleExists ( const std::string & _title) const

Returns true if a view with the given title (or current title) exists.

Parameters
_titleTitle to check

◆ initialize()

void ot::WidgetViewManager::initialize ( WidgetViewDockManager * _dockManager = nullptr)

Must be called upon startup, if no dock manager is provided a new one will be created.

References OT_LOG_WA, and slotViewFocused().

◆ renameView()

void ot::WidgetViewManager::renameView ( const std::string & _oldEntityName,
const std::string _newEntityName )

Renames the view with the given name.

References ot::BasicEntityInformation::setEntityName().

◆ requestCloseUnpinnedViews()

void ot::WidgetViewManager::requestCloseUnpinnedViews ( const WidgetViewBase::ViewFlags & _flags,
const SelectionInformation & _activeSelection,
bool _ignoreCurrent )

Emits a close request for all unpinned views that match the criteria.

Parameters
_flagsFlags that must be set at the view.
_activeSelectionThe current selection. Views that don't have at least one matching selection will be considered.
_ignoreCurrentIf true the current view will be ignored.

◆ restoreState()

bool ot::WidgetViewManager::restoreState ( std::string _state,
int _version = 0 )

Restores the state.

Parameters
_stateState to restore.
_versionState version. If the versions mismatch the restore state will cancel and return false.

References OT_LOG_D, OT_LOG_E, OTAssertNullptr, and result.

◆ saveState()

std::string ot::WidgetViewManager::saveState ( int _version = 0)

Saves the current state that can be restored later.

Parameters
_versionState version (see restoreState).

References OTAssertNullptr.

◆ setConfigFlag()

void ot::WidgetViewManager::setConfigFlag ( ManagerConfigFlag _flag,
bool _active = true )
inline

◆ setConfigFlags()

void ot::WidgetViewManager::setConfigFlags ( const ManagerConfigFlags & _flags)
inline

◆ setCurrentView()

void ot::WidgetViewManager::setCurrentView ( const std::string & _entityName,
WidgetViewBase::ViewType _type )

Sets the specified widget view as the current tab in its tab area.

Parameters
_entityNameWidget view name.

◆ setCurrentViewFromTitle()

void ot::WidgetViewManager::setCurrentViewFromTitle ( const std::string & _viewTitle)

Sets the current view title.

◆ slotViewFocused

void ot::WidgetViewManager::slotViewFocused ( ads::CDockWidget * _oldFocus,
ads::CDockWidget * _newFocus )
slot

◆ viewAdded

void ot::WidgetViewManager::viewAdded ( WidgetView * _view)
signal

◆ viewCloseRequested

void ot::WidgetViewManager::viewCloseRequested ( WidgetView * _view)
signal

◆ viewDataModifiedChanged

void ot::WidgetViewManager::viewDataModifiedChanged ( ot::WidgetView * _view)
signal

◆ viewFocusChanged

void ot::WidgetViewManager::viewFocusChanged ( WidgetView * _focusedView,
WidgetView * _previousView )
signal

◆ viewTabClicked

void ot::WidgetViewManager::viewTabClicked ( WidgetView * _view)
signal

The documentation for this class was generated from the following files: