From bc7ded00629ebf9178e8908b8cba82c507664c55 Mon Sep 17 00:00:00 2001 From: Denes Matetelki Date: Tue, 7 Jun 2011 23:40:23 +0200 Subject: [PATCH] node hasBorder tru/false, center node is the icon --- .gitignore | 6 ++++++ graphwidget.cpp | 3 ++- node.cpp | 16 ++++++++++++---- node.h | 2 ++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 8df47d5..d01fc5b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,7 @@ *.qm +ui_* +*.o +Makefile +moc_* +qrc_* +qtmindmap diff --git a/graphwidget.cpp b/graphwidget.cpp index 6f65cf7..fb890c4 100644 --- a/graphwidget.cpp +++ b/graphwidget.cpp @@ -24,9 +24,10 @@ GraphWidget::GraphWidget(QWidget *parent) : setMinimumSize(400, 400); Node *node1 = new Node(this); - node1->setHtml(QString("me")); + node1->setHtml(QString("")); m_scene->addItem(node1); node1->setPos(-10, -10); + node1->setBorder(false); m_nodeList.append(node1); Node *node2 = new Node(this); diff --git a/node.cpp b/node.cpp index 779e00a..c53c0c5 100644 --- a/node.cpp +++ b/node.cpp @@ -9,7 +9,8 @@ Node::Node(GraphWidget *parent) : m_graph(parent), m_isActive(false), m_activeEdge(0), - m_number(-1) + m_number(-1), + m_hasBorder(true) { 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->drawRect(QRect(boundingRect().topLeft().toPoint(), - boundingRect().bottomRight().toPoint() - - QPoint(1,1))); + if (m_hasBorder) + painter->drawRect(QRect(boundingRect().topLeft().toPoint(), + boundingRect().bottomRight().toPoint() - + QPoint(1,1))); qDebug() << m_number; @@ -132,3 +134,9 @@ void Node::showNumber(const int &number, const bool& show) m_number = show ? number : -1; update(); } + +void Node::setBorder(const bool &hasBorder) +{ + m_hasBorder = hasBorder; + update(); +} diff --git a/node.h b/node.h index 113cfe2..1c89eeb 100644 --- a/node.h +++ b/node.h @@ -18,6 +18,7 @@ public: // QList edges() const; void setActive(const bool &active); void showNumber(const int &number, const bool& show); + void setBorder(const bool &hasBorder); protected: @@ -35,6 +36,7 @@ private: bool m_isActive; Edge *m_activeEdge; int m_number; + bool m_hasBorder; }; #endif // NODE_H