rescale and setcolor on subtrees

master
Denes Matetelki 14 years ago
parent fe8983fce9
commit 6a075518f5

@ -302,20 +302,34 @@ void GraphWidget::keyPressEvent(QKeyEvent *event)
// zoom in/out // zoom in/out
case Qt::Key_Plus: case Qt::Key_Plus:
if (event->modifiers() & Qt::ControlModifier) if (event->modifiers() == Qt::ControlModifier)
{ {
m_activeNode->setScale(qreal(1.2),sceneRect()); m_activeNode->setScale(qreal(1.2),sceneRect());
} }
else if (event->modifiers() & Qt::ControlModifier &&
event->modifiers() & Qt::ShiftModifier)
{
QList <Node *> nodeList = m_activeNode->subtree();
foreach(Node *node, nodeList)
node->setScale(qreal(1.2),sceneRect());
}
else else
{ {
scaleView(qreal(1.2)); scaleView(qreal(1.2));
} }
break; break;
case Qt::Key_Minus: case Qt::Key_Minus:
if (event->modifiers() & Qt::ControlModifier) if (event->modifiers() == Qt::ControlModifier)
{ {
m_activeNode->setScale(qreal(1 / 1.2),sceneRect()); m_activeNode->setScale(qreal(1 / 1.2),sceneRect());
} }
else if (event->modifiers() & Qt::ControlModifier &&
event->modifiers() & Qt::ShiftModifier)
{
QList <Node *> nodeList = m_activeNode->subtree();
foreach(Node *node, nodeList)
node->setScale(qreal(1 / 1.2),sceneRect());
}
else else
{ {
scaleView(1 / qreal(1.2)); scaleView(1 / qreal(1.2));
@ -423,29 +437,53 @@ void GraphWidget::keyPressEvent(QKeyEvent *event)
case Qt::Key_C: case Qt::Key_C:
{ {
QList <Node *> nodeList;
if (event->modifiers() == Qt::ShiftModifier)
{
nodeList = m_activeNode->subtree();
}
else
{
nodeList.push_back(m_activeNode);
}
QColorDialog dialog(this); QColorDialog dialog(this);
dialog.setWindowTitle(tr("Select node color")); dialog.setWindowTitle(tr("Select node color"));
dialog.setCurrentColor(m_activeNode->color()); dialog.setCurrentColor(m_activeNode->color());
if (dialog.exec()) if (dialog.exec())
{ {
QColor color = dialog.selectedColor(); QColor color = dialog.selectedColor();
m_activeNode->setColor(color); foreach(Node *node, nodeList)
foreach (Edge * edge, m_activeNode->edgesToThis(false)) {
node->setColor(color);
foreach (Edge * edge, node->edgesToThis(false))
edge->setColor(color); edge->setColor(color);
} }
}
break; break;
} }
case Qt::Key_T: case Qt::Key_T:
{ {
QList <Node *> nodeList;
if (event->modifiers() == Qt::ShiftModifier)
{
nodeList = m_activeNode->subtree();
}
else
{
nodeList.push_back(m_activeNode);
}
QColorDialog dialog(this); QColorDialog dialog(this);
dialog.setWindowTitle(tr("Select text color")); dialog.setWindowTitle(tr("Select text color"));
dialog.setCurrentColor(m_activeNode->textColor()); dialog.setCurrentColor(m_activeNode->textColor());
if (dialog.exec()) if (dialog.exec())
{ {
QColor color = dialog.selectedColor(); QColor color = dialog.selectedColor();
m_activeNode->setTextColor(color); foreach(Node *node, nodeList)
node->setTextColor(color);
} }
break; break;

Loading…
Cancel
Save