Can not add one point to detail twice

--HG--
branch : feature
This commit is contained in:
Valentina Zhuravska 2015-11-10 10:07:40 +02:00
parent 779117a34f
commit 4c41e04d49

View File

@ -180,31 +180,49 @@ void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &t
return; return;
} }
QListWidgetItem *item = new QListWidgetItem(name); bool canAddNewPoint = false;
item->setFont(QFont("Times", 12, QFont::Bold));
VNodeDetail node(id, typeTool, typeNode, mx, my, reverse);
item->setData(Qt::UserRole, QVariant::fromValue(node));
ui.listWidget->addItem(item);
ui.listWidget->setCurrentRow(ui.listWidget->count()-1);
ui.doubleSpinBoxBiasX->blockSignals(true); if(ui.listWidget->count() == 0)
ui.doubleSpinBoxBiasY->blockSignals(true);
ui.doubleSpinBoxBiasX->setValue(qApp->fromPixel(node.getMx()));
ui.doubleSpinBoxBiasY->setValue(qApp->fromPixel(node.getMy()));
if (node.getTypeTool() == Tool::NodePoint)
{ {
ui.checkBoxReverse->setChecked(false); canAddNewPoint = true;
ui.checkBoxReverse->setEnabled(false);
} }
else else
{ {
ui.checkBoxReverse->setEnabled(true); QString lastItemName = ui.listWidget->item(ui.listWidget->count()-1)->text();
ui.checkBoxReverse->setChecked(node.getReverse()); if(QString::compare(lastItemName, name) != 0)
{
canAddNewPoint = true;
}
} }
ui.doubleSpinBoxBiasX->blockSignals(false); if(canAddNewPoint)
ui.doubleSpinBoxBiasY->blockSignals(false); {
QListWidgetItem *item = new QListWidgetItem(name);
item->setFont(QFont("Times", 12, QFont::Bold));
VNodeDetail node(id, typeTool, typeNode, mx, my, reverse);
item->setData(Qt::UserRole, QVariant::fromValue(node));
ui.listWidget->addItem(item);
ui.listWidget->setCurrentRow(ui.listWidget->count()-1);
ui.doubleSpinBoxBiasX->blockSignals(true);
ui.doubleSpinBoxBiasY->blockSignals(true);
ui.doubleSpinBoxBiasX->setValue(qApp->fromPixel(node.getMx()));
ui.doubleSpinBoxBiasY->setValue(qApp->fromPixel(node.getMy()));
if (node.getTypeTool() == Tool::NodePoint)
{
ui.checkBoxReverse->setChecked(false);
ui.checkBoxReverse->setEnabled(false);
}
else
{
ui.checkBoxReverse->setEnabled(true);
ui.checkBoxReverse->setChecked(node.getReverse());
}
ui.doubleSpinBoxBiasX->blockSignals(false);
ui.doubleSpinBoxBiasY->blockSignals(false);
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------