node border

master
Denes Matetelki 14 years ago
commit 96b07fc1e5

@ -16,12 +16,18 @@ Edge::Edge(Node *sourceNode, Node *destNode)
setAcceptedMouseButtons(0); setAcceptedMouseButtons(0);
m_sourceNode = sourceNode; m_sourceNode = sourceNode;
m_destNode = destNode; m_destNode = destNode;
m_sourceNode->addEdge(this); m_sourceNode->addEdge(this,true);
m_destNode->addEdge(this); m_destNode->addEdge(this,false);
adjust(); adjust();
// setZValue(1); // setZValue(1);
} }
Edge::~Edge()
{
m_sourceNode->removeEdge(this);
m_destNode->removeEdge(this);
}
Node *Edge::sourceNode() const Node *Edge::sourceNode() const
{ {
return m_sourceNode; return m_sourceNode;
@ -32,7 +38,10 @@ Node *Edge::destNode() const
return m_destNode; return m_destNode;
} }
/// @note This is brute force. Isn't there a simple fv for this? /** @note This is brute force. Isn't there a simple fv for this?
* The precision is not the best either
*/
QPointF firstNotContainedPoint(const QLineF &line, QPointF firstNotContainedPoint(const QLineF &line,
const QRectF &rect, const QRectF &rect,
bool reverse = false) bool reverse = false)
@ -104,15 +113,26 @@ void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
return; return;
// Draw the arrows // Draw the arrows
double angle = ::acos(line.dx() / line.length()); m_angle = ::acos(line.dx() / line.length());
if (line.dy() >= 0) if (line.dy() >= 0)
angle = TwoPi - angle; m_angle = TwoPi - m_angle;
qDebug() << m_angle;
QPointF destArrowP1 = m_destPoint + QPointF(sin(angle - Pi / 3) * m_arrowSize, QPointF destArrowP1 = m_destPoint + QPointF(sin(m_angle - Pi / 3) * m_arrowSize,
cos(angle - Pi / 3) * m_arrowSize); cos(m_angle - Pi / 3) * m_arrowSize);
QPointF destArrowP2 = m_destPoint + QPointF(sin(angle - Pi + Pi / 3) * m_arrowSize, QPointF destArrowP2 = m_destPoint + QPointF(sin(m_angle - Pi + Pi / 3) * m_arrowSize,
cos(angle - Pi + Pi / 3) * m_arrowSize); cos(m_angle - Pi + Pi / 3) * m_arrowSize);
painter->setBrush(Qt::black); painter->setBrush(Qt::black);
painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2); painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2);
} }
double Edge::getAngle() const
{
qDebug() << __PRETTY_FUNCTION__;
qDebug() << m_angle;
return m_angle;
}

@ -10,9 +10,11 @@ class Edge : public QGraphicsItem
public: public:
Edge(Node *sourceNode, Node *destNode); Edge(Node *sourceNode, Node *destNode);
~Edge();
Node *sourceNode() const; Node *sourceNode() const;
Node *destNode() const; Node *destNode() const;
double getAngle() const;
void adjust(); void adjust();
@ -29,7 +31,7 @@ private:
QPointF m_sourcePoint; QPointF m_sourcePoint;
QPointF m_destPoint; QPointF m_destPoint;
qreal m_arrowSize; qreal m_arrowSize;
double m_angle;
}; };
#endif #endif

@ -1,15 +1,22 @@
#include "graphwidget.h" #include "graphwidget.h"
#include <QDebug> #include <QDebug>
#include "node.h" #include <QStatusBar>
//#include <QGraphicsTextItem> #include "node.h"
#include "edge.h" #include "edge.h"
#include "math.h" #include "math.h"
#include "mainwindow.h"
GraphWidget::GraphWidget(QWidget *parent) : GraphWidget::GraphWidget(QWidget *parent) :
QGraphicsView(parent), QGraphicsView(parent),
m_parent(parent),
m_activeNode(0), m_activeNode(0),
m_showingNodeNumbers(false) m_showingNodeNumbers(false),
m_followNode(0)
{ {
qDebug() << __PRETTY_FUNCTION__; qDebug() << __PRETTY_FUNCTION__;
@ -60,14 +67,58 @@ GraphWidget::GraphWidget(QWidget *parent) :
node6->setPos(-10, 100); node6->setPos(-10, 100);
m_nodeList.append(node6); m_nodeList.append(node6);
Node *node7 = new Node(this);
node7->setHtml(QString("node <h1>important</h1> shit"));
m_scene->addItem(node7);
node7->setPos(-200, 50);
m_nodeList.append(node7);
Node *node8 = new Node(this);
node8->setHtml(QString("more than\none lins"));
m_scene->addItem(node8);
node8->setPos(50, -80);
m_nodeList.append(node8);
Node *node9 = new Node(this);
node9->setHtml(QString("iam a <b>bald</b> and <i>italian</i> guy"));
m_scene->addItem(node9);
node9->setPos(50, 40);
m_nodeList.append(node9);
Node *node10 = new Node(this);
node10->setHtml(QString("no joke"));
m_scene->addItem(node10);
node10->setPos(-160, -10);
m_nodeList.append(node10);
Node *node11 = new Node(this);
node11->setHtml(QString("salalal"));
m_scene->addItem(node11);
node11->setPos(-120, -120);
m_nodeList.append(node11);
Node *node12 = new Node(this);
node12->setHtml(QString("lalalala"));
m_scene->addItem(node12);
node12->setPos(130, -10);
m_nodeList.append(node12);;
m_scene->addItem(new Edge(node1, node2)); m_scene->addItem(new Edge(node1, node2));
m_scene->addItem(new Edge(node1, node3)); m_scene->addItem(new Edge(node1, node3));
m_scene->addItem(new Edge(node3, node4)); m_scene->addItem(new Edge(node3, node4));
m_scene->addItem(new Edge(node1, node5)); m_scene->addItem(new Edge(node1, node5));
m_scene->addItem(new Edge(node5, node6)); m_scene->addItem(new Edge(node5, node6));
m_scene->addItem(new Edge(node4, node11));
m_scene->addItem(new Edge(node2, node12));
m_scene->addItem(new Edge(node3, node10));
m_scene->addItem(new Edge(node10, node7));
m_scene->addItem(new Edge(node5, node7));
m_scene->addItem(new Edge(node2, node8));
m_scene->addItem(new Edge(node2, node9));
m_activeNode = m_nodeList.first(); m_activeNode = m_nodeList.first();
m_activeNode->setActive(true); m_activeNode->setActive();
} }
QGraphicsScene *GraphWidget::getScene() QGraphicsScene *GraphWidget::getScene()
@ -78,19 +129,23 @@ QGraphicsScene *GraphWidget::getScene()
void GraphWidget::keyPressEvent(QKeyEvent *event) void GraphWidget::keyPressEvent(QKeyEvent *event)
{ {
qDebug() << __PRETTY_FUNCTION__; qDebug() << __PRETTY_FUNCTION__;
// qDebug() << event->key(); qDebug() << event->key();
switch (event->key()) { switch (event->key()) {
case Qt::Key_Up: case Qt::Key_Up:
if (m_activeNode)
m_activeNode->moveBy(0, -20); m_activeNode->moveBy(0, -20);
break; break;
case Qt::Key_Down: case Qt::Key_Down:
if (m_activeNode)
m_activeNode->moveBy(0, 20); m_activeNode->moveBy(0, 20);
break; break;
case Qt::Key_Left: case Qt::Key_Left:
if (m_activeNode)
m_activeNode->moveBy(-20, 0); m_activeNode->moveBy(-20, 0);
break; break;
case Qt::Key_Right: case Qt::Key_Right:
if (m_activeNode)
m_activeNode->moveBy(20, 0); m_activeNode->moveBy(20, 0);
break; break;
case Qt::Key_Plus: case Qt::Key_Plus:
@ -100,11 +155,29 @@ void GraphWidget::keyPressEvent(QKeyEvent *event)
scaleView(1 / qreal(1.2)); scaleView(1 / qreal(1.2));
break; break;
case Qt::Key_F: case Qt::Key_F:
{ // need brackets because of local variable
m_showingNodeNumbers = !m_showingNodeNumbers; m_showingNodeNumbers = !m_showingNodeNumbers;
int i =0; if (m_showingNodeNumbers)
for (QList<Node *>::const_iterator it = m_nodeList.begin(); it != m_nodeList.end(); it++, i++) m_followNumber.clear();
dynamic_cast<Node*>(*it)->showNumber(i,m_showingNodeNumbers);
showingAllNodeNumbers(m_showingNodeNumbers);
if (m_showingNodeNumbers)
{
m_nodeList.first()->showNumber(0,true,true);
m_followNode = m_nodeList.first();
}
break;
case Qt::Key_Insert:
if (!m_activeNode)
{
dynamic_cast<MainWindow *>(m_parent)->getStatusBar()->showMessage(
tr("No active node."),
5000); // millisec
}
else
{
insertNode();
} }
break; break;
@ -118,10 +191,74 @@ void GraphWidget::keyPressEvent(QKeyEvent *event)
case Qt::Key_7: case Qt::Key_7:
case Qt::Key_8: case Qt::Key_8:
case Qt::Key_9: case Qt::Key_9:
if (!m_showingNodeNumbers)
break;
m_followNumber.append(QString::number(event->key()-48));
showingAllNodeNumbers(false);
showingNodeNumbersBeginWithNumber(m_followNumber.toInt(), true);
break;
case Qt::Key_Backspace:
if (!m_showingNodeNumbers)
break;
if (!m_followNumber.isEmpty())
{
m_followNumber.remove(m_followNumber.length()-1,1);
if (m_followNumber.isEmpty())
{
showingAllNodeNumbers(true);
m_nodeList.first()->showNumber(0,true,true);
m_followNode = m_nodeList.first();
}
else
{
showingAllNodeNumbers(false);
showingNodeNumbersBeginWithNumber(m_followNumber.toInt(), true);
}
}
break;
case Qt::Key_Return:
case Qt::Key_Enter:
if (m_followNode && m_showingNodeNumbers)
{
qDebug() << m_activeNode;
qDebug() << m_followNode;
showingAllNodeNumbers(false);
if (m_activeNode)
m_activeNode->setActive(false); m_activeNode->setActive(false);
m_activeNode = m_nodeList[3]; m_activeNode = m_followNode;
m_activeNode->setActive(true); m_activeNode->setActive();
m_showingNodeNumbers = false;
}
break;
case Qt::Key_Delete:
if (m_activeNode)
{
if (m_followNode==m_activeNode)
m_followNode=0;
m_nodeList.removeAll(m_activeNode);
delete m_activeNode;
m_activeNode = 0;
if (m_showingNodeNumbers)
{
m_showingNodeNumbers = false;
showingAllNodeNumbers(false);
}
}
else
{
dynamic_cast<MainWindow *>(m_parent)->getStatusBar()->showMessage(
tr("No active node."),
5000); // millisec
}
break; break;
@ -159,7 +296,6 @@ void GraphWidget::scaleView(qreal scaleFactor)
scale(scaleFactor, scaleFactor); scale(scaleFactor, scaleFactor);
} }
/// @note this == 0? how is it possible?
void GraphWidget::setActiveNode(Node *node) void GraphWidget::setActiveNode(Node *node)
{ {
qDebug() << __PRETTY_FUNCTION__; qDebug() << __PRETTY_FUNCTION__;
@ -168,5 +304,80 @@ void GraphWidget::setActiveNode(Node *node)
m_activeNode->setActive(false); m_activeNode->setActive(false);
m_activeNode = node; m_activeNode = node;
m_activeNode->setActive(true); m_activeNode->setActive();
}
void GraphWidget::insertNode()
{
qDebug() << __PRETTY_FUNCTION__;
double angle(m_activeNode->calculateBiggestAngle());
qreal length(100);
qDebug() << "angle: ";
qDebug() << angle;
QPointF pos(length * cos(angle), length * sin(angle));
qDebug() << pos;
Node *node = new Node(this);
node->setHtml(QString("new node"));
m_scene->addItem(node);
node->setPos(m_activeNode->pos() +
// m_activeNode->boundingRect().center() +
pos);
m_nodeList.append(node);
m_scene->addItem(new Edge(m_activeNode, node));
}
void GraphWidget::showingAllNodeNumbers(const bool &show)
{
int i =0;
for (QList<Node *>::const_iterator it = m_nodeList.begin(); it != m_nodeList.end(); it++, i++)
dynamic_cast<Node*>(*it)->showNumber(i,show);
}
void GraphWidget::showingNodeNumbersBeginWithNumber(const int &number, const bool &show)
{
int i(0);
int hit(0);
for (QList<Node *>::const_iterator it = m_nodeList.begin(); it != m_nodeList.end(); it++, i++)
{
if (i == number)
{
hit++;
dynamic_cast<Node*>(*it)->showNumber(i,show,true);
m_followNode = dynamic_cast<Node*>(*it);
continue;
}
if (numberStartsWithNumber(i, number))
{
hit++;
dynamic_cast<Node*>(*it)->showNumber(i,show);
}
}
if (hit==1)
{
showingAllNodeNumbers(false);
if (m_activeNode)
m_activeNode->setActive(false);
m_activeNode = m_followNode;
m_activeNode->setActive();
m_showingNodeNumbers = false;
}
else if (hit == 0)
{
m_showingNodeNumbers = false;
showingAllNodeNumbers(false);
}
}
bool GraphWidget::numberStartsWithNumber(const int &number, const int &prefix)
{
return (QString::number(number)).startsWith(QString::number(prefix));
} }

@ -17,6 +17,7 @@ public:
GraphWidget(QWidget *parent = 0); GraphWidget(QWidget *parent = 0);
QGraphicsScene *getScene(); QGraphicsScene *getScene();
void setActiveNode(Node *node); void setActiveNode(Node *node);
void insertNode();
protected: protected:
@ -28,11 +29,18 @@ protected:
private: private:
void showingAllNodeNumbers(const bool &show = true);
void showingNodeNumbersBeginWithNumber(const int &number, const bool &show = true);
bool numberStartsWithNumber(const int &number, const int &prefix);
qreal calculateBiggestAngle(Node *node);
QList<Node *> m_nodeList; QList<Node *> m_nodeList;
QWidget *m_parent;
Node *m_activeNode; Node *m_activeNode;
QGraphicsScene *m_scene; QGraphicsScene *m_scene;
bool m_showingNodeNumbers; bool m_showingNodeNumbers;
QString m_followNumber;
Node *m_followNode;
}; };

