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::ViewType > | ViewNameTypeListEntry |
| typedef std::list< ViewNameTypeListEntry > | ViewNameTypeList |
| typedef std::pair< BasicServiceInformation, ot::WidgetView * > | ViewEntry |
| typedef Flags< ManagerConfigFlag > | ManagerConfigFlags |
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. | |
| 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 () |
| 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. | |
| 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 | 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 ManagerConfigFlags & | getConfigFlags () 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 () |
| Returns true if the content of any of the views is modified. | |
| QAction * | getDockToggleAction () const |
| Return the dock toggle action. | |
| WidgetView * | getCurrentlyFocusedView () const |
| WidgetView * | getLastFocusedView () const |
| WidgetView * | getLastFocusedSideView () const |
| WidgetView * | getLastFocusedToolView () const |
| WidgetView * | getLastFocusedCentralView () const |
| void | getDebugInformation (JsonObject &_object, JsonAllocator &_allocator) const |
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 |
| ot::WidgetViewManager::WidgetViewManager | ( | ) |
References ot::NoFlags.
| ot::WidgetViewManager::~WidgetViewManager | ( | ) |
| bool ot::WidgetViewManager::addView | ( | const BasicServiceInformation & | _owner, |
| WidgetView * | _view, | ||
| const WidgetView::InsertFlags & | _insertFlags = WidgetView::InsertFlags(WidgetView::NoInsertFlags), | ||
| WidgetView * | _parentView = (WidgetView*)nullptr ) |
| 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.
| 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.
| _entityName | Widget view name. |
References OTAssertNullptr.
| void ot::WidgetViewManager::closeView | ( | WidgetView * | _view | ) |
Close and destroy the provided view.
| _view | The view to close. |
References ot::WidgetView::closeRequested(), ot::WidgetViewTab::disableButtons(), ot::WidgetView::getViewDockWidget(), ot::WidgetView::getViewIsPermanent(), ot::WidgetViewDock::getWidgetViewTab(), OTAssertNullptr, ot::WidgetView::pinnedChanged(), and ot::WidgetView::viewDataModifiedChanged().
| void ot::WidgetViewManager::closeViews | ( | ) |
Close all widget views. Widget views that are protected will be ignored.
References OTAssertNullptr.
| 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.
| _owner | Widget view owner. |
References OTAssertNullptr.
| 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. |
References ot::WidgetView::closeRequested(), OT_LOG_EA, OT_LOG_EAS, OTAssert, OTAssertNullptr, ot::WidgetView::pinnedChanged(), and ot::WidgetView::viewDataModifiedChanged().
| void ot::WidgetViewManager::forgetView | ( | WidgetView * | _view | ) |
Removes the provided widget view from the manager. The caller takes ownership.
| _view | View to forget. |
References ot::BasicEntityInformation::getEntityName(), ot::WidgetView::getViewData(), ot::WidgetViewBase::getViewType(), and OTAssertNullptr.
| bool ot::WidgetViewManager::getAnyViewContentModified | ( | ) |
Returns true if the content of any of the views is modified.
|
inline |
| ot::WidgetView * ot::WidgetViewManager::getCurrentlyFocusedView | ( | ) | const |
| void ot::WidgetViewManager::getDebugInformation | ( | JsonObject & | _object, |
| JsonAllocator & | _allocator ) const |
References ot::WidgetViewBase::toString(), and ot::WidgetViewBase::toStringList().
|
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.
References OT_LOG_EA.
| 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.
References result.
| 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.
References OT_LOG_WA, and slotViewFocused().
| void ot::WidgetViewManager::renameView | ( | const std::string & | _oldEntityName, |
| const std::string | _newEntityName ) |
Renames the view with the given name.
References ot::BasicEntityInformation::setEntityName().
| 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.
| _flags | Flags that must be set at the view. |
| _activeSelection | The current selection. Views that don't have at least one matching selection will be considered. |
| _ignoreCurrent | If true the current view will be ignored. |
| 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. |
References OT_LOG_D, OT_LOG_E, OTAssertNullptr, and result.
| std::string ot::WidgetViewManager::saveState | ( | int | _version = 0 | ) |
Saves the current state that can be restored later.
| _version | State version (see restoreState). |
References OTAssertNullptr.
|
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.
|
slot |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |