Envision
A visual programming IDE for object-oriented languages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
Visualization::ViewItemManager Class Reference

The ViewItemManager manages all the different ViewItems which are part of a given scene. More...

Public Member Functions

 ViewItemManager (Scene *scene)
 Creates a new ViewItemManager connected to the given scene. More...
 
 ~ViewItemManager ()
 
ViewItemcurrentViewItem ()
 Returns the currently visible ViewItem. More...
 
ViewItemloadView (QString name, QPoint position={-1, -1})
 Loads the given view from persistent disk storage. More...
 
ViewItemnewViewItem (const QString name={}, QPoint position={-1, -1})
 Creates a new ViewItem and adds it to the manager. More...
 
void removeAllViewItems ()
 Removes all existing ViewItems from the manager. More...
 
void removeViewItem (ViewItem *view)
 Removes view from the manager. More...
 
void saveView (ViewItem *view, Model::TreeManager *manager) const
 Saves the given view persistently on disk, using the given manager. More...
 
bool switchToView (const QString viewName)
 Overload using the view's name. More...
 
void switchToView (ViewItem *view)
 Switches to the given view to be the new current view. More...
 
ViewItemviewItem (const QString name)
 Finds the ViewItem with the given name, or nullptr if it doesn't exist. More...
 
QVector< QVector< ViewItem * > > viewItems () const
 

Private Member Functions

void addViewItem (ViewItem *view, QPoint position={-1, -1})
 
void cleanupRemovedItem (Visualization::Item *removedItem)
 
void cleanupRemovedNode (Model::Node *removedNode)
 
QString fileName (QString viewName, QString managerName) const
 
ViewItemloadView (QString name, Model::TreeManager *manager)
 
QPoint nextEmptyPosition () const
 

Private Attributes

ViewItemcurrentViewItem_ {}
 
const QString DIRECTORY_NAME = "views"
 
Scenescene_ {}
 
const int VIEW_ITEM_COLUMNS = 3
 
QVector< QVector< ViewItem * > > viewItems_
 

Friends

class Item
 
class Scene
 

Detailed Description

The ViewItemManager manages all the different ViewItems which are part of a given scene.

It is responsible for adding and removing views to and from the scene, as well as switching between the different views.

Constructor & Destructor Documentation

◆ ViewItemManager()

Visualization::ViewItemManager::ViewItemManager ( Scene scene)

Creates a new ViewItemManager connected to the given scene.

◆ ~ViewItemManager()

Visualization::ViewItemManager::~ViewItemManager ( )

Member Function Documentation

◆ addViewItem()

void Visualization::ViewItemManager::addViewItem ( ViewItem view,
QPoint  position = {-1, -1} 
)
private

◆ cleanupRemovedItem()

void Visualization::ViewItemManager::cleanupRemovedItem ( Visualization::Item removedItem)
private

◆ cleanupRemovedNode()

void Visualization::ViewItemManager::cleanupRemovedNode ( Model::Node removedNode)
private

◆ currentViewItem()

ViewItem * Visualization::ViewItemManager::currentViewItem ( )

Returns the currently visible ViewItem.

Guaranteed to return a valid ViewItem.

◆ fileName()

QString Visualization::ViewItemManager::fileName ( QString  viewName,
QString  managerName 
) const
private

◆ loadView() [1/2]

ViewItem * Visualization::ViewItemManager::loadView ( QString  name,
Model::TreeManager manager 
)
private

◆ loadView() [2/2]

ViewItem * Visualization::ViewItemManager::loadView ( QString  name,
QPoint  position = {-1, -1} 
)

Loads the given view from persistent disk storage.

If it exists, it is added to the manager at the given position.

◆ newViewItem()

ViewItem * Visualization::ViewItemManager::newViewItem ( const QString  name = {},
QPoint  position = {-1, -1} 
)

Creates a new ViewItem and adds it to the manager.

The ViewItem is given the name which is supplied, and positioned at the given position, or at the next free position if the default argument (-1, -1) is used.

◆ nextEmptyPosition()

QPoint Visualization::ViewItemManager::nextEmptyPosition ( ) const
private

◆ removeAllViewItems()

void Visualization::ViewItemManager::removeAllViewItems ( )

Removes all existing ViewItems from the manager.

◆ removeViewItem()

void Visualization::ViewItemManager::removeViewItem ( ViewItem view)

Removes view from the manager.

◆ saveView()

void Visualization::ViewItemManager::saveView ( ViewItem view,
Model::TreeManager manager 
) const

Saves the given view persistently on disk, using the given manager.

Note: The view can still contain nodes handled by other managers.

◆ switchToView() [1/2]

bool Visualization::ViewItemManager::switchToView ( const QString  viewName)

Overload using the view's name.

Returns whether switching was successful, i.e. whether a view with the name was found.

◆ switchToView() [2/2]

void Visualization::ViewItemManager::switchToView ( ViewItem view)

Switches to the given view to be the new current view.

The view must already be known to the manager.

◆ viewItem()

ViewItem * Visualization::ViewItemManager::viewItem ( const QString  name)

Finds the ViewItem with the given name, or nullptr if it doesn't exist.

◆ viewItems()

QVector< QVector< ViewItem * > > Visualization::ViewItemManager::viewItems ( ) const
inline

Friends And Related Function Documentation

◆ Item

friend class Item
friend

◆ Scene

friend class Scene
friend

Member Data Documentation

◆ currentViewItem_

ViewItem* Visualization::ViewItemManager::currentViewItem_ {}
private

◆ DIRECTORY_NAME

const QString Visualization::ViewItemManager::DIRECTORY_NAME = "views"
private

◆ scene_

Scene* Visualization::ViewItemManager::scene_ {}
private

◆ VIEW_ITEM_COLUMNS

const int Visualization::ViewItemManager::VIEW_ITEM_COLUMNS = 3
private

◆ viewItems_

QVector<QVector<ViewItem*> > Visualization::ViewItemManager::viewItems_
private