Envision
A visual programming IDE for object-oriented languages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
VersionControlUI::DiffManager Class Reference

Public Types

enum  NameChangeVisualization { Summary = 0x1 , NameText = 0x2 , References = 0x4 }
 
using NameChangeVisualizationFlags = QFlags< NameChangeVisualization >
 

Public Member Functions

 DiffManager (QString project, QList< Model::SymbolMatcher > contextUnitMatcherPriorityList, Model::NodeIdType targetNodeID={})
 
DiffFramesAndSetup computeDiffFramesAndOverlays (QString oldVersion, QString newVersion, Visualization::ViewItem *viewItem)
 
void highlightChangedParts (QString oldVersion, QString newVersion, Model::TreeManager *manager)
 
void showDiff (QString oldVersion, QString newVersion)
 
void showNodeHistory (Model::NodeIdType targetNodeID, QList< QString > versions)
 

Static Public Member Functions

static void clear ()
 
static QString createHTMLCommitInfo (const FilePersistence::GitRepository *repository, QString revision)
 
static void setNameChangeVisualizationFlags (NameChangeVisualizationFlags nameChangeVisualizationFlags)
 
static bool toggleNameChangeHighlights (Visualization::Item *target, QKeySequence keySequence, Interaction::ActionRegistry::InputState inputState)
 

Private Member Functions

bool areInTargetNodeSubtree (Model::Node *oldNode, Model::Node *newNode, const DiffSetup &diffSetup)
 Check if at least one of the nodes oldNode or newNode is in the targetNode subtree. More...
 
void computeDiff (QString oldVersion, QString newVersion, QList< ChangeWithNodes > &changesWithNodes, QSet< Model::NodeIdType > &changedNodesToVisualize, DiffSetup &diffSetup)
 Inserts for entries of changes a ChangeWithNodes in changesWithNodes. More...
 
QString computeNameChangeInformation (const DiffSetup &diffSetup)
 
QList< DiffFrame * > createDiffFrames (DiffSetup &diffSetup, QSet< Model::NodeIdType > diffFrameNodeIds, const QList< ChangeWithNodes > &changesWithNodes)
 Returns a list of DiffFrame created from the ids from diffFrameNodeIds. More...
 
void createOverlaysForChanges (QList< ChangeWithNodes > changesWithNodes, Visualization::ViewItem *viewItem, DiffSetup diffSetup, Visualization::Item *anchorItem)
 
Model::TreeManagercreateTreeManagerFromVersion (FilePersistence::GitRepository *repository, QString version)
 Creates a TreeManager from version using repository. More...
 
QSet< Model::Node * > findAllNodesWithDirectParentPresent (QHash< Model::Node *, FilePersistence::ChangeType > &nodes)
 Returns all nodes which have their direct parent present in nodes if the change type of the node matches the one of the parent node. More...
 
bool findChangedNode (Model::TreeManager *treeManager, Model::NodeIdType id, Model::NodeIdType &resultId)
 Searches in treeManager for a node with id and tries to get its first ancestor of type symbol_. More...
 
DiffSetup initializeDiffPrerequisites (QString oldVersion, QString newVersion)
 
bool processNameChange (Model::Node *oldNode, Model::Node *newNode, const DiffSetup &diffSetup)
 
void processNameTextChanges (FilePersistence::IdToChangeDescriptionHash &changes, const DiffSetup &diffSetup)
 
void removeDirectChildrenOfNodesInContainer (QList< ChangeWithNodes > &container)
 Deletes all nodes in container if their direct parent is also in container and has the same change type. More...
 
void removeNodesWithAncestorPresent (QSet< Model::NodeIdType > &container)
 Removes all nodes which have an ancestor present in container. More...
 
VersionNodes retrieveVersionNodesForId (const Model::NodeIdType &id, const DiffSetup &diffSetup)
 

Static Private Member Functions

static Visualization::ItemaddOverlaysAndReturnItem (Model::Node *node, Visualization::ViewItem *viewItem, QString highlightOverlayName, QString highlightOverlayStyle, QString arrowIconOverlayName, QString arrowIconOverlayStyle)
 
static void createOverlaysForChanges (Visualization::ViewItem *diffViewItem, QList< ChangeWithNodes > changesWithNodes, QList< Model::NodeIdType > nameChangesIds)
 Creates the different overlays according to the change type of the node. More...
 
static QSet< Visualization::Item * > findAllItemsWithAncestorsIn (QSet< Visualization::Item * > items)
 Returns all items which have an ancestor present in items. More...
 
