The widget view manager is used to manage widget views. More...
#include "WidgetViewManager.h"
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::ViewType > | ViewNameTypeListEntry |
typedef std::list< ViewNameTypeListEntry > | ViewNameTypeList |
typedef std::pair< BasicServiceInformation, ot::WidgetView * > | ViewEntry |
typedef Flags< ManagerConfigFlag > | ManagerConfigFlags |
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. | |
WidgetView * | 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. | |
WidgetView * | 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. | |
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. | |
WidgetView * | getViewFromDockWidget (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. | |
WidgetView * | 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. | |
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 ManagerConfigFlags & | getConfigFlags (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. | |
WidgetView * | findViewFromWidget (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. | |
WidgetView * | getCurrentlyFocusedView (void) const |
WidgetView * | getLastFocusedView (void) const |
WidgetView * | getLastFocusedSideView (void) const |
WidgetView * | getLastFocusedToolView (void) const |
WidgetView * | getLastFocusedCentralView (void) const |
Static Public Member Functions | |
static WidgetViewManager & | instance (void) |
Return the clobal instance. | |
The widget view manager is used to manage widget views.
typedef std::pair<BasicServiceInformation, ot::WidgetView*> ot::WidgetViewManager::ViewEntry |
typedef std::list<ViewNameTypeListEntry> ot::WidgetViewManager::ViewNameTypeList |
typedef std::pair<std::string, WidgetViewBase::ViewType> ot::WidgetViewManager::ViewNameTypeListEntry |
enum ot::WidgetViewManager::ManagerConfigFlag : uint32_t |
bool ot::WidgetViewManager::addView | ( | const BasicServiceInformation & | _owner, |
WidgetView * | _view, | ||
const WidgetView::InsertFlags & | _insertFlags = WidgetView::InsertFlags(WidgetView::NoInsertFlags), | ||
WidgetView * | _parentView = (WidgetView*)nullptr ) |
void ot::WidgetViewManager::closeView | ( | const std::string & | _entityName, |
WidgetViewBase::ViewType | _type ) |
void ot::WidgetViewManager::closeView | ( | WidgetView * | _view | ) |
Close and destroy the provided view.
_view | The view to close. |
void ot::WidgetViewManager::closeViews | ( | const BasicServiceInformation & | _owner | ) |
void ot::WidgetViewManager::closeViews | ( | void | ) |
Close all widget views. Widget views that are protected will be ignored.
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.
_entityName | Widget view name. |
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.
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.
ot::WidgetView * ot::WidgetViewManager::findViewFromWidget | ( | QWidget * | _widget | ) | const |
Returns the widget view from the provided widget. This only works if the view was registered.
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.
_entityName | Widget view name. |
void ot::WidgetViewManager::forgetView | ( | WidgetView * | _view | ) |
Removes the provided widget view from the manager. The caller takes ownership.
_view | View to forget. |
bool ot::WidgetViewManager::getAnyViewContentModified | ( | void | ) |
Returns true if the content of any of the views is modified.
|
inline |
ot::WidgetView * ot::WidgetViewManager::getCurrentlyFocusedView | ( | void | ) | const |
|
inline |
Returns the dock manager that is managed by this widget view manager.
|
inline |
Return the dock toggle action.
|
inline |
|
inline |
|
inline |
|
inline |
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.
bool ot::WidgetViewManager::getViewExists | ( | const std::string & | _entityName, |
WidgetViewBase::ViewType | _type ) const |
Returns true if a view with the given name exists.
_entityName | Name to check |
ot::WidgetView * ot::WidgetViewManager::getViewFromDockWidget | ( | ads::CDockWidget * | _dock | ) | const |
Returns the widget view that owns this dock.
ot::WidgetViewManager::ViewNameTypeList ot::WidgetViewManager::getViewNamesFromOwner | ( | const BasicServiceInformation & | _owner | ) | const |
Returns all view names that belong to the given owner.
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.
bool ot::WidgetViewManager::getViewTitleExists | ( | const std::string & | _title | ) | const |
Returns true if a view with the given title (or current title) exists.
_title | Title to check |
void ot::WidgetViewManager::initialize | ( | WidgetViewDockManager * | _dockManager = nullptr | ) |
Must be called upon startup, if no dock manager is provided a new one will be created.
|
static |
Return the clobal instance.
bool ot::WidgetViewManager::restoreState | ( | std::string | _state, |
int | _version = 0 ) |
Restores the state.
_state | State to restore. |
_version | State version. If the versions mismatch the restore state will cancel and return false. |
std::string ot::WidgetViewManager::saveState | ( | int | _version = 0 | ) | const |
Saves the current state that can be restored later.
_version | State version (see restoreState). |
|
inline |
|
inline |
void ot::WidgetViewManager::setCurrentView | ( | const std::string & | _entityName, |
WidgetViewBase::ViewType | _type ) |
Sets the specified widget view as the current tab in its tab area.
_entityName | Widget view name. |
void ot::WidgetViewManager::setCurrentViewFromTitle | ( | const std::string & | _viewTitle | ) |
Sets the current view title.
|
signal |
|
signal |
|
signal |
|
signal |