ui: redesigned graph overview and use new list layouting within overview bundles

* overview bundles imitate style of bundled node type
* removed bundle for built-in types
* show contents of overview bundle in vertical list layouted with new ListLayouter
* nodes starting with the same letter are grouped with the letter displayed above
* pressing the letter key will scroll to the group
* also use this list layouting for namespace & package contents
* renamed BucketGrid to BucketLayouter
* moved used functions of GraphPostProcessor to GraphViewStyle and removed GraphPostProcessor

fortune cookie message = Don't be afraid to take that big step
This commit is contained in:
Eberhard Graether
2017-02-02 13:29:40 +01:00
parent 993d66727d
commit 52b0cd2017
34 changed files with 577 additions and 578 deletions
+7 -1
View File
@@ -66,7 +66,7 @@ QtGraphicsView::QtGraphicsView(QWidget* parent)
float QtGraphicsView::getZoomFactor() const
{
return m_appZoomFactor;
return m_appZoomFactor * m_zoomFactor;
}
void QtGraphicsView::setAppZoomFactor(float appZoomFactor)
@@ -181,6 +181,12 @@ void QtGraphicsView::mouseReleaseEvent(QMouseEvent *event)
void QtGraphicsView::keyPressEvent(QKeyEvent* event)
{
if (event->key() >= Qt::Key_A && event->key() <= Qt::Key_Z)
{
QChar c = event->text().at(0).toUpper();
emit characterKeyPressed(c);
}
bool moved = moves();
switch (event->key())
+1
View File
@@ -45,6 +45,7 @@ protected:
signals:
void emptySpaceClicked();
void characterKeyPressed(QChar c);
private slots:
void updateTimer();
+77 -11
View File
@@ -11,9 +11,7 @@
#include "component/controller/helper/DummyEdge.h"
#include "component/controller/helper/DummyNode.h"
#include "component/controller/helper/GraphPostprocessor.h"
#include "component/view/GraphViewStyle.h"
#include "settings/ColorScheme.h"
#include "settings/ApplicationSettings.h"
#include "utility/messaging/type/MessageDeactivateEdge.h"
#include "utility/ResourcePaths.h"
@@ -29,6 +27,7 @@
#include "qt/view/graphElements/QtGraphNodeData.h"
#include "qt/view/graphElements/QtGraphNodeExpandToggle.h"
#include "qt/view/graphElements/QtGraphNodeQualifier.h"
#include "qt/view/graphElements/QtGraphNodeText.h"
QtGraphView::QtGraphView(ViewLayout* viewLayout)
: GraphView(viewLayout)
@@ -40,6 +39,8 @@ QtGraphView::QtGraphView(ViewLayout* viewLayout)
, m_refreshFunctor(std::bind(&QtGraphView::doRefreshView, this))
, m_focusInFunctor(std::bind(&QtGraphView::doFocusIn, this, std::placeholders::_1))
, m_focusOutFunctor(std::bind(&QtGraphView::doFocusOut, this, std::placeholders::_1))
, m_scrollToTop(false)
, m_isIndexedList(false)
{
}
@@ -71,6 +72,7 @@ void QtGraphView::initView()
widget->layout()->addWidget(view);
connect(view, SIGNAL(emptySpaceClicked()), this, SLOT(clickedInEmptySpace()));
connect(view, SIGNAL(characterKeyPressed(QChar)), this, SLOT(pressedCharacterKey(QChar)));
m_scrollSpeedChangeListenerHorizontal.setScrollBar(view->horizontalScrollBar());
m_scrollSpeedChangeListenerVertical.setScrollBar(view->verticalScrollBar());
@@ -109,18 +111,25 @@ Vec2i QtGraphView::getViewSize() const
QtGraphicsView* view = getView();
float zoomFactor = view->getZoomFactor();
return Vec2i(view->width() / zoomFactor - 80, view->height() / zoomFactor - 80);
return Vec2i(view->width() / zoomFactor - 60, view->height() / zoomFactor - 60);
}
void QtGraphView::centerScrollBars()
void QtGraphView::updateScrollBars()
{
QGraphicsView* view = getView();
QScrollBar* hb = view->horizontalScrollBar();
QScrollBar* vb = view->verticalScrollBar();
hb->setValue((hb->minimum() + hb->maximum()) / 2);
vb->setValue((vb->minimum() + vb->maximum()) / 2);
if (m_scrollToTop)
{
vb->setValue(vb->minimum());
}
else
{
hb->setValue((hb->minimum() + hb->maximum()) / 2);
vb->setValue((vb->minimum() + vb->maximum()) / 2);
}
}
void QtGraphView::finishedTransition()
@@ -148,6 +157,50 @@ void QtGraphView::clickedInEmptySpace()
}
}
void QtGraphView::pressedCharacterKey(QChar c)
{
if (!m_isIndexedList)
{
return;
}
QtGraphNode* node = nullptr;
bool hasTextNodes = false;
for (const std::shared_ptr<QtGraphNode>& n : m_oldNodes)
{
if (n->isTextNode() && n->getName().size())
{
hasTextNodes = true;
QChar start(n->getName()[0]);
if (start >= c)
{
node = n.get();
break;
}
}
}
if (!hasTextNodes)
{
return;
}
QtGraphicsView* view = getView();
if (!node)
{
view->ensureVisibleAnimated(QRectF(0, view->scene()->height() - 5, view->scene()->width(), 5), 100, 100);
}
else
{
Vec2i pos = node->getPosition();
Vec2i size = node->getSize();
view->ensureVisibleAnimated(QRectF(pos.x, pos.y, size.x, size.y + view->height() / 3 * 2), 100, 100);
}
}
void QtGraphView::switchToNewGraphData()
{
m_oldGraph = m_graph;
@@ -170,6 +223,11 @@ void QtGraphView::switchToNewGraphData()
doResize();
if (m_scrollToTop)
{
updateScrollBars();
}
// Manually hover the item below the mouse cursor.
QtGraphicsView* view = getView();
QtGraphNode* node = view->getNodeAtCursorPosition();
@@ -244,7 +302,7 @@ void QtGraphView::doRebuildGraph(
}
QPointF center = itemsBoundingRect(m_nodes).center();
Vec2i o = GraphPostprocessor::alignOnRaster(Vec2i(center.x(), center.y()));
Vec2i o = GraphViewStyle::alignOnRaster(Vec2i(center.x(), center.y()));
QPointF offset = QPointF(o.x, o.y);
m_sceneRectOffset = offset - center;
@@ -282,6 +340,9 @@ void QtGraphView::doRebuildGraph(
m_activeNode.reset();
}
m_scrollToTop = params.scrollToTop;
m_isIndexedList = params.isIndexedList;
if (params.animatedTransition && ApplicationSettings::getInstance()->getUseAnimations())
{
createTransition();
@@ -364,12 +425,17 @@ std::shared_ptr<QtGraphNode> QtGraphView::createNodeRecursive(
}
else if (node->isBundleNode())
{
newNode = std::make_shared<QtGraphNodeBundle>(node->tokenId, node->getBundledNodeCount(), node->name);
newNode = std::make_shared<QtGraphNodeBundle>(
node->tokenId, node->getBundledNodeCount(), node->bundledNodeType, node->name);
}
else if (node->isQualifierNode())
{
newNode = std::make_shared<QtGraphNodeQualifier>(node->qualifierName);
}
else if (node->isTextNode())
{
newNode = std::make_shared<QtGraphNodeText>(node->name);
}
newNode->setPosition(node->position);
newNode->setSize(node->size);
@@ -384,7 +450,7 @@ std::shared_ptr<QtGraphNode> QtGraphView::createNodeRecursive(
{
newNode->setParent(parentNode);
}
else
else if (!node->isTextNode())
{
newNode->addComponent(std::make_shared<QtGraphNodeComponentMoveable>(newNode));
}
@@ -624,9 +690,9 @@ void QtGraphView::createTransition()
anim->setDuration(300);
if (!remainingNodes.size())
if (!remainingNodes.size() || m_scrollToTop)
{
connect(anim, SIGNAL(finished()), this, SLOT(centerScrollBars()));
connect(anim, SIGNAL(finished()), this, SLOT(updateScrollBars()));
}
remain->addAnimation(anim);
+4 -1
View File
@@ -49,9 +49,10 @@ public:
virtual Vec2i getViewSize() const;
private slots:
void centerScrollBars();
void updateScrollBars();
void finishedTransition();
void clickedInEmptySpace();
void pressedCharacterKey(QChar c);
private:
void switchToNewGraphData();
@@ -112,6 +113,8 @@ private:
std::list<std::shared_ptr<QtGraphNode>> m_oldNodes;
std::shared_ptr<QtGraphNode> m_activeNode;
bool m_scrollToTop;
bool m_isIndexedList;
std::shared_ptr<QSequentialAnimationGroup> m_transition;
QPointF m_sceneRectOffset;
@@ -5,15 +5,12 @@
#include <QGraphicsSceneEvent>
#include <QPen>
#include "utility/ResourcePaths.h"
#include "component/controller/helper/GraphPostprocessor.h"
#include "qt/graphics/QtRoundedRectItem.h"
#include "qt/utility/QtDeviceScaledPixmap.h"
#include "qt/utility/utilityQt.h"
#include "qt/view/graphElements/nodeComponents/QtGraphNodeComponent.h"
#include "qt/view/graphElements/QtGraphEdge.h"
#include "utility/ResourcePaths.h"
void QtGraphNode::blendIn()
{
@@ -250,6 +247,11 @@ bool QtGraphNode::isQualifierNode() const
return false;
}
bool QtGraphNode::isTextNode() const
{
return false;
}
Id QtGraphNode::getTokenId() const
{
return 0;
@@ -277,7 +279,7 @@ void QtGraphNode::addSubNode(const std::shared_ptr<QtGraphNode>& node)
void QtGraphNode::moved(const Vec2i& oldPosition)
{
setPosition(GraphPostprocessor::alignOnRaster(getPosition()));
setPosition(GraphViewStyle::alignOnRaster(getPosition()));
}
void QtGraphNode::onClick()
@@ -77,6 +77,7 @@ public:
virtual bool isExpandToggleNode() const;
virtual bool isBundleNode() const;
virtual bool isQualifierNode() const;
virtual bool isTextNode() const;
virtual Id getTokenId() const;
@@ -8,9 +8,10 @@
#include "component/view/GraphViewStyle.h"
#include "qt/graphics/QtCountCircleItem.h"
QtGraphNodeBundle::QtGraphNodeBundle(Id tokenId, size_t nodeCount, std::string name)
QtGraphNodeBundle::QtGraphNodeBundle(Id tokenId, size_t nodeCount, Node::NodeType type, std::string name)
: QtGraphNode()
, m_tokenId(tokenId)
, m_type(type)
{
this->setName(name);
@@ -38,12 +39,24 @@ Id QtGraphNodeBundle::getTokenId() const
void QtGraphNodeBundle::onClick()
{
MessageGraphNodeBundleSplit(m_tokenId).dispatch();
MessageGraphNodeBundleSplit(
m_tokenId,
m_type != Node::NODE_UNDEFINED && getName() != "Anonymous Namespaces",
m_type != Node::NODE_UNDEFINED
).dispatch();
}
void QtGraphNodeBundle::updateStyle()
{
GraphViewStyle::NodeStyle style = GraphViewStyle::getStyleOfBundleNode(m_isHovering);
GraphViewStyle::NodeStyle style;
if (m_type != Node::NODE_UNDEFINED)
{
style = GraphViewStyle::getStyleForNodeType(m_type, true, false, m_isHovering, false, false);
}
else
{
style = GraphViewStyle::getStyleOfBundleNode(m_isHovering);
}
setStyle(style);
m_circle->setPosition(Vec2f(m_rect->rect().right() - 3, m_rect->rect().top() + 3));
@@ -1,6 +1,7 @@
#ifndef QT_GRAPH_NODE_BUNDLE_H
#define QT_GRAPH_NODE_BUNDLE_H
#include "data/graph/Node.h"
#include "qt/view/graphElements/QtGraphNode.h"
class QtCountCircleItem;
@@ -9,7 +10,7 @@ class QtGraphNodeBundle
: public QtGraphNode
{
public:
QtGraphNodeBundle(Id tokenId, size_t nodeCount, std::string name);
QtGraphNodeBundle(Id tokenId, size_t nodeCount, Node::NodeType type, std::string name);
virtual ~QtGraphNodeBundle();
// QtGraphNode implementation
@@ -27,6 +28,7 @@ protected:
private:
QtCountCircleItem* m_circle;
Id m_tokenId;
Node::NodeType m_type;
};
#endif // QT_GRAPH_NODE_BUNDLE_H
@@ -0,0 +1,20 @@
#include "qt/view/graphElements/QtGraphNodeText.h"
QtGraphNodeText::QtGraphNodeText(const std::string& name)
{
setName(name);
}
QtGraphNodeText::~QtGraphNodeText()
{
}
bool QtGraphNodeText::isTextNode() const
{
return true;
}
void QtGraphNodeText::updateStyle()
{
setStyle(GraphViewStyle::getStyleOfTextNode());
}
@@ -0,0 +1,19 @@
#ifndef QT_GRAPH_NODE_TEXT_H
#define QT_GRAPH_NODE_TEXT_H
#include "qt/view/graphElements/QtGraphNode.h"
class QtGraphNodeText
: public QtGraphNode
{
public:
QtGraphNodeText(const std::string& name);
virtual ~QtGraphNodeText();
// QtGraphNode implementation
virtual bool isTextNode() const;
virtual void updateStyle();
};
#endif // QT_GRAPH_NODE_TEXT_H