ui: graphView

Added basic graph view with simple nodes (just text, no edges or anything...)

fortune cookie message = Don't be afraid to take that big step.
This commit is contained in:
Manuel Dobusch
2014-07-02 16:14:56 +02:00
parent 5251e3ecb6
commit a8e32af5dd
16 changed files with 220 additions and 2 deletions
+67
View File
@@ -0,0 +1,67 @@
#include "QtGraphView.h"
#include "qboxlayout.h"
#include "qgraphicsitem.h"
#include "qgraphicsproxywidget.h"
#include "qgraphicsscene.h"
#include "qgraphicsview.h"
#include "qpushbutton.h"
#include "qt/utility/utilityQt.h"
#include "qt/QtWidgetWrapper.h"
#include "qt/view/graphElements/QtGraphNode.h"
QtGraphView::QtGraphView(ViewLayout* viewLayout)
: GraphView(viewLayout)
{
}
QtGraphView::~QtGraphView()
{
}
void QtGraphView::createWidgetWrapper()
{
setWidgetWrapper(std::make_shared<QtWidgetWrapper>(std::make_shared<QFrame>()));
}
void QtGraphView::initGui()
{
QWidget* widget = QtWidgetWrapper::getWidgetOfView(this);
utility::setWidgetBackgroundColor(widget, Colori(100, 20, 200, 255));
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
layout->setSpacing(3);
layout->setContentsMargins(3, 3, 3, 3);
widget->setLayout(layout);
QGraphicsScene* scene = new QGraphicsScene(widget);
QGraphicsView* view = new QGraphicsView(widget);
view->setScene(scene);
widget->layout()->addWidget(view);
}
void QtGraphView::addNode(const Vec2i& position, const std::string& name)
{
QWidget* widget = QtWidgetWrapper::getWidgetOfView(this);
QLayout* layout = widget->layout();
QObjectList children = widget->children();
QGraphicsView* view = widget->findChild<QGraphicsView*>("");
if(view != NULL)
{
QtGraphNode* node = new QtGraphNode(position, name);
view->scene()->addItem(node);
node->setFlag(QGraphicsItem::ItemIsMovable);
}
else
{
LOG_WARNING("Unable to retrieve view from widget");
}
}