@ -47,7 +47,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(m_ui->actionAbout_QtMindMap, SIGNAL(activated()), this, connect(m_ui->actionAbout_QtMindMap, SIGNAL(activated()), this,
SLOT(about())); SLOT(about()));
m_graphicsView = new GraphWidget(m_ui->centralWidget); m_graphicsView = new GraphWidget(this);
setCentralWidget(m_graphicsView); setCentralWidget(m_graphicsView);
} }
@ -120,3 +120,8 @@ void MainWindow::aboutDestroyed()
setEnabled(true); setEnabled(true);
} }
QStatusBar * MainWindow::getStatusBar()
{
return m_ui->statusBar;
}

@ -18,6 +18,7 @@ class MainWindow : public QMainWindow
public: public:
explicit MainWindow(QWidget *parent = 0); explicit MainWindow(QWidget *parent = 0);
~MainWindow(); ~MainWindow();
QStatusBar * getStatusBar();
public slots: public slots:
void klakk(); void klakk();

@ -55,6 +55,9 @@
</widget> </widget>
<widget class="QStatusBar" name="statusBar"/> <widget class="QStatusBar" name="statusBar"/>
<action name="actionNew"> <action name="actionNew">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>&amp;New</string> <string>&amp;New</string>
</property> </property>
@ -63,6 +66,9 @@
</property> </property>
</action> </action>
<action name="actionOpen"> <action name="actionOpen">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>&amp;Open</string> <string>&amp;Open</string>
</property> </property>
@ -71,6 +77,9 @@
</property> </property>
</action> </action>
<action name="actionSave"> <action name="actionSave">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>&amp;Save</string> <string>&amp;Save</string>
</property> </property>
@ -92,6 +101,9 @@
</property> </property>
</action> </action>
<action name="actionClose"> <action name="actionClose">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>&amp;Close</string> <string>&amp;Close</string>
</property> </property>

