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
 

Signals

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

Public Member Functions

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 (void) 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 (void)
 Close all widget views. Widget views that are protected will be ignored.
 
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 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) const
 Saves the current state that can be restored later.
 
bool restoreState (std::string _state, int _version=0)
 Restores the state.
 
void setConfigFlag (ManagerConfigFlag _flag, bool _active=true)
 
void setConfigFlags (const ManagerConfigFlags &_flags)
 
const ManagerConfigFlagsgetConfigFlags (void) 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 (void)
 Returns true if the content of any of the views is modified.
 
QAction * getDockToggleAction (void) const
 Return the dock toggle action.
 
WidgetViewgetCurrentlyFocusedView (void) const
 
WidgetViewgetLastFocusedView (void) const
 
WidgetViewgetLastFocusedSideView (void) const
 
WidgetViewgetLastFocusedToolView (void) const
 
WidgetViewgetLastFocusedCentralView (void) const
 

Static Public Member Functions

static WidgetViewManagerinstance (void)
 Return the clobal instance.
 

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).

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.

◆ 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.

◆ closeView() [2/2]

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

Close and destroy the provided view.

Parameters
_viewThe view to close.

◆ closeViews() [1/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.

◆ closeViews() [2/2]

void ot::WidgetViewManager::closeViews ( void )

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

◆ 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.

◆ 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.

◆ getAnyViewContentModified()

bool ot::WidgetViewManager::getAnyViewContentModified ( void )

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

◆ getConfigFlags()

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

◆ getCurrentlyFocusedView()

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

◆ getDockManager()

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

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

◆ getDockToggleAction()

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

Return the dock toggle action.

◆ getLastFocusedCentralView()

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

◆ getLastFocusedSideView()

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

◆ getLastFocusedToolView()

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

◆ getLastFocusedView()

WidgetView * ot::WidgetViewManager::getLastFocusedView ( void ) 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.

◆ 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.

◆ 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.

◆ instance()

ot::WidgetViewManager & ot::WidgetViewManager::instance ( void )
static

Return the clobal instance.

◆ 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.

◆ saveState()

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

Saves the current state that can be restored later.

Parameters
_versionState version (see restoreState).

◆ 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.

◆ 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: