src: fixed clang warnings, fixed undefined symbols logs, fixed code convention violations

This commit is contained in:
Eberhard Graether
2014-07-21 01:26:35 +02:00
parent 0c570d54af
commit 0d46de871a
30 changed files with 166 additions and 172 deletions
+2
View File
@@ -19,5 +19,7 @@ void QtButton::setCallbackOnClick(std::function<void(void)> callback)
void QtButton::slotOnClick()
{
if (m_onClick)
{
m_onClick();
}
}
+1
View File
@@ -2,6 +2,7 @@
#define QT_THREADED_FUCTOR_H
#include <functional>
#include <QObject>
#include <QSemaphore>
+38 -42
View File
@@ -1,15 +1,12 @@
#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 <QBoxLayout>
#include <QFrame>
#include <QGraphicsScene>
#include <QGraphicsView>
#include "qt/QtWidgetWrapper.h"
#include "qt/utility/utilityQt.h"
#include "qt/view/graphElements/QtGraphEdge.h"
#include "qt/view/graphElements/QtGraphNode.h"
#include "qt/view/graphElements/QtGraphNodeMouseMovable.h"
@@ -68,8 +65,6 @@ QGraphicsView* QtGraphView::getView()
{
QWidget* widget = QtWidgetWrapper::getWidgetOfView(this);
QLayout* layout = widget->layout();
QObjectList children = widget->children();
return widget->findChild<QGraphicsView*>("");
@@ -81,12 +76,15 @@ void QtGraphView::doRebuildGraph(const std::vector<DummyNode>& nodes, const std:
if (view != NULL)
{
std::map<Id, std::weak_ptr<GraphNode>> weakNodes; // used when creating the edges
std::list<std::shared_ptr<GraphNode>> newNodes; // temporary stores all nodes (existing and newly created) needed in the new graph
// this is a relatively easy and cheap way to save existing nodes that are still needed
// Used when creating the edges.
std::map<Id, std::weak_ptr<GraphNode>> weakNodes;
// Temporary stores all nodes (existing and newly created) needed in the new graph
// this is a relatively easy and cheap way to save existing nodes that are still needed
std::list<std::shared_ptr<GraphNode>> newNodes;
// create nodes (or find existing nodes for re-use)
for(unsigned int i = 0; i < nodes.size(); i++)
for (unsigned int i = 0; i < nodes.size(); i++)
{
std::shared_ptr<GraphNode> newNode = findOrCreateNode(view, nodes[i]);
newNode->setPosition(nodes[i].position);
@@ -97,10 +95,10 @@ void QtGraphView::doRebuildGraph(const std::vector<DummyNode>& nodes, const std:
doClear();
m_nodes = newNodes;
for(unsigned int i = 0; i < edges.size(); i++)
for (unsigned int i = 0; i < edges.size(); i++)
{
std::shared_ptr<GraphEdge> edge = createEdge(view, edges[i]);
if(edge != NULL)
if (edge != NULL)
{
m_edges.push_back(edge);
}
@@ -124,7 +122,7 @@ std::shared_ptr<GraphNode> QtGraphView::findOrCreateNode(QGraphicsView* view, co
result = findNode(node.tokenId);
if(result == NULL)
if (result == NULL)
{
result = createNode(view, node);
}
@@ -134,18 +132,16 @@ std::shared_ptr<GraphNode> QtGraphView::findOrCreateNode(QGraphicsView* view, co
std::shared_ptr<GraphNode> QtGraphView::findNode(const Id id)
{
std::list<std::shared_ptr<GraphNode>>::iterator it = m_nodes.begin();
for(it; it != m_nodes.end(); it++)
for (std::list<std::shared_ptr<GraphNode>>::iterator it = m_nodes.begin(); it != m_nodes.end(); it++)
{
if((*it)->getTokenId() == id)
if ((*it)->getTokenId() == id)
{
return *it;
}
else
{
std::shared_ptr<GraphNode> result = findSubNode(*it, id);
if(result != NULL)
if (result != NULL)
{
return result;
}
@@ -159,17 +155,16 @@ std::shared_ptr<GraphNode> QtGraphView::findSubNode(const std::shared_ptr<GraphN
{
std::list<std::shared_ptr<GraphNode>> subNodes = node->getSubNodes();
std::list<std::shared_ptr<GraphNode>>::iterator it = subNodes.begin();
for(it; it != subNodes.end(); it++)
for (std::list<std::shared_ptr<GraphNode>>::iterator it = subNodes.begin(); it != subNodes.end(); it++)
{
if((*it)->getTokenId() == id)
if ((*it)->getTokenId() == id)
{
return *it;
}
else
{
std::shared_ptr<GraphNode> result = findSubNode(*it, id);
if(result != NULL)
if (result != NULL)
{
return result;
}
@@ -181,19 +176,20 @@ std::shared_ptr<GraphNode> QtGraphView::findSubNode(const std::shared_ptr<GraphN
std::shared_ptr<GraphNode> QtGraphView::createNode(QGraphicsView* view, const DummyNode& node)
{
if(view != NULL)
if (view != NULL)
{
std::shared_ptr<QtGraphNodeMouseMovable> newNode = std::make_shared<QtGraphNodeMouseMovable>(Vec2i(0, 0), node.name, node.tokenId);
std::shared_ptr<QtGraphNodeMouseMovable> newNode =
std::make_shared<QtGraphNodeMouseMovable>(Vec2i(0, 0), node.name, node.tokenId);
view->scene()->addItem(newNode.get());
m_nodes.push_back(newNode);
for(unsigned int i = 0; i < node.subNodes.size(); i++)
for (unsigned int i = 0; i < node.subNodes.size(); i++)
{
std::shared_ptr<QtGraphNode> subNode = createSubNode(view, node.subNodes[i]);
subNode->setParentItem(newNode.get());
newNode->addSubNode(subNode);
subNode->setRect(0, 0, 80, 20);
subNode->moveBy(10, (i+1)*30);
subNode->moveBy(10, (i + 1) * 30);
}
newNode->setRect(0, 0, 100, 40 + (node.subNodes.size() * 30));
@@ -209,18 +205,18 @@ std::shared_ptr<GraphNode> QtGraphView::createNode(QGraphicsView* view, const Du
std::shared_ptr<QtGraphNode> QtGraphView::createSubNode(QGraphicsView* view, const DummyNode& node)
{
if(view != NULL)
if (view != NULL)
{
std::shared_ptr<QtGraphNode> newNode = std::make_shared<QtGraphNode>(Vec2i(0, 0), node.name, node.tokenId);
view->scene()->addItem(newNode.get());
for(unsigned int i = 0; i < node.subNodes.size(); i++)
for (unsigned int i = 0; i < node.subNodes.size(); i++)
{
std::shared_ptr<QtGraphNode> subNode = createSubNode(view, node.subNodes[i]);
subNode->setParentItem(newNode.get());
newNode->addSubNode(subNode);
subNode->setRect(0, 0, 80, 20);
subNode->moveBy(10, (i+1)*30);
subNode->moveBy(10, (i + 1) * 30);
}
return newNode;
@@ -234,33 +230,33 @@ std::shared_ptr<QtGraphNode> QtGraphView::createSubNode(QGraphicsView* view, con
std::shared_ptr<QtGraphEdge> QtGraphView::createEdge(QGraphicsView* view, const DummyEdge& edge)
{
if(view != NULL)
if (view != NULL)
{
std::shared_ptr<GraphNode> owner = findNode(edge.ownerId);
std::shared_ptr<GraphNode> target = findNode(edge.targetId);
if(owner != NULL && target != NULL)
if (owner != NULL && target != NULL)
{
std::shared_ptr<QtGraphEdge> qtEdge = std::make_shared<QtGraphEdge>(owner, target, edge.tokenId);
switch(edge.edgeType)
switch (edge.edgeType)
{
case Edge::EdgeType::EDGE_CALL:
case Edge::EDGE_CALL:
qtEdge->setColor(m_edgeColors[0]);
break;
case Edge::EdgeType::EDGE_USAGE:
case Edge::EDGE_USAGE:
qtEdge->setColor(m_edgeColors[1]);
break;
case Edge::EdgeType::EDGE_TYPE_OF:
case Edge::EDGE_TYPE_OF:
qtEdge->setColor(m_edgeColors[2]);
break;
case Edge::EdgeType::EDGE_RETURN_TYPE_OF:
case Edge::EDGE_RETURN_TYPE_OF:
qtEdge->setColor(m_edgeColors[3]);
break;
case Edge::EdgeType::EDGE_PARAMETER_TYPE_OF:
case Edge::EDGE_PARAMETER_TYPE_OF:
qtEdge->setColor(m_edgeColors[4]);
break;
case Edge::EdgeType::EDGE_INHERITANCE:
case Edge::EDGE_INHERITANCE:
qtEdge->setColor(m_edgeColors[5]);
break;
default:
+2 -4
View File
@@ -1,20 +1,18 @@
#ifndef QT_GRAPH_VIEW_H
#define QT_GRAPH_VIEW_H
#include "component/view/GraphView.h"
#include "qt/utility/QtThreadedFunctor.h"
#include "utility/math/Vector4.h"
#include "utility/types.h"
#include "component/view/GraphView.h"
struct DummyEdge;
struct DummyNode;
class QGraphicsView;
class QtGraphEdge;
class QtGraphNode;
class QtGraphView : public GraphView
class QtGraphView: public GraphView
{
public:
QtGraphView(ViewLayout* viewLayout);
+3
View File
@@ -97,7 +97,10 @@ void QtSearchView::doSetAutocompletionList(const std::vector<std::string>& autoc
{
QStringList wordList;
for (const std::string& s: autocompletionList)
{
wordList << s.c_str();
}
QCompleter *completer = new QCompleter(wordList, m_searchBox);
completer->popup()->setObjectName("search_box_popup");
completer->setCaseSensitivity(Qt::CaseInsensitive);
+1
View File
@@ -34,6 +34,7 @@ private:
QtEditBox* m_searchBox;
QtButton* m_searchButton;
QtButton* m_caseSensitiveButton;
QtThreadedFunctor<const std::string&> m_setTextFunctor;
QtThreadedFunctor<> m_setFocusFunctor;
QtThreadedFunctor<const std::vector<std::string>&> m_setAutocompletionListFunctor;
@@ -1,7 +1,7 @@
#include "qt/view/graphElements/QtGraphEdge.h"
#include "qgraphicsscene.h"
#include "qpen.h"
#include <QGraphicsScene>
#include <QPen>
#include "component/view/graphElements/GraphNode.h"
@@ -67,7 +67,7 @@ void QtGraphEdge::removeEdgeFromScene()
{
std::shared_ptr<GraphNode> node = m_owner.lock();
if(node != NULL)
if (node != NULL)
{
node->removeOutEdge(this);
}
+5 -6
View File
@@ -3,17 +3,16 @@
#include <memory>
#include "qgraphicsitem.h"
#include "utility/messaging/type/MessageActivateToken.h"
#include <QGraphicsItem>
#include "component/view/graphElements/GraphEdge.h"
#include "utility/messaging/type/MessageActivateToken.h"
class GraphNode;
class QtGraphEdge:
public GraphEdge,
public QGraphicsLineItem
class QtGraphEdge
: public GraphEdge
, public QGraphicsLineItem
{
public:
QtGraphEdge(const std::weak_ptr<GraphNode>& owner, const std::weak_ptr<GraphNode>& target, const Id id);
+16 -20
View File
@@ -2,8 +2,8 @@
#include <sstream>
#include "qgraphicsscene.h"
#include "qgraphicssceneevent.h"
#include <QGraphicsScene>
#include <QGraphicsSceneEvent>
#include "qt/view/graphElements/QtGraphEdge.h"
@@ -24,11 +24,10 @@ QtGraphNode::QtGraphNode(const Vec2i& position, const std::string& name, const I
QtGraphNode::~QtGraphNode()
{
std::list<std::weak_ptr<GraphEdge> >::iterator it = m_inEdges.begin();
for(it; it != m_inEdges.end(); it++)
for (std::list<std::weak_ptr<GraphEdge>>::iterator it = m_inEdges.begin(); it != m_inEdges.end(); it++)
{
std::shared_ptr<GraphEdge> edge = it->lock();
if(edge != NULL)
if (edge != NULL)
{
edge->removeEdgeFromScene();
}
@@ -50,7 +49,7 @@ void QtGraphNode::setPosition(const Vec2i& position)
Vec2i currentPosition = getPosition();
Vec2i offset = position - currentPosition;
if(offset.getLength() > 0.0f)
if (offset.getLength() > 0.0f)
{
this->moveBy(offset.x, offset.y);
notifyEdgesAfterMove();
@@ -59,10 +58,10 @@ void QtGraphNode::setPosition(const Vec2i& position)
bool QtGraphNode::addOutEdge(const std::shared_ptr<GraphEdge>& edge)
{
std::list<std::shared_ptr<GraphEdge> >::iterator it = m_outEdges.begin();
for(it; it != m_outEdges.end(); it++)
for (std::list<std::shared_ptr<GraphEdge>>::iterator it = m_outEdges.begin(); it != m_outEdges.end(); it++)
{
if ((*it)->getOwner().lock() == edge->getOwner().lock() && (*it)->getTarget().lock() == edge->getTarget().lock())
if ((*it)->getOwner().lock() == edge->getOwner().lock() &&
(*it)->getTarget().lock() == edge->getTarget().lock())
{
return false;
}
@@ -74,11 +73,10 @@ bool QtGraphNode::addOutEdge(const std::shared_ptr<GraphEdge>& edge)
bool QtGraphNode::addInEdge(const std::weak_ptr<GraphEdge>& edge)
{
std::list<std::weak_ptr<GraphEdge> >::iterator it = m_inEdges.begin();
for(it; it != m_inEdges.end(); it++)
for (std::list<std::weak_ptr<GraphEdge> >::iterator it = m_inEdges.begin(); it != m_inEdges.end(); it++)
{
std::shared_ptr<GraphEdge> existingEdge = it->lock();
if(existingEdge != NULL)
if (existingEdge != NULL)
{
if (existingEdge->getOwner().lock() == edge.lock()->getOwner().lock() &&
existingEdge->getTarget().lock() == edge.lock()->getTarget().lock())
@@ -95,9 +93,9 @@ bool QtGraphNode::addInEdge(const std::weak_ptr<GraphEdge>& edge)
void QtGraphNode::removeOutEdge(GraphEdge* edge)
{
std::list<std::shared_ptr<GraphEdge> >::iterator it = m_outEdges.begin();
while(it != m_outEdges.end())
while (it != m_outEdges.end())
{
if((*it).get() == edge)
if ((*it).get() == edge)
{
m_outEdges.erase(it);
break;
@@ -130,17 +128,16 @@ void QtGraphNode::notifyParentMoved()
void QtGraphNode::notifyEdgesAfterMove()
{
std::list<std::shared_ptr<GraphEdge> >::iterator it = m_outEdges.begin();
for(it; it != m_outEdges.end(); it++)
for (std::list<std::shared_ptr<GraphEdge> >::iterator it = m_outEdges.begin(); it != m_outEdges.end(); it++)
{
(*it)->ownerMoved();
}
std::list<std::weak_ptr<GraphEdge> >::iterator it2 = m_inEdges.begin();
while(it2 != m_inEdges.end())
while (it2 != m_inEdges.end())
{
std::shared_ptr<GraphEdge> edge = it2->lock();
if(edge.get() != NULL)
if (edge.get() != NULL)
{
edge->targetMoved();
++it2;
@@ -151,8 +148,7 @@ void QtGraphNode::notifyEdgesAfterMove()
}
}
std::list<std::shared_ptr<GraphNode> >::iterator it3 = m_subNodes.begin();
for(it3; it3 != m_subNodes.end(); it3++)
for (std::list<std::shared_ptr<GraphNode> >::iterator it3 = m_subNodes.begin(); it3 != m_subNodes.end(); it3++)
{
(*it3)->notifyParentMoved();
}
+5 -6
View File
@@ -1,18 +1,17 @@
#ifndef QT_GRAPH_NODE_H
#define QT_GRAPH_NODE_H
#include "qgraphicsitem.h"
#include <QGraphicsItem>
#include "component/view/graphElements/GraphNode.h"
#include "utility/messaging/type/MessageActivateToken.h"
#include "utility/math/Vector2.h"
#include "component/view/graphElements/GraphNode.h"
class QtGraphEdge;
class QtGraphNode:
public GraphNode,
public QGraphicsRectItem
class QtGraphNode
: public GraphNode
, public QGraphicsRectItem
{
public:
QtGraphNode(const Vec2i& position, const std::string& name, const Id tokenId);