static QSet< Visualization::Item * > findAllItemsWithAncestorsIn (QSet< Visualization::Item * > items, QSet< Visualization::Item * > possibleAncestors)
 Returns all items which have an ancestor present in possibleAncestors. More...
 
static void scaleItems (QSet< Visualization::Item * > itemsToScale, Visualization::ViewItem *currentViewItem, bool nameChangeRelated=false)
 
static void setOverlayInformationAccordingToChangeType (FilePersistence::ChangeType changeType, QString &highlightOverlayStyle, QString &highlightOverlayName, QString &arrowIconOverlayStyle, QString &arrowIconOverlayName, bool iconsForMoveAndModify=false)
 
static bool shouldShowChange (Model::NodeIdType id)
 Check if change associated with id should be visualized (e.g. More...
 

Private Attributes

QList< Model::SymbolMatchercontextUnitMatcherPriorityList_
 
QMultiHash< QString, QPair< QString, Model::NodeIdType > > nameChangeInformation_
 Maps old name to a pair consisting of the new name and the id of the renamed component. More...
 
QString project_
 
Model::NodeIdType targetNodeId_
 

Static Private Attributes

static const QString NAME_CHANGE_ARROW_OVERLAY_NAME = "nameChange_arrow_overlay"
 
static const QString NAME_CHANGE_OVERLAY_NAME = "nameChange_overlay"
 
static QList< int > nameChangeOnZoomHandlerIds_
 List of the ids of all OnZoomHandlers associated with name changes. More...
 
static QList< ChangeWithNodesnameChanges_
 List of all ChangeWithNodes related to name changes. More...
 
static QMultiHash< Model::NodeIdType, bool > nameChangesIdsIsNameText_
 Contains the id of all NameTexts and References related to name changes. More...
 
static QSet< Visualization::Item * > nameChangesScaledByAncestor_
 All items related to name changes, which do not need special scaling, since one of their ancestors is responsible for the scaling. More...
 
static NameChangeVisualizationFlags nameChangeVisualizationFlags_ {Summary | NameText | References}
 Flags used to control the amount of information that should be displayed for name changes. More...
 
static QHash< Visualization::ViewItem *, int > onZoomHandlerIdPerViewItem_
 
static const QString OVERVIEW_HIGHLIGHT_OVERLAY_NAME = "changeOverviewHighlights"
 
static const QString OVERVIEW_ICON_OVERLAY_NAME = "changeOverviewIcons"
 

Member Typedef Documentation

◆ NameChangeVisualizationFlags

Member Enumeration Documentation

◆ NameChangeVisualization

Enumerator
Summary 
NameText 
References 

Constructor & Destructor Documentation

◆ DiffManager()

VersionControlUI::DiffManager::DiffManager ( QString  project,
QList< Model::SymbolMatcher contextUnitMatcherPriorityList,
Model::NodeIdType  targetNodeID = {} 
)

Member Function Documentation

◆ addOverlaysAndReturnItem()

Visualization::Item * VersionControlUI::DiffManager::addOverlaysAndReturnItem ( Model::Node node,
Visualization::ViewItem viewItem,
QString  highlightOverlayName,
QString  highlightOverlayStyle,
QString  arrowIconOverlayName,
QString  arrowIconOverlayStyle 
)
staticprivate

◆ areInTargetNodeSubtree()

bool VersionControlUI::DiffManager::areInTargetNodeSubtree ( Model::Node oldNode,
Model::Node newNode,
const DiffSetup diffSetup 
)
private

Check if at least one of the nodes oldNode or newNode is in the targetNode subtree.

If no targetNode is specified returns true.

◆ clear()

void VersionControlUI::DiffManager::clear ( )
static

◆ computeDiff()

void VersionControlUI::DiffManager::computeDiff ( QString  oldVersion,
QString  newVersion,
QList< ChangeWithNodes > &  changesWithNodes,
QSet< Model::NodeIdType > &  changedNodesToVisualize,
DiffSetup diffSetup 
)
private

Inserts for entries of changes a ChangeWithNodes in changesWithNodes.

Computes id of nodes which should be visualized and inserts them in changedNodesToVisualize.

◆ computeDiffFramesAndOverlays()

DiffFramesAndSetup VersionControlUI::DiffManager::computeDiffFramesAndOverlays ( QString  oldVersion,
QString  newVersion,
Visualization::ViewItem viewItem 
)

◆ computeNameChangeInformation()

QString VersionControlUI::DiffManager::computeNameChangeInformation ( const DiffSetup diffSetup)
private

◆ createDiffFrames()

QList< DiffFrame * > VersionControlUI::DiffManager::createDiffFrames ( DiffSetup diffSetup,
QSet< Model::NodeIdType diffFrameNodeIds,
const QList< ChangeWithNodes > &  changesWithNodes 
)
private

Returns a list of DiffFrame created from the ids from diffFrameNodeIds.

◆ createHTMLCommitInfo()

QString VersionControlUI::DiffManager::createHTMLCommitInfo ( const FilePersistence::GitRepository repository,
QString  revision 
)
static

◆ createOverlaysForChanges() [1/2]

void VersionControlUI::DiffManager::createOverlaysForChanges ( QList< ChangeWithNodes changesWithNodes,
Visualization::ViewItem viewItem,
DiffSetup  diffSetup,
Visualization::Item anchorItem 
)
private

◆ createOverlaysForChanges() [2/2]

void VersionControlUI::DiffManager::createOverlaysForChanges ( Visualization::ViewItem diffViewItem,
QList< ChangeWithNodes changesWithNodes,
QList< Model::NodeIdType nameChangesIds 
)
staticprivate

Creates the different overlays according to the change type of the node.

Uses nameChangesIds to identify changes related to name changes and use special overlay names for them.

◆ createTreeManagerFromVersion()

Model::TreeManager * VersionControlUI::DiffManager::createTreeManagerFromVersion ( FilePersistence::GitRepository repository,
QString  version 
)
private

Creates a TreeManager from version using repository.

◆ findAllItemsWithAncestorsIn() [1/2]

QSet< Visualization::Item * > VersionControlUI::DiffManager::findAllItemsWithAncestorsIn ( QSet< Visualization::Item * >  items)
staticprivate

Returns all items which have an ancestor present in items.

◆ findAllItemsWithAncestorsIn() [2/2]

QSet< Visualization::Item * > VersionControlUI::DiffManager::findAllItemsWithAncestorsIn ( QSet< Visualization::Item * >  items,
QSet< Visualization::Item * >  possibleAncestors 
)
staticprivate

Returns all items which have an ancestor present in possibleAncestors.

◆ findAllNodesWithDirectParentPresent()

QSet< Model::Node * > VersionControlUI::DiffManager::findAllNodesWithDirectParentPresent ( QHash< Model::Node *, FilePersistence::ChangeType > &  nodes)
private

Returns all nodes which have their direct parent present in nodes if the change type of the node matches the one of the parent node.

◆ findChangedNode()

bool VersionControlUI::DiffManager::findChangedNode ( Model::TreeManager treeManager,
Model::NodeIdType  id,
Model::NodeIdType resultId 
)
private

Searches in treeManager for a node with id and tries to get its first ancestor of type symbol_.

Returns true if such a node was found and saved to resultId.

◆ highlightChangedParts()

void VersionControlUI::DiffManager::highlightChangedParts ( QString  oldVersion,
QString  newVersion,
Model::TreeManager manager 
)

◆ initializeDiffPrerequisites()

DiffSetup VersionControlUI::DiffManager::initializeDiffPrerequisites ( QString  oldVersion,
QString  newVersion 
)
private

◆ processNameChange()

bool VersionControlUI::DiffManager::processNameChange ( Model::Node oldNode,
Model::Node newNode,
const DiffSetup diffSetup 
)
private

◆ processNameTextChanges()

void VersionControlUI::DiffManager::processNameTextChanges ( FilePersistence::IdToChangeDescriptionHash changes,
const DiffSetup diffSetup 
)
private

◆ removeDirectChildrenOfNodesInContainer()

void VersionControlUI::DiffManager::removeDirectChildrenOfNodesInContainer ( QList< ChangeWithNodes > &  container)
private

Deletes all nodes in container if their direct parent is also in container and has the same change type.

◆ removeNodesWithAncestorPresent()

void VersionControlUI::DiffManager::removeNodesWithAncestorPresent ( QSet< Model::NodeIdType > &  container)
private

Removes all nodes which have an ancestor present in container.

◆ retrieveVersionNodesForId()

VersionNodes VersionControlUI::DiffManager::retrieveVersionNodesForId ( const Model::NodeIdType id,
const DiffSetup diffSetup 
)
private

◆ scaleItems()

void VersionControlUI::DiffManager::scaleItems ( QSet< Visualization::Item * >  itemsToScale,
Visualization::ViewItem currentViewItem,
bool  nameChangeRelated = false 
)
staticprivate

◆ setNameChangeVisualizationFlags()

void VersionControlUI::DiffManager::setNameChangeVisualizationFlags ( NameChangeVisualizationFlags  nameChangeVisualizationFlags)
inlinestatic

◆ setOverlayInformationAccordingToChangeType()

void VersionControlUI::DiffManager::setOverlayInformationAccordingToChangeType ( FilePersistence::ChangeType  changeType,
QString &  highlightOverlayStyle,
QString &  highlightOverlayName,
QString &  arrowIconOverlayStyle,
QString &  arrowIconOverlayName,
bool  iconsForMoveAndModify = false 
)
staticprivate

◆ shouldShowChange()

bool VersionControlUI::DiffManager::shouldShowChange ( Model::NodeIdType  id)
staticprivate

Check if change associated with id should be visualized (e.g.

if the change is part of a name change, does it satisfy the visualization constraint).

◆ showDiff()

void VersionControlUI::DiffManager::showDiff ( QString  oldVersion,
QString  newVersion 
)

◆ showNodeHistory()

void VersionControlUI::DiffManager::showNodeHistory ( Model::NodeIdType  targetNodeID,
QList< QString >  versions 
)

◆ toggleNameChangeHighlights()

bool VersionControlUI::DiffManager::toggleNameChangeHighlights ( Visualization::Item target,
QKeySequence  keySequence,
Interaction::ActionRegistry::InputState  inputState 
)
static

Member Data Documentation

◆ contextUnitMatcherPriorityList_

QList<Model::SymbolMatcher> VersionControlUI::DiffManager::contextUnitMatcherPriorityList_
private

◆ NAME_CHANGE_ARROW_OVERLAY_NAME

const QString VersionControlUI::DiffManager::NAME_CHANGE_ARROW_OVERLAY_NAME = "nameChange_arrow_overlay"
staticprivate

◆ NAME_CHANGE_OVERLAY_NAME

const QString VersionControlUI::DiffManager::NAME_CHANGE_OVERLAY_NAME = "nameChange_overlay"
staticprivate

◆ nameChangeInformation_

QMultiHash<QString, QPair<QString, Model::NodeIdType> > VersionControlUI::DiffManager::nameChangeInformation_
private

Maps old name to a pair consisting of the new name and the id of the renamed component.

◆ nameChangeOnZoomHandlerIds_

QList< int > VersionControlUI::DiffManager::nameChangeOnZoomHandlerIds_
staticprivate

List of the ids of all OnZoomHandlers associated with name changes.

◆ nameChanges_

QList< ChangeWithNodes > VersionControlUI::DiffManager::nameChanges_
staticprivate

List of all ChangeWithNodes related to name changes.

◆ nameChangesIdsIsNameText_

QMultiHash< Model::NodeIdType, bool > VersionControlUI::DiffManager::nameChangesIdsIsNameText_
staticprivate

Contains the id of all NameTexts and References related to name changes.

The bool value is used to decide whether the id is of type NameText (true) or Reference (false).

◆ nameChangesScaledByAncestor_

QSet< Visualization::Item * > VersionControlUI::DiffManager::nameChangesScaledByAncestor_
staticprivate

All items related to name changes, which do not need special scaling, since one of their ancestors is responsible for the scaling.

◆ nameChangeVisualizationFlags_

DiffManager::NameChangeVisualizationFlags VersionControlUI::DiffManager::nameChangeVisualizationFlags_ {Summary | NameText | References}
staticprivate

Flags used to control the amount of information that should be displayed for name changes.

◆ onZoomHandlerIdPerViewItem_

QHash< Visualization::ViewItem *, int > VersionControlUI::DiffManager::onZoomHandlerIdPerViewItem_
staticprivate

◆ OVERVIEW_HIGHLIGHT_OVERLAY_NAME

const QString VersionControlUI::DiffManager::OVERVIEW_HIGHLIGHT_OVERLAY_NAME = "changeOverviewHighlights"
staticprivate

◆ OVERVIEW_ICON_OVERLAY_NAME

const QString VersionControlUI::DiffManager::OVERVIEW_ICON_OVERLAY_NAME = "changeOverviewIcons"
staticprivate

◆ project_

QString VersionControlUI::DiffManager::project_
private

◆ targetNodeId_

Model::NodeIdType VersionControlUI::DiffManager::targetNodeId_
private