node hasBorder tru/false, center node is the icon

master
Denes Matetelki 14 years ago
parent a6c1ec643f
commit bc7ded0062

6
.gitignore vendored

@ -1 +1,7 @@
*.qm *.qm
ui_*
*.o
Makefile
moc_*
qrc_*
qtmindmap

@ -24,9 +24,10 @@ GraphWidget::GraphWidget(QWidget *parent) :
setMinimumSize(400, 400); setMinimumSize(400, 400);
Node *node1 = new Node(this); Node *node1 = new Node(this);
node1->setHtml(QString("me")); node1->setHtml(QString("<img src=:/heart.svg width=40 height=40></img>"));
m_scene->addItem(node1); m_scene->addItem(node1);
node1->setPos(-10, -10); node1->setPos(-10, -10);
node1->setBorder(false);
m_nodeList.append(node1); m_nodeList.append(node1);
Node *node2 = new Node(this); Node *node2 = new Node(this);

@ -9,7 +9,8 @@ Node::Node(GraphWidget *parent) :
m_graph(parent), m_graph(parent),
m_isActive(false), m_isActive(false),
m_activeEdge(0), m_activeEdge(0),
m_number(-1) m_number(-1),
m_hasBorder(true)
{ {
qDebug() << __PRETTY_FUNCTION__; qDebug() << __PRETTY_FUNCTION__;
@ -78,9 +79,10 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
painter->setPen(m_isActive ? Qt::red : Qt::blue); painter->setPen(m_isActive ? Qt::red : Qt::blue);
painter->drawRect(QRect(boundingRect().topLeft().toPoint(), if (m_hasBorder)
boundingRect().bottomRight().toPoint() - painter->drawRect(QRect(boundingRect().topLeft().toPoint(),
QPoint(1,1))); boundingRect().bottomRight().toPoint() -
QPoint(1,1)));
qDebug() << m_number; qDebug() << m_number;
@ -132,3 +134,9 @@ void Node::showNumber(const int &number, const bool& show)
m_number = show ? number : -1; m_number = show ? number : -1;
update(); update();
} }
void Node::setBorder(const bool &hasBorder)
{
m_hasBorder = hasBorder;
update();
}

@ -18,6 +18,7 @@ public:
// QList<Edge *> edges() const; // QList<Edge *> edges() const;
void setActive(const bool &active); void setActive(const bool &active);
void showNumber(const int &number, const bool& show); void showNumber(const int &number, const bool& show);
void setBorder(const bool &hasBorder);
protected: protected:
@ -35,6 +36,7 @@ private:
bool m_isActive; bool m_isActive;
Edge *m_activeEdge; Edge *m_activeEdge;
int m_number; int m_number;
bool m_hasBorder;
}; };
#endif // NODE_H #endif // NODE_H

Loading…
Cancel
Save