@ -5,12 +5,14 @@
#include <QDebug> #include <QDebug>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
static const double Pi = 3.14159265358979323846264338327950288419717;
Node::Node(GraphWidget *parent) : Node::Node(GraphWidget *parent) :
m_graph(parent), m_graph(parent),
m_isActive(false), m_isActive(false),
m_activeEdge(0),
m_number(-1), m_number(-1),
m_hasBorder(true) m_hasBorder(true)
m_numberIsSpecial(false)
{ {
qDebug() << __PRETTY_FUNCTION__; qDebug() << __PRETTY_FUNCTION__;
@ -26,18 +28,35 @@ Node::Node(GraphWidget *parent) :
// setTextInteractionFlags(Qt::TextEditorInteraction); // setTextInteractionFlags(Qt::TextEditorInteraction);
} }
void Node::addEdge(Edge *edge) Node::~Node()
{
qDebug() << __PRETTY_FUNCTION__;
foreach (EdgeElement element, m_edgeList) delete element.edge;
}
void Node::addEdge(Edge *edge, bool startsFromThisNode)
{ {
qDebug() << __PRETTY_FUNCTION__; qDebug() << __PRETTY_FUNCTION__;
m_edgeList << edge; m_edgeList.push_back(EdgeElement(edge, startsFromThisNode));
edge->adjust(); edge->adjust();
} }
void Node::removeEdge(Edge *edge)
{
qDebug() << __PRETTY_FUNCTION__;
for(QList<EdgeElement>::iterator it = m_edgeList.begin(); it != m_edgeList.end(); it++)
if (it->edge == edge)
{
m_edgeList.erase(it);
return;
}
}
QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value) QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
qDebug() << __PRETTY_FUNCTION__; // qDebug() << __PRETTY_FUNCTION__;
switch (change) { switch (change) {
@ -62,7 +81,7 @@ QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
case ItemPositionHasChanged: case ItemPositionHasChanged:
foreach (Edge *edge, m_edgeList) edge->adjust(); foreach (EdgeElement element, m_edgeList) element.edge->adjust();
break; break;
default: default:
break; break;
@ -73,7 +92,13 @@ QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *w) void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *w)
{ {
qDebug() << __PRETTY_FUNCTION__; // qDebug() << __PRETTY_FUNCTION__;
if (m_number != -1)
{
painter->setBackground(m_numberIsSpecial ? Qt::green : Qt::yellow);
painter->setBackgroundMode(Qt::OpaqueMode);
}
QGraphicsTextItem::paint(painter, option, w); QGraphicsTextItem::paint(painter, option, w);
@ -84,12 +109,10 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
boundingRect().bottomRight().toPoint() - boundingRect().bottomRight().toPoint() -
QPoint(1,1))); QPoint(1,1)));
qDebug() << m_number;
if (m_number != -1) if (m_number != -1)
{ {
painter->setPen(Qt::yellow); painter->setPen(Qt::white);
painter->setBackground(Qt::black); painter->setBackground(Qt::red);
painter->setBackgroundMode(Qt::OpaqueMode); painter->setBackgroundMode(Qt::OpaqueMode);
painter->drawText(boundingRect().topLeft()+QPointF(0,11), QString("%1").arg(m_number)); painter->drawText(boundingRect().topLeft()+QPointF(0,11), QString("%1").arg(m_number));
} }
@ -104,34 +127,45 @@ void Node::setActive(const bool &active)
} }
/// @note who shall set active: press or release?
void Node::mousePressEvent(QGraphicsSceneMouseEvent *event) void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
qDebug() << __PRETTY_FUNCTION__; qDebug() << __PRETTY_FUNCTION__;
m_graph->setActiveNode(this);
QGraphicsItem::mousePressEvent(event); QGraphicsItem::mousePressEvent(event);
} }
void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void Node::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{ {
qDebug() << __PRETTY_FUNCTION__; qDebug() << __PRETTY_FUNCTION__;
m_graph->setActiveNode(this); m_graph->insertNode();
QGraphicsItem::mouseDoubleClickEvent(event);
}
void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
QGraphicsItem::mouseReleaseEvent(event); QGraphicsItem::mouseReleaseEvent(event);
} }
void Node::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void Node::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
qDebug() << __PRETTY_FUNCTION__; // qDebug() << __PRETTY_FUNCTION__;
QGraphicsItem::mouseMoveEvent(event); QGraphicsItem::mouseMoveEvent(event);
} }
void Node::showNumber(const int &number, const bool& show) void Node::showNumber(const int &number, const bool& show, const bool &numberIsSpecial)
{ {
qDebug() << __PRETTY_FUNCTION__; // qDebug() << __PRETTY_FUNCTION__;
m_number = show ? number : -1; m_number = show ? number : -1;
m_numberIsSpecial = numberIsSpecial;
update(); update();
} }
@ -140,3 +174,60 @@ void Node::setBorder(const bool &hasBorder)
m_hasBorder = hasBorder; m_hasBorder = hasBorder;
update(); update();
} }
double Node::calculateBiggestAngle()
{
qDebug() << __PRETTY_FUNCTION__;
if (m_edgeList.empty())
return 1.5 * Pi;
if (m_edgeList.size()==1)
{
if (m_edgeList.first().startsFromThisNode)
{
return Pi - m_edgeList.first().edge->getAngle();
}
else
{
return 2 * Pi - m_edgeList.first().edge->getAngle();
}
}
QList<double> tmp;
for(QList<EdgeElement>::iterator it = m_edgeList.begin(); it != m_edgeList.end(); it++)
{
if (it->startsFromThisNode)
{
tmp.push_back(Pi - it->edge->getAngle());
}
else
{
tmp.push_back(2 * Pi - it->edge->getAngle());
}
}
qSort(tmp.begin(), tmp.end());
qDebug() << tmp;
double prev(tmp.last());
double max_prev(tmp.last());
double max(0);
/// @bug algorith is baaad
for(QList<double>::const_iterator it = tmp.begin(); it!=tmp.end(); it++)
{
if (abs(*it - prev) > abs(max) )
{
max = *it - prev;
max_prev = prev;
}
prev = *it;
}
qDebug() << max;
qDebug() << max_prev;
return max_prev + max / 2 ;
}

@ -13,30 +13,49 @@ class Node : public QGraphicsTextItem
public: public:
Node(GraphWidget *graphWidget = 0); Node(GraphWidget *graphWidget = 0);
~Node();
void addEdge(Edge *edge); void addEdge(Edge *edge, bool startsFromThisNode);
void removeEdge(Edge *edge);
// QList<Edge *> edges() const; // QList<Edge *> edges() const;
void setActive(const bool &active);
void showNumber(const int &number, const bool& show);
void setBorder(const bool &hasBorder); void setBorder(const bool &hasBorder);
void setActive(const bool &active = true);
void showNumber(const int &number, const bool& show = true, const bool &numberIsSpecial = false);
double calculateBiggestAngle();
protected: protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
QVariant itemChange(GraphicsItemChange change, const QVariant &value); QVariant itemChange(GraphicsItemChange change, const QVariant &value);
void mousePressEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
private: private:
QList<Edge *> m_edgeList; struct EdgeElement
{
Edge *edge;
bool startsFromThisNode;
EdgeElement(Edge *e, bool s) : edge(e), startsFromThisNode(s) {}
};
// class EdgeList : public QList<EdgeElement>
// {
// public:
// int compareItems(QCollection::Item a, QCollection::Item b)
// {
// return (EdgeElement)a.edge = (EdgeElement)b.edge;
// }
// };
QList<EdgeElement> m_edgeList;
GraphWidget *m_graph; GraphWidget *m_graph;
bool m_isActive; bool m_isActive;
Edge *m_activeEdge; // Edge *m_activeEdge;
int m_number; int m_number;
bool m_hasBorder; bool m_hasBorder;
bool m_numberIsSpecial;
}; };
#endif // NODE_H #endif // NODE_H

@ -182,7 +182,7 @@
<value key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments" type="QString"></value> <value key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments" type="QString"></value>
<value key="Qt4ProjectManager.Qt4RunConfiguration.ProFile" type="QString">qtmindmap.pro</value> <value key="Qt4ProjectManager.Qt4RunConfiguration.ProFile" type="QString">qtmindmap.pro</value>
<value key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix" type="bool">false</value> <value key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix" type="bool">false</value>
<value key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal" type="bool">false</value> <value key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal" type="bool">true</value>
<valuelist key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges" type="QVariantList"/> <valuelist key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString"></value> <value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString"></value>
<value key="RunConfiguration.QmlDebugServerPort" type="uint">3768</value> <value key="RunConfiguration.QmlDebugServerPort" type="uint">3768</value>

Loading…
Cancel